FirebirdSQL / firebird

Firebird server, client and tools
https://www.firebirdsql.org/
1.24k stars 214 forks source link

FreePascal as an embedded language in Firebird [CORE3571] #3925

Open firebird-automations opened 13 years ago

firebird-automations commented 13 years ago

Submitted by: JimBeam (jimbeam)

Votes: 6

0. Background

FreePascal (FPC) is an object oriented variant of Pascal that looks very much like Delphi (in fact, there's a Delphi compatibility switch so you can port your existing code). Firebird is an open source relational database derived from Interbase.

1. FreePascal as an embedded language in Firebird

For Firebird, FreePascal could be a good embedded language (for writing stored procedures/functions/triggers) next to e.g. Java.

2. End user considerations

2.1 A lot of developers that use Firebird program in Delphi. As FreePascal syntax is (almost) identical, these developers can easily port their code between the database and the application.

2.2 FreePascal may be easier to learn than Java for some people and would make a nice alternative as opposed to e.g. including C or C++

2.3 FreePascal might not run/is not supported for some platforms that Firebird 3 will be released for. Perhaps HP-UX? Firebird 2.5 runs on Windows (x86/x64), Linux versions (x86/x64), Solaris (Sparc and Intel), HP-UX (PA-Risc) and Mac OSX.

3. Development considerations

I only know enough to make wild guesses... that doesn't stop me from making them, though.

3.1 Obviously, Firebird must allow running compiled code (as opposed to running code in a Java Virtual Machine), presumably in a form of dynamic library. This will have obvious security implications; on the Firebird dev mailing list just trusting the code, sandboxes, restriction of used units, different levels of trust as implemented in PostgreSQL, code signing was discussed.

3.2 Firebird must be modified to include (a stripped down version of?) the FPC compiler (or store the location of the compiler) and call it whenever the FreePascal source code in a procedure is changed. This might not be necessary for production servers as long as embedded Pascal code is compiled on developer machines and the resulting object code is loaded into the production database.

3.3 FreePascal will need to have some way to access, manipulate and return the data in the database and call other Firebird stored procedures, functions, etc. FPC already has good database access, including Interbase/Firebird support, but some kind of interface unit for direct access will need to be added.

3.4 FreePascal will need to use the Firebird memory manager. Using various memory managers is fortunately already possible in FPC.

3.5 Most importantly: it will probably require a lot of work on both ends to get this done. Fortunately, both Firebird and FPC have an active developer community with good communication and bug tracker systems, so this helps.

4. More information/collaboration

Please see further discussion following from my 27 July 2011 post to the fpc mailing list http://lists.freepascal.org/lists/fpc-pascal/2011-July/029715.html and Firebird development list: https://lists.sourceforge.net/lists/listinfo/firebird-devel (Mostly on the Firebird list).

Firebird issue/feature/request: CORE3571 FreePascal issue/feature request: http://bugs.freepascal.org/view.php?id=19946

firebird-automations commented 13 years ago
Modified by: JimBeam (jimbeam) description: 0\. Background ============= FreePascal \(FPC\) is an object oriented variant of Pascal that looks very much like Delphi \(in fact, there's a Delphi compatibility switch so you can port your existing code\)\. Firebird is an open source relational database derived from Interbase\. 1\. FreePascal as an embedded language in Firebird ======================================== For Firebird, FreePascal could be a good embedded language \(for writing stored procedures/functions/triggers\) next to e\.g\. Java\. 2\. End user considerations ========================== 2\.1 A lot of developers that use Firebird program in Delphi\. As FreePascal syntax is \(almost\) identical, these developers can easily port their code between the database and the application\. 2\.2 FreePascal may be easier to learn than Java for some people and would make a nice alternative as opposed to e\.g\. including C or C\+\+ 2\.3 FreePascal might not run/is not supported for some platforms that Firebird 3 will be released for\. Perhaps HP\-UX? Firebird 2\.5 runs on Windows \(x86/x64\), Linux versions \(x86/x64\), Solaris \(Sparc and Intel\), HP\-UX \(PA\-Risc\) and Mac OSX\. 3\. Development considerations ======================== I only know enough to make wild guesses\.\.\. that doesn't stop me from making them, though\. 3\.1 Obviously, Firebird must allow running compiled code \(as opposed to running code in a Java Virtual Machine\), presumably in a form of dynamic library\. This will have obvious security implications; on the Firebird dev mailing list just trusting the code, sandboxes, restriction of used units, different levels of trust as implemented in PostgreSQL, code signing was discussed\. 3\.2 Firebird must be modified to include \(a stripped down version of?\) the FPC compiler \(or store the location of the compiler\) and call it whenever the FreePascal source code in a procedure is changed\. This might not be necessary for production servers as long as embedded Pascal code is compiled on developer machines and the resulting object code is loaded into the production database\. 3\.3 FreePascal will need to have some way to access, manipulate and return the data in the database and call other Firebird stored procedures, functions, etc\. FPC already has good database access, including Interbase/Firebird support, but some kind of interface unit for direct access will need to be added\. 3\.4 FreePascal will need to use the Firebird memory manager\. Using various memory managers is fortunately already possible in FPC\. 3\.5 Most importantly: it will probably require a lot of work on both ends to get this done\. Fortunately, both Firebird and FPC have an active developer community with good communication and bug tracker systems, so this helps\. Please see further discussion following from my 27 July 2011 post to the fpc mailing list and Firebird development list: \(Mostly on the Firebird list\)\. =\> 0\. Background ============= FreePascal \(FPC\) is an object oriented variant of Pascal that looks very much like Delphi \(in fact, there's a Delphi compatibility switch so you can port your existing code\)\. Firebird is an open source relational database derived from Interbase\. 1\. FreePascal as an embedded language in Firebird ======================================== For Firebird, FreePascal could be a good embedded language \(for writing stored procedures/functions/triggers\) next to e\.g\. Java\. 2\. End user considerations ========================== 2\.1 A lot of developers that use Firebird program in Delphi\. As FreePascal syntax is \(almost\) identical, these developers can easily port their code between the database and the application\. 2\.2 FreePascal may be easier to learn than Java for some people and would make a nice alternative as opposed to e\.g\. including C or C\+\+ 2\.3 FreePascal might not run/is not supported for some platforms that Firebird 3 will be released for\. Perhaps HP\-UX? Firebird 2\.5 runs on Windows \(x86/x64\), Linux versions \(x86/x64\), Solaris \(Sparc and Intel\), HP\-UX \(PA\-Risc\) and Mac OSX\. 3\. Development considerations ======================== I only know enough to make wild guesses\.\.\. that doesn't stop me from making them, though\. 3\.1 Obviously, Firebird must allow running compiled code \(as opposed to running code in a Java Virtual Machine\), presumably in a form of dynamic library\. This will have obvious security implications; on the Firebird dev mailing list just trusting the code, sandboxes, restriction of used units, different levels of trust as implemented in PostgreSQL, code signing was discussed\. 3\.2 Firebird must be modified to include \(a stripped down version of?\) the FPC compiler \(or store the location of the compiler\) and call it whenever the FreePascal source code in a procedure is changed\. This might not be necessary for production servers as long as embedded Pascal code is compiled on developer machines and the resulting object code is loaded into the production database\. 3\.3 FreePascal will need to have some way to access, manipulate and return the data in the database and call other Firebird stored procedures, functions, etc\. FPC already has good database access, including Interbase/Firebird support, but some kind of interface unit for direct access will need to be added\. 3\.4 FreePascal will need to use the Firebird memory manager\. Using various memory managers is fortunately already possible in FPC\. 3\.5 Most importantly: it will probably require a lot of work on both ends to get this done\. Fortunately, both Firebird and FPC have an active developer community with good communication and bug tracker systems, so this helps\. 4\. More information/collaboration ========================= Please see further discussion following from my 27 July 2011 post to the fpc mailing list and Firebird development list: \(Mostly on the Firebird list\)\. Firebird issue/feature/request: [CORE3571](https://github.com/FirebirdSQL/firebird/issues?q=CORE3571+in%3Atitle) FreePascal issue/feature request: