The PROPERTIES keyword and optimizer hints have been removed
from Cloudscape before the code was contributed to Derby.
I'm not sure where you've found the PROPERTIES keyword, but
as far as I can tell it is no longer part of the manual.

The reason it was removed is because the syntax is non-standard SQL.

Removing optimizer hints (and other hints) from the language because they are non-standard is pretty ridiculous, in my opinion. Hints are almost inevitably non-standard. The SQL standard doesn't even recognize the concept of optimization, much less optimizer hints.


Given that optimizer hints are useful (even necessary), how could one support them in a "standard" way? I suppose they could be hidden in comments, although building the support for this isn't simple (the lexer strips out comments, so for the hints to make it into the query tree would require some co-ordination between the lexer and the rest of the parser). This still wouldn't be standard, but it would hide the non-standard syntax so the query would still work with other database systems.

SQL comments in Derby are delimited by "--" and end-of-line, which would force the user to put line breaks in their queries if they wished to use hints. That is, the following:

    select a, b from s, t where c = d

would have to change to:

    select a, b
    from s -- properties index=sx
           ,t -- properties index=tx
    where c = d

I suspect supporting syntax in comments would involve a lot of work and tricky coding. The Derby lexer rule for comments is as follows (from sqlgrammar.jj):

SKIP :
{       /* comments */
  <SINGLE_LINE_SQLCOMMENT: "--" (~["\n","\r"])* ("\n"|"\r"|"\r\n")>
}

This tells the lexer to ignore anything that starts with "--" up until the end of the line. The skipped-over characters are not part of any token, and are not accessible to the grammar. It might be possible to define two types of comment, one starting with "-- properties" and the other starting with "--" followed by anything other than "properties", and to make "-- properties" a regular token. The problem then remains how to recognize end-of-line from within the grammar (note that a different rule tells the lexer to ignore whitespace).

I remember that JavaCC has some sort of feature that allows the grammar to set a state which then affects the behavior of the lexer. It might be necessary to use this feature to implement commented hints.

- Jeff Lichtman
[EMAIL PROTECTED]
Check out Swazoo Koolak's Web Jukebox at
http://swazoo.com/




Reply via email to