db-derby-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Bryan Pendleton <bpendleton.de...@gmail.com>
Subject Re: SQL processing
Date Fri, 23 Apr 2010 15:40:51 GMT
?? ??????????? wrote:
> What classes are responsible for producing logical model from SQL? I 
> want to understand how to code the equivalent of, say, following SQL:
> select grasp, result, density from REDUNDANT;
> to directly force necessary execution mechanisms, instead of doing SQL 
> sting pre-processing. John  

I think this would be a fairly tricky thing to do. The execution API
code is quite tightly bound up with the parser and compiler. Internally,
when Derby code occasionally wants to execute some SQL during the
processing of other work (e.g., for accessing system catalogs), the
the technique even then is to generate, parse, compile, and execute
a string of SQL, rather than trying to program directly against the
execution classes.

If you wanted to understand the execution classes and how they work,
I think that a good start is to read the code in impl.sql.execute,
and then to have a look at how the code in impl.sql.compile constructs
those execution-time objects.

For the particular query you mention above, you'll want to look at
ProjectRestrictResultSet and how it works together with TableScanResultSet
and the ScanController class.

You should know ahead of time that this is quite complicated code; for
example, the projection logic (extracting the values of 'grasp', 'result',
and 'density' from the current row) is handled by generating Java
bytecode on-the-fly during compilation and then invoking that byte code
at execution time.



View raw message