Validating the 'SBSPACENAME' sblobspace
Posted in 2006
Topics: Storage & Space Management, Connectivity: ODBC / JDBC / .NET, Server Administration, Platform-Specific Issues
Hello, Question: My application is a simple application that connects to the Informix instance, validates that some preconditions are fulfilled and starts creating a database (including dbspaces and such) and enables datablades for the database. Now one of the datablades needs the default sbspace to be present, and thus will fail to enable if not. What I'd like my program to do, is to validate that the sbspace stated in the onconfig SBSPACENAME parameter has been created. One way I could do it, is to parse the onconfig file, fetch the SBSPACENAME and create a lookup in the SYSDBSPACES table of sysmaster. BUT: I'd much rather do it entirely without file system access (reading the onconfig file). So, do any of you have an idea on how to either: A. Read parameters from the onconfig file via SQL. B. Perform a call (could be either command-line or SQL) that will give the name of the default SBSPACE. Thanks in advance! Server Info: Platform: Windows Server 2003 Database is Informix Dynamic Server 10...TC3 Application info: Connecting through JDBC only. Full access to the file system, including INFORMIXDIR
Thor Kristensen wrote:
> Question:
> My application is a simple application that connects to the Informix
> instance, validates that some preconditions are fulfilled and starts
> creating a database (including dbspaces and such) and enables datablades for
> the database.
> Now one of the datablades needs the default sbspace to be present, and thus
> will fail to enable if not.
> What I'd like my program to do, is to validate that the sbspace stated in
> the onconfig SBSPACENAME parameter has been created.
> One way I could do it, is to parse the onconfig file, fetch the SBSPACENAME
> and create a lookup in the SYSDBSPACES table of sysmaster. BUT: I'd much
> rather do it entirely without file system access (reading the onconfig
> file).
> So, do any of you have an idea on how to either:
> A. Read parameters from the onconfig file via SQL.
Poke around in sysmaster - maybe sysconfig table?
> B. Perform a call (could be either command-line or SQL) that will give the
> name of the default SBSPACE.
Is a command-line call significantly different from file system access?
sed -n -e 's/#.*//' -e 's/[ ][ ]*/ /g' -e '/^ *$/d' \\
-e '/^ *SBSPACENAME /p' \\
${INFORMIXDIR:-/usr/informix}/etc/${ONCONFIG:-onconfig.std}
This should give you all the line(s) that define SBSPACENAME in a format
with no comments. You'd need to capture the output with back-ticks or
'$(...sed command...)' and validate the resulting (possibly empty) list
of words. The sed script doesn't print lines by default (-n). The
first regular expression deletes comments, then next converts any
sequences of tabs and blanks into single blanks, to simplify the rest of
the script. The third deletes blank lines (barely necessary here), and
the fourth matches the required SBSPACENAME parameter, requiring a space
after it (which means it would ignore an empty SBSPACENAME line that had
no trailing comment - but that means there is no defined SBSPACENAME, so
it doesn't matter). The file name more or less defaults to the correct
name for the ONCONFIG file - you can debate whether it would look for
'onconfig' before hunting for 'onconfig.std', but doing a test based on
file presence requires a messier substitution.
A more serious issue is whether you can specify SBSPACENAME without
taking IDS down - if you can, it will be in a recent (10.00, maybe 9.40)
version via 'onmode -wf SBSPACENAME=sbspace'. I'm not confident you can
do that - but you can RTF(abulous)M as well as I can.
--
Jonathan Leffler #include <disclaimer.h>
Email: jleffler@earthlink.net, jleffler@us.ibm.com
Guardian of DBD::Informix v2005.02 -- http://dbi.perl.org/