You are viewing a plain text version of this content. The canonical link for it is here.
Posted to derby-dev@db.apache.org by Shazin Sadakath <sh...@gmail.com> on 2009/11/20 10:08:54 UTC
Stored Procedures
Hi All,
Can anyone guide me on what classes in the source are associated with
creating a DerbySQL Routine please???
Thanks,
Shazin
Re: Stored Procedures
Posted by Rick Hillegas <Ri...@Sun.COM>.
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 <ma...@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
>
>
Re: Stored Procedures
Posted by Shazin Sadakath <sh...@gmail.com>.
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??
2. When the Created Procedure/Function is called at the run time. How does
the loading and execution
take place?
Thanks,
Shazin
On Fri, Nov 20, 2009 at 7:34 PM, Rick Hillegas <Ri...@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
>
>
Re: Stored Procedures
Posted by Rick Hillegas <Ri...@Sun.COM>.
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