Emulator for an SQL relational-database6003026Abstract Method and means for porting an existing application (An) using a relational-database with SQL interface toward a hardware platform (HW2) with a reduced software configuration which does not include an SQL relational-database. The invention emulates an SQL database enabling hardware resources saving and providing a subset of functions for: creating SQL tables and defining fields; storing, modifying and deleting data on created tables, with a type check, retrieving such data by using SQL filters. Functions can be subdivided into levels (M1, M2, M3) in order to: convert an SQL statement, coming from an existing user application (An), into a sequence of elementary interface functions (IF1 . . . IFn), use said interface functions to read/write data files (F1 . . . Fn), process output data to be supplied to the requesting user application (An). Claims I claim: Description BACKGROUND OF THE INVENTION
______________________________________
# Table ASH.sub.-- STATES
#
H This table has 4 columns.linevert split.4.linevert split.
#
C Application Service Id.
.linevert split.NUMBER.linevert split.3.linevert split.NOT
NULL.linevert split.UNIQUE INDEX.linevert split.
C Appiication Entity Name
.linevert split.CHAR.linevert split.32.linevert split.NOT
NULL.linevert split.UNIQUE INDEX.linevert split.
C Sequence Number
.linevert split.NUMBER.linevert split.3.linevert
split.NOT NULL.linevert split.UNIQUE INDEX.linevert split.
C StateName .linevert split.CHAR.linevert split.20.linevert
split.NOT NULL.linevert split.
H
#
* 1.linevert split.dh.sub.-- 1.linevert split. 0.linevert split.IDLE.linev
ert split.
* 1.linevert split.dh.sub.-- 1.linevert split. 1.linevert split.START.sub.
-- INT.sub.-- DIAL.sub.-- PEND .linevert split.
* 1.linevert split.dh.sub.-- 1.linevert split. 2.linevert split.INT.sub.--
DIAL.sub.-- EXP .linevert split.
* 1.linevert split.dh.sub.-- 1.linevert split. 3.linevert split.INT.sub.--
DIAL.sub.-- PEND .linevert split.
* 1.linevert split.dh.sub.-- 1.linevert split. 4.linevert split.WAIT.sub.-
- FOR.sub.-- CONT .linevert split.
* 1.linevert split.dh.sub.-- 1.linevert split. 5.linevert split.WAIT.sub.-
- FOR.sub.-- LAST .linevert split.
* 1.linevert split.dh.sub.-- 1.linevert split.998.linevert split.PROVIDER.
sub.-- ABORT .linevert split.
* 1.linevert split.dh.sub.-- 1.linevert split.999.linevert split.SUCCESFUL
.sub.-- COMPLETED .linevert split.
#
* 2.linevert split.bh.sub.-- 1.linevert split. 0.linevert split.IDLE
.linevert split.
* 2.linevert split.bh.sub.-- 1.linevert split. 1.linevert split.COMMAND.su
b.-- EXPECTED .linevert split.
* 2.linevert split.bh.sub.-- 1.linevert split.998.linevert split.PROVIDER_
ABORT .linevert split.
* 2.linevert split.bh#1.linevert split.999.linevert split.SUCCESFUL
COMPLETED .linevert split.
#
______________________________________
The skilled man will be aware of still further configuration mode. By way of further explanation, reference is directed to FIG. 3 which is in diagrammatic form. An SQL statement, included in the user application, cause the activation of an emulator interface functions IFi, which invokes a sequence, depending on the specific SQL statement, of emulation library functions LF1 . . . LFm accessing the ASCII files AF1 . . . AFk containing the user data. For example when the SQL statement INSERT INTO Tab2 (field.sub.-- name1,field.sub.-- name2) VALUES (`field.sub.-- value1`, `field.sub.-- value2`); is invoked by the user application An, the INSERT emulator interface function IF1 is activated; it calls a sequence of emulation library functions accessing the Tab2 ASCII file AF2 containing the user data, as it will be explained in more detail later. Another example is the following: when the SQL statement SELECT FROM Tab2 is invoked by the user application An, the SELECTn emulator interface function IFn is activated; it calls a sequence of emulation library functions accessing the Tab2 ASCII file. A modular emulation library is available providing a set of functions LF1 . . . LFm. A subset of said functions can be combined to implement an SQL statement. An example of library functions is the following:
______________________________________
F1 .sub.-- get.sub.-- table.sub.-- descr
F2 .sub.-- open.sub.-- table
F3 .sub.-- close.sub.-- table
F4 .sub.-- search.sub.-- first.sub.-- row
F5 .sub.-- search.sub.-- next.sub.-- row
F6 .sub.-- fetch.sub.-- row.sub.-- at.sub.-- curr.sub.--
pos
F7 .sub.-- fetch.sub.-- row.sub.-- at.sub.-- abs.sub.--
pos
F8 .sub.-- write.sub.-- row
F9 .sub.-- delete.sub.-- row
F10 .sub.-- refresh.sub.-- table.sub.-- file
______________________________________
A detailed description of each function is provided later. In FIG. 4 it is shown in details the implementation of one of the interface functions IF1 . . . IFn aforesaid listed and shown in FIG. 3. Said function is translated into a sequence of emulation library functions LF1 . . . LFm accessing the ASCII files. Table Description A and Access Description B are defined in the data area of the function IFi; they are implemented as an array of records having an element for each database table column. Table Description A is a build up of the following configuration data: 1=column type, 2=column length, 3=whether the field can be null or not, 4=whether the field is an index to access to the records or not. Access description B includes data about the access type and mode depending on the origin SQL statement type. It is a build up of the following data, filled in by the emulator Interface Function IFi depending on which columns the SQL statement uses: 1=use flag to indicate if the column is used (T=true, F=false) 2=string size, and the following fields where to read/write the result of the operation (written by the .sub.-- fetch.sub.-- row or read by the .sub.-- write .sub.-- row): 3=a flag indicating whether the field can be null or not (T=true, F=false), 4=a flag indicating whether the field contains a numeric value, 5=a flag indicating whether the field contains an alphanumeric value (char=character/ptr=pointer). The first operation performed in RAM memory is the .sub.-- get .sub.-- table.sub.-- description function activation to retrieve from the database files the user table definition and copy it in the Table Description A. Subsequently all the emulator library functions will use the Table Description A to read/write the Access Description B. An example of a system to manage a telephone network, implemented using a LAN network comprising communication servers of reduced hardware configuration which can carry out the invention, is shown in FIG. 5. The system includes two Application Servers AS1 and AS2, one active and the other stand-by, performing management operations for a network; these equipment have a full hardware and software configuration including duplicated disks HD. An Operator can interface the management system by using a so-called X.sub.-- Terminal connected to a X.sub.-- Terminal Server providing a graphical operator interface. A plurality of possible Communication Servers CS1 . . . CSn of reduced hw configuration are installed and can carry out the invention. The number of communication servers CS1 . . . CSn with different hardware configuration can increase in future upgrades of the network. On the communication server CS should be installed applications developed on different hardware configuration equipment having a complete software platform including a commercial database. As the reduced communication server CS software platform should include also communication software and since commercial SQL relational-databases are highly hardware resources consuming, the emulation approach enables to spare memory and CPU time. An example of a telephone network management system architecture comprising network management systems according to FIG. 5, including equipment which can carry out the invention. The emulator approach can be useful in view of future extension of the network by inserting an increasing number of equipment of different hardware configuration on which applications needing an SQL relational-database should be executed. As the complexity of a network topology increases, the network management systems are supposed to be upgraded in terms of number of equipment installed in applications running on said equipment. The architecture of the network management system shown in FIG. 5 can be split up in a plurality of cooperating sub-systems interconnected through a network. Network management systems SYSTEM1 SYSTEM2 and SYSTEM3 including equipment having different configuration are interconnected to a network to be managed in order to cooperate exchanging management information. The emulation approach enables the porting of applications developed on full hardware and software platforms toward any network equipment. It has been mentioned above that every interface function IF1 . . . IFn aforesaid listed and shown in FIG. 3, is translated into a sequence of emulation library functions LF1 . . . LFm accessing the ASCII files. By way of further explanation, an SQL statement in the user application is converted into a IF function each IF function is associated to a sequence of functions of the emulation library, where the sequence depends from the SQL statement the output of the SQL command is returned to the user application, as described above. In the following will be examined in more detail: 1) IF functions 2) emulation library 3) ASCII files An example of set of IF functions can be the following: insert; delete; update; select1; . . . ; and selectn. A SELECT statement, according to SQL syntax, can have a different WHERE clause. Here are some examples of different complexity. The character "*" means "ALL".
______________________________________
SELECT f1, f2 FROM tab1;
SELECT*FROM tab1;
SELECT f1, f5 FROM tab1 WHERE (f1=0 AND f2=`string`);
SELECT f1, f5 FROM tab1
WHERE (F1=0 AND f2 NOT IN
(SELECT f3, f4 FROM tab2
WHERE (f1=10 AND f2=`String1`)));
((SELECT f1, f5 FROM tab1
WHERE (F1=0 AND f2 NOT IN
(SELECT f3, f4 FROM tab2 WHERE (f1=10 AND
f2=`string1`)))
UNION
(SELECT f1, f5 FROM tab1
WHERE (F1=0 AND f2 NOT IN
(SELECT f3, f4 FROM tab2 WHERE (f1=10 AND
f2=`string1`)));
)
);
______________________________________
The user application An interfaces the database using SQL statement and passing parameters (pointers to data structure containing data sent to the database and pointers to data structure in which the output of the SQL commands will be returned). There will be described one of the aforesaid IF function, the one correspondent to the SELECT SQL statement, as far as its implementation is concerned. TAB1 is an example of database table having 6 columns defined C1 . . . C6. Two data lines have been inserted in TAB1; only the data relevant for the example are written, the other field can have any value. TAB1:
______________________________________
C1 C2 C3 C4 C5 C6
______________________________________
5 70 0 string
10 100 200 string
______________________________________
The following SQL statement can come from the user application An: SELECT c2, c4, c5 FROM tab1 WHERE (c2=10 AND c6=`string`); There will be described how the emulator works to get results. In this SELECT statement with this WHERE clause, the Access Description Table B defined in FIG. 4, is duplicated in Access Description Select B1 (not shown in figure), Access Description Where B2 (not shown in figure). In this case two different accesses to user data are made by using two Access Description tables. As explained before, every row of the Table Description A and Access Description B or B1 and B2 corresponds to a column of the defined database table at the creation phase. The Access Description Select B1 defines which fields among C1 . . . C6 are to be retrieved for each data row selected from the ones present in TAB1 and should be sent to the application An, by tagging with T the fields of interest, in this case c1, c4, c5:
______________________________________
1 2 3 4 5
______________________________________
use
C1 F
C2 T 10
C3 F
C4 T 100
C5 T 200
C6 F
______________________________________
The Access Description Where B2 defines the clause to identify which rows present in TAB1 should be selected, by tagging with T the fields cited in the WHERE (c2=10 AND c6=`string`) clause:
______________________________________
1 2 3 4 5
______________________________________
use
C1 F
C2 T 10
C3 F
C4 F
C5 F
C6 T 5 string
______________________________________
Another solution in a different SELECT statement, for example SELECT f1,f2 FROM tab1; could be performed by using a single access and a single Access Description B. In FIG. 4-B is shown a special case of FIG. 4. This is the case of the implementation of the following SQL statement.
______________________________________
((SELECT f1,f5 FROM tab1
WHERE (F1=0 AND f2 NOT IN
(SELECT f3, f4 FROM tab 2 WHERE (f1=10 AND
f2=`string1`)))
UNION
(SELECT f1,f5 FROM tab1
WHERE (F1=0 AND f2 NOT IN
(SELECT f3,f4 FROM tab2 WHERE (f1=10 and f2=
`string`)));
)
);
______________________________________
which could be performed by using: a multiple Table Description A1 and A2 a multiple Access Description B1 and B2. In the following paragraph it will be explained how different steps are executed by the IFn SELECT function, by calling a definite sequence of emulator library functions. When the user application An asks the IFn for retrieving data from the database, it sends to the emulator a pointer to a data structure containing parameters of the SQL SELECT statement and at the end of the operation will be given back a pointer to the retrieved data result of the query. A way for the IFn to perform the aforesaid task is the following: 1) the Table Description A, in the data area of FIG. 4, is initialized according to the table description read from the ASCII file containing the configuration data, by calling the emulator library function .sub.-- get.sub.-- table.sub.-- descr() LF in particular the array of structure of Table Description A is filled in, one row for each table column; 2) the ASCII file containing user data related to the previously accessed table configuration is opened the function verify whether the file has not been opened before. If the file is opened for the first time: opens the file moves to the first row by calling the function .sub.-- search.sub.-- next.sub.-- row(). If not, a pointer to the file moves to the row by calling .sub.-- search.sub.-- next.sub.-- row() and return a pointer to the row, cycling till: the end of the file, or the specified number of rows has been read; 3) for each row, it reads the row at current position by calling the function .sub.-- fetch.sub.-- row.sub.-- at.sub.-- curr.sub.-- pos() and verify if the WHERE clause written in B2 is satisfied for that row, in this case the required fields of that user data row are copied in B1 (SELECT Access Description), filling in the last three columns (null, long/int, char/ptr) according to the data type; 4) at the end close the user data table file. As result of this function, the output of the SELECT clause will be available in the Access Description table (last three columns of B1) and will be returned to the application An. An example of EMULATION LIBRARY, as listed above, can be the following. A subset of the functions can be combined to implement an SQL statement. In the following, a more detailed description of each function is given. F1 NAME: .sub.-- get.sub.-- table.sub.-- descr DESCRIPTION: It gets the table description for a specified table (input parameter .sub.-- table.sub.-- name), filling in the "row description" structure (output parameter .sub.-- row.sub.-- desc). The proper table file is opened and closed after the completion of the table description reading. It logs a message when an error occurs. F2 NAME: .sub.-- open.sub.-- table DESCRIPTION: It opens a table file for a specified table (input parameter .sub.-- table.sub.-- name). The file can be opened for read, update or append depending on the specified "action type" (SELECT, DELETE and INSERT as specified by the input parameter .sub.-- action.sub.-- type). It gives back to the calling function the pointer to the opened file (output parameter .sub.-- file.sub.-- ptr). It logs a message when an error occurs. F3 NAME: .sub.-- close.sub.-- table DESCRIPTION: It closes a table file for a specified table name (input parameter .sub.-- table.sub.-- name). The file pointer is given by the calling function (input parameter .sub.-- file.sub.-- ptr). It logs a message when an error occurs. F4 NAME: .sub.-- search.sub.-- first.sub.-- row DESCRIPTION: It searches for the first row in a table. That means: the Table Description lines are skipped, as comment lines, till the second Header line (closing the Table Description) is found. It gets from the calling function the file pointer (input parameter.sub.-- file.sub.-- ptr) and the table name (input parameter .sub.-- table.sub.-- name) that is inserted in the error messages. If the row is correctly found it gives back to the calling function the position of the row in the table file (output parameter .sub.-- file.sub.-- pos): it is the position of the line type char. It assumes the initial value of the file pointer is pointing to the first byte of a file line, otherwise the search fails. Last char got from the file: first char of the row (when it has been correctly found end-of-file found at the beginning of a line (no rows in the table) an unexpected line first char an unexpected end-of-file. It logs a message when an error occurs. F5 NAME: .sub.-- search.sub.-- next.sub.-- row DESCRIPTION: It searches for the next row in a table. That means: Table Description lines, if found, are treated as "unexpected lines". It gets from the calling function the file pointer (input parameter .sub.-- file.sub.-- ptr) and the table name (input parameter .sub.-- table.sub.-- name) that is inserted in error messages. If the row is correctly found, it gives back to the calling function the position of the row in the table file (output parameter .sub.-- file.sub.-- pos): it is the position of the line type char. It assumes the initial value of the file pointer is pointing to the first byte of a file line, otherwise the search fails. Last char got from the file: first char of the row (when it has been correctly found) end-of-file found at the beginning of a line (no more rows in the table) an unexpected line first char an unexpected end-of-file. It logs a message when an error occurs. F6 NAME: .sub.-- fetch.sub.-- row.sub.-- at.sub.-- curr.sub.-- pos DESCRIPTION: It fetches a table row starting from the current position in the table file (position given by the calling function in the file pointer .sub.-- file.sub.-- ptr). To scan the row it uses the row description given by the calling function in the input parameter .sub.-- row.sub.-- desc. It fills in the "access structure" in the memory area of the calling function (parameter .sub.-- row.sub.-- access). For more details, See the internal function .sub.-- fetch.sub.-- row. It logs a message when an error occurs. F7 NAME: .sub.-- fetch.sub.-- row.sub.-- at.sub.-- abs.sub.-- pos DESCRIPTION: It fetches a table row starting from the position explicitly given by the calling function with the input parameter .sub.-- file.sub.-- pos (in addition to the file pointer .sub.-- file.sub.-- ptr). To scan the row it uses the row description given by the calling function in the input parameter .sub.-- row.sub.-- desc. It fills in the "access structure" in the memory area of the calling function (parameter .sub.-- row.sub.-- access). For more details, See the internal function .sub.-- fetch.sub.-- row. It logs a message when an error occurs. F8 NAME: .sub.-- write.sub.-- row DESCRIPTION: It logs a message when an error occurs. Input A and B. It inserts a row in a table (the row is appended at the bottom of the file table). It uses the row description given by the calling function as input parameter. It takes the data to be written from the Access Description structure B given by the calling function as input parameter. It opens and close the table file. It checks whether a row with the UNIQUE INDEX already exists in the table. F9 NAME: .sub.-- delete.sub.-- row DESCRIPTION: It logically deletes a row in a table. The calling function must give the position of the row in the table. It updates the counter of deleted lines. F10 NAME: .sub.-- refresh.sub.-- table.sub.-- file DESCRIPTION: It checks, for a specified table, whether the deleted lines counter has reached the threshold or not. If yes, it rewrites the table files without all lines that have been previously logically deleted. The counter is reset to 0 when the threshold is overcome and maintains the same value when the value is less than the threshold. F11 NAME: .sub.-- fetch.sub.-- row DESCRIPTION: It fetches a table row starting from the current position in the table file (position given by the calling function in the file pointer .sub.-- file.sub.-- ptr). To scan the row it uses the row description given by the calling function in the input parameter .sub.-- row.sub.-- desc. It fills in the "access structure" in the memory area of the calling function (parameter .sub.-- row.sub.-- access). It gets from the calling function the table name (parameter .sub.-- table.sub.-- name) and the row number (parameter .sub.-- row.sub.-- nbr) that are inserted in the error messages. If no error occurs, the scanning terminates at the end-of-line after the last column. Otherwise, the scanning is aborted when the first error is detected. It assumes the initial value of the file pointer is pointing to char immediately after the special char initiating the row. Last char got from the file: end-of-line terminating the last (or the unique) line composing the row (fetching successfully terminated), column terminator of the last column fetched or bad char initiating a line or unexpected end-of-line or unexpected end-of-file (fetching aborted). It logs a message when an error occurs. The described method of emulating an SQL relational-database in order to simplify the porting of an existing application toward a destination equipment is felt to have considerable advantages in terms of memory and CPU time saving.
|
Same subclass Same class Consider this |
||||||||||
