Oninit® SQLMorph — Build and Install
Convert
sqlmorph -s informix-4gl [--schema db.sch] -t informix-native -o out/ f1.4gl f2.4gl
Without -t the command only validates the source and writes nothing. With it, every FUNCTION
becomes its own set of files, and nothing at all is written if any function has a diagnostic, so a
bundle is never half converted. Exit status is 0 for success and 2 when the source was rejected.
--schema takes a dbschema snapshot. It is needed for DEFINE x LIKE table.column
and to tell a host variable from a column of the same name inside an SQL statement.
Instead of a snapshot file, --schema-db mydb reads the schema from the database itself with dbschema.
It is off unless you ask for it, so converting never touches a database by default. Reading every table of a large database
takes time, so add --schema-table customer --schema-table orders (repeatable) to read only the tables the 4GL
uses. SQLMORPH_DBSCHEMA replaces the command (%s is the database, %t the table
selection), for example to run dbschema inside a container.
Files per function
| File | Contents |
|---|---|
| <name>.c | The UDR. Each 4GL statement is a short block preceded by /* 4GL line N */. |
| <name>_install.sql | CREATE FUNCTION (or PROCEDURE when the function returns nothing) WITH (HANDLESNULLS), LANGUAGE C. |
| <name>_manifest.json | Callees, compiler version, minimum engine version, hashes of the source and of the generated code. |
| <name>_check.sql | Lists callees that are not installed in the database. |
The shared object is named <name>_<hash>.so, where the hash is of the generated code. A new
version never overwrites a module the engine may have loaded, and a call already running finishes on the old code.
Build and deploy
tools/fgl_deploy.sh -d mydb [-c container] [-r dir] out/
The tool compiles each module, checks the glibc and architecture it needs against the engine host, copies it to
$INFORMIXDIR/extend/sqlmorph/ without overwriting, runs a rolled-back dry run of the install scripts
and then installs them in one transaction. It records the current version and the history of each converted routine
in two small tables. Running it again with unchanged source installs nothing.
Build on the engine’s own system (or one with the same glibc and architecture). A library built against a newer glibc than the engine host’s will not load, and the tool refuses to install one.
Use
EXECUTE FUNCTION order_total(1042, 8.25); SELECT c.name, order_total(c.id, 8.25) FROM customer c WHERE c.region = "EU";
Engines
The generated code uses the documented DataBlade API only. It is built and run against Informix 14.10 and 15.0.
Two engine rules show up in use: the engine refuses a call whose function writes a table the calling statement
reads (error -7435), and a function used in a functional index must be declared NOT VARIANT.