Go to file
2023-02-28 16:06:26 +01:00
build Add Visual Studio project files 2023-02-06 13:50:42 +01:00
docs/images WIP 2023-02-06 13:30:21 +01:00
sql LoadBlobFromFile takes only a single parameter and returns a blob 2023-02-02 16:10:25 +01:00
src Resize buffer if BytesRead is less than MaxSegmentSize 2023-02-03 17:09:22 +01:00
test Use heredoc correctly 2023-02-28 16:05:57 +01:00
.editorconfig Add extra settings 2023-01-24 19:17:43 +01:00
.gitignore ignore 2023-02-28 16:06:26 +01:00
.kateconfig misc 2023-01-23 15:43:45 +01:00
.kateproject Add editor config files 2023-01-23 15:31:00 +01:00
CMakeLists.txt Separate out error messages if firebird include dir or lib dir cannot be found. 2023-01-25 11:39:36 +01:00
compile_flags.txt Initial commit 2023-01-20 16:18:10 +01:00
Readme.md Add more doc notes 2023-02-06 14:05:48 +01:00
VERSION.txt Initial Commit 2023-01-20 16:17:42 +01:00
workspace.code-workspace Add VSCode workspace 2023-01-20 13:00:23 +01:00
write_build_no.sh Add versioning and .rc for windows 2023-01-20 19:34:51 +01:00

MyFirstUDRKit

Welcome to MyFirstUDRKit. As you can tell from the name, this plugin is not intended for production use. It is just to play with. When you are ready feel free to fork it and give it a new name.

What is in the kit?

There are currently four functions available. Two div and flagged are simple smoke test functions. They do very little but they demonstrate two things:

  • how to write basic C code in a UDR
  • do quick tests to verify the basics of UDR plugin develeopment and testing.

There are two other functions available:

  • LoadBlobFromFile
  • SaveBlobToFile

These are more ambitious.

  • they are written in C++
  • they demonstrate how to work with the new Firebird OO API

Forking the repository

For test purposes you can just clone the repo and try building and testing the code. However, for serious work it is recommended that you clone the repo and give the project a new name. When doing so be sure to search and replace all references to MyFirstUDRKit to your new project name. There are two strings to replace:

MyFirstUDRKit
MY_FIRST_UDR_KIT

Setting up cmake

Run the cmake gui and fill in the path information. Set the source to the root of the location where you have cloned the repo. CMake looks for the file CMakeLists.txt. Binaries will be built under build/x86_64-win64 and build/x86_64-linux for linux.

cmake - pre-config

Click on Configure to generate the default config for the current platform. This will open a dialogue. When prompted choose the Unix makefiles generator for linux. Under Windows choose Visual Studio 15 2017 and be sure to set the Optional platform for generator to x64 for windows as in the screenshot below:

cmake - windows generator

Click on Finish and you should then see a screen similar to this:

cmake - config

Under linux the only change needed at this stage is to set CMAKE_BUILD_TYPE to Debug`. Under Windows there should be nothing further to do.

You can then click on Generate and you should end up with a screen similar to this:

cmake - config

If you want to start again be sure to click on FILE|DELETE CACHE

Building the kit

On linux just do:

cd build/x86_64-linux
make

On windows just open the solution in visual studio and build the solution.

Testing

There is a test suite available for testing under linux in the test directory.

Stress testing

TO DO

  • compile fb for valgrind
  • stress test for leakage

Installation

Run the sql on the target database

In the sql directory there are two scripts.

MyFirstUDRKit.ddl contains the function declarations. You can run the script directly on your database to register the functions.

MyFirstUDRKitPackage.sql, although incomplete, demonstrates how you can declare the functions as part of a package.

When things go wrong

Errors when registering a function

Invalid index 1 in function IMetadataBuilder::setType

This error indicates that the parameters in the sql function declaration do not match the parameters in the actual function. Check your sql with the FB_UDR_MESSAGE declarations.

Debugging

TO DO