Environment translation for extended references; global directory translation
Final Release Note
The environment variable ydb_env_translate
can identify a shared library containing a routine to provide an optional environment translation for extended references. If $ydb_env_translate
is undefined, YottaDB can use a shared library identified by $gtm_env_translate
; defaulting to no environment translation. Previously, YottaDB only sought a value of the gtm_env_translate
environment variable.
Global directories defined by $zgbldir
can also be similarly translated. When $zgbldir
is set, if the environment variable ydb_gbldir_translate
identifies a shared library with the entry point ydb_gbldir_xlate()
, the global directory used is the value assigned to $zgbldir
as translated by the routine. ydb_gbldir_xlate()
has the same signature as the ydb_env_xlate()
routine used for environment translation:
int ydb_gbldir_xlate(ydb_string_t *in1, ydb_string_t *in2, ydb_string_t *in3, ydb_string_t *out);
where:
-
in1
references the value being assigned to$zgbldir
. -
in2
is the NULL string - the parameter exists only so that the signature matches that ofydb_env_translate()
. -
in3
references$zdirectory
the current directory of the process. -
out
is a return value that references the actual global directory file to be used.
A return value other than zero (0) indicates an error in translation, and is reported as a YottaDB error.
We thank Thomas Morstein (@ztmr) for working with us on this enhancement. [#488 (closed)]
Description
When ydb_env_translate
is used, only gtm_env_xlate
symbol is resolved, not ydb_env_xlate
. It is possible to work around using C function alias technique, just does not seem to be consistent behaviour to define ydb_
variable and implement gtm_
symbol.
Also, this translation seems to be invoked only when an extended global reference is being expanded. Setting to $ZGBLDIR
does not seem to perform such a translation.
It would be nice if we could set $ZGBLDIR="Something"
, it would hold that value as is (only being translated when opening the GD file). That would allow for a proper UCI/VOL/Namespace emulation.
NOTE: We currently emulate namespaces using shell variable named as a desired namespace, just with $
-prefix. That works but is not nice and can be problematic if the variable gets expanded somewhere and does not map back to the original namespace (logical/variable) name.
Draft Release Note
YottaDB allows the translation routine to be named either ydb_env_translate or gtm_env_translate though it looks for ydb_env_translate first. Previously, only gtm_env_translate was supported.
In addition support is added for a global directory translation facility similar to the environment translation facility available in extended references. When $ZGBLDIR is set, if $ydb_gbldir_translate is defined (which should contain the path and name of a shared library containing the entry point ydb_gbldir_xlate()), the value $ZGBLDIR is being set to is run through this translation routine to get a value that is then resolved and loaded. The ydb_gbldir_xlate() routine has the same signature as the ydb_env_xlate() routine does that is used for environment translation:
int ydb_gbldir_xlate(ydb_string_t v1, ydb_string_t v2, ydb_string_t v3, ydb_string_t out);
where:
- v1 contains the value that $ZGBLDIR is being set to.
- v2 contains the NULL string (not used - present only so signature matches ydb_env_translate).
- v3 contains $ZDIRECTORY.
- out is where a return value description is placed.