Thu Aug 30 13:32:10 PDT 2007
- Previous message: [Slony1-general] Re: Bug in slonik SQL parser: comments are not removed properly
- Next message: [Slony1-general] Bug in remote_worker.c (typo)
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
"Andrew Hammond" <andrew.george.hammond at gmail.com> writes: > On 8/30/07, Jan Wieck <JanWieck at yahoo.com> wrote: > On 8/29/2007 2:52 PM, Dmitry Koterov wrote: > > And much worse - seems such DDL with comments breaks the whole > > replication (fortunately I have run it on a test server, not in production). > > I watched sl_event table on a subscriber and noticed that the whole DDL > > (with comments included) are passed and saved in the subscriber. > > Where in the ANSI SQL standard does it allow -- comments nested inside > of /* ... */ comments? > > > I can see having problems with "real" nested comments. > /* > layer one > /* > layer two > */ > I'll bet this doesn't work > */ > Or, if you want to get really stupid, like this. > -- this is a stupid place to /* start > a multi-line coment > */ Note that PostgreSQL supports nested comments, which, I should note, C *does not.* That is, in C, the following comment is *broken*: /* Here is a comment /* that nests */ */ That comment ends, in C, after the first "*/". In effect, in C, the following is a single comment: /* Here is a comment /* that nests */ c++; So the first comment that you describe is, as far as C, is invalid, but PostgreSQL does accept it. Your second example: -- quote to end of a line that includes /* what looks like the start of a C-style comment multilining */ is treated, by PostgreSQL, as invalid. The "--" hides everything until the end of the line, and that includes the "/*", so that its parser does not recognize there being any beginning to what you imagined was going to begin commenting line 2. > But honestly, a parser that fails because of comment characters inside a comment... that's kinda broken. > /* this may be stupid > -- but, really it should still work. */ PostgreSQL recognizes this as a valid comment. Since the parser is already in "comment mode" when it gets to "--", that does NOT hide the rest of the line. > Just because Postgres itself allows it doesn't mean that every piece of > software working with Postgres must be aware of this, does it? > > I think that for any software which works _only_ with Postgres, it > is reasonable to assume that it will attempt to be as close to the > Postgres interpretation / implementation of SQL as possible. One of > the ways to test DDL before applying it via slonik is to run it with > a rollback on each node. If a script passes this test, then it seems > to me that it's reasonable to expect it to work via EXECUTE DDL. > Hmm, maybe that's an idea for a new feature "EXECUTE DDL DRYRUN" or > something of that nature... The nature of this particular problem actually makes my head hurt. - My first thought was, "no big deal, I'll just get the parser to recognize C-style comments." I have code not yet checked in that does this, and which survives something of a "torture test." Here's a pretty reasonable torture test: select * from /************ *foooo* /- * / here is a tremendously ugly C-style comment * * * * * / -- **{***(***[****/ b; However, in looking at things deeper, then comes the "ow!" part. C doesn't support nested comments, but *PostgreSQL does*!!! Nested /* /* */ */ comments are somewhat harder to support, and when this actually *IS NOT* supporting a "C style comment" (as there's demonstrably different behaviour), it frankly strikes me as silly to head deeply into this. There is a conspicuous bug in that the parser presently never comes out of "C-style comment mode;" I'm happy enough to address that. But I am also loathe to go to extremes to support functionality that is also deviant from what people's expectations will generally be. -- let name="cbbrowne" and tld="linuxfinances.info" in name ^ "@" ^ tld;; http://cbbrowne.com/info/slony.html "There are three kinds of program statements: sequence, repetition, and seduction."
- Previous message: [Slony1-general] Re: Bug in slonik SQL parser: comments are not removed properly
- Next message: [Slony1-general] Bug in remote_worker.c (typo)
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
More information about the Slony1-general mailing list