db-derby-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Rick Hillegas <Richard.Hille...@Sun.COM>
Subject Re: Stored Procedures
Date Mon, 23 Nov 2009 16:55:58 GMT
Hi Shazin,

Some responses inline...

Shazin Sadakath wrote:
> Hi Rick,
>
> Thanks for that very descriptive reply. 
>
> I have some more questions.
>
> 1. So what the Create Procedure/Function statement actually does is 
> creating an Alias to 
>     a static java method??
That's right. So a Procedure/Function definition results in a row in 
SYS.SYSALIASES. It also results in a couple rows in SYS.SYSCOLUMNS, one 
for each parameter to the Procedure/Function.
>
> 2. When the Created Procedure/Function is called at the run time. How 
> does the loading and execution
>    take place?
In Derby, a prepared SQL statement is a generated Java class, which 
Derby fills in and compiles. The invocation of the procedure/function is 
just generated byte code for calling the static method that is bound to 
the procedure/function. Derby class loading is a little tricky, but at a 
high level classes can come from three places:

o From the VM classpath

o From jar files which have been stored in the database and wired into a 
database-specific classpath

o From the cache of generated classes which are the executable forms of 
SQL statements

I am going on vacation now so please don't be put off by my radio 
silence. Hopefully, other developers in the community can answer 
follow-on questions which you may have.

Cheers,
-Rick
> Thanks,
> Shazin
>
> On Fri, Nov 20, 2009 at 7:34 PM, Rick Hillegas 
> <Richard.Hillegas@sun.com <mailto:Richard.Hillegas@sun.com>> wrote:
>
>     Shazin Sadakath wrote:
>
>         Hi All,
>
>         Can anyone guide me on what classes in the source are
>         associated with creating a DerbySQL Routine please???
>
>         Thanks,
>         Shazin
>
>     Hi Shazin,
>
>     The processing flow is something like this:
>
>     o The parser (sqlgrammar.jj) creates a CreateAliasNode to
>     represent the user's CREATE FUNCTION/PROCEDURE
>
>     o The rest of compilation for the CREATE FUNCTION/PROCEDURE
>     statement is handled by the bindStatement() and
>     makeConstantAction() methods of the CreateAliasNode.
>
>     o In particular, CreateAliasNode.makeConstantAction() creates the
>     execution-time object which does the heavy lifting: a
>     CreateAliasConstantAction object.
>
>     o At statement-execution time, the CreateAliasConstantAction
>     populates the data dictionary. That is the
>     CreateAliasConstantAction adds a persistent AliasDescriptor, which
>     describes the new function/procedure.
>
>     o The AliasDescriptor is stored in SYS.SYSALIASES. The really
>     interesting bits of the AliasDescriptor are the AliasInfo object
>     which it contains. That AliasInfo object is stored in the
>     ALIASINFO column of SYS.SYSALIASES.
>
>     Hope this helps,
>     -Rick
>
>


Mime
View raw message