wkim / h2database

Automatically exported from code.google.com/p/h2database
0 stars 0 forks source link

Expose getter methods on some internal classes for engine embedders, query rewriters, AST walkers #457

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
Hi, I've made this request before to expose the internal state of classes like 
Select, Condition and related classes. 

Why:
This is very essential for people who are embedding H2 and wish to hook into 
the query parsing sequence. Sometimes it is required to rewrite the query 
transparently (from the user's point of view) before issuing it against the 
tables and views.

Also, for people who are implementing custom TableEngines, this is the best 
place to intercept, examine and modify the queries.

Ref:
1) 
https://groups.google.com/forum/?fromgroups=#!topic/h2-database/8rokZy6zj4k[1-25
-false]
2) 
https://groups.google.com/forum/?fromgroups=#!topic/h2-database/r1he1r7x6aU[1-25
-false]
3) 
https://groups.google.com/forum/?fromgroups=#!topic/h2-database/RK0Za5Zaysc[1-25
-false]

Patch:
From my experience and usage scenarios, I've addressed those shortcomings in 
the internal classes and included a patch.

The patch merely exposes some getter methods, some classes that were package 
local are now public. 

It also fixes some inconsistencies in the Select class where upon calling 
init() the internal state is read, optimized and the original parsed data is 
not available. I've modified the getter methods to infer the data and still 
return valid results even after the init() method is called.

No new code has been introduced. There is one simple test class to make sure 
the Select AST works.

Thanks!
Ashwin Jayaprakash.

Original issue reported on code.google.com by ashwin.j...@gmail.com on 24 Apr 2013 at 6:39

Attachments:

GoogleCodeExporter commented 8 years ago
Hi, I'm attaching a new version of the patch. This includes some minor, 
additional H2 classes with public getters.

Hope you guys can integrate this into H2 trunk.

Ashwin.

Original comment by ashwin.j...@gmail.com on 8 May 2013 at 9:11

Attachments:

GoogleCodeExporter commented 8 years ago
Hi,

I'm sorry, but I don't think it's a good idea to make more of the internal part 
of the database engine available in the form of a public API. It would limit 
changing the internals, and it would make your code rely too much on internals.

If you want to extend H2, I suggest to simply provide patches for the features 
you want to add, instead of making H2 pluggable so that you don't have to 
submit your code.

Original comment by thomas.t...@gmail.com on 31 May 2013 at 2:50