Abstract:
A method of copying files to a database includes the step of constructing a table of file attributes characterizing each file of a set of files stored on a computer. A specific file from the set of files is then identified. A file selected field corresponding to the specific file is then marked within the table. The specific file is then transferred to a database where it is recorded without acknowledgment. A file transfer status field for the specific file is then updated.

Description:
This application claims priority to the provisional application entitled &#34;Apparatus and Method for Annotated Bulk Copying of Files to a Database&#34;, Ser. No. 60/031,790, filed Nov. 27, 1996. 
    
    
     BRIEF DESCRIPTION OF THE INVENTION 
     This invention relates generally to transferring data into databases. More particularly, this invention relates to a technique of recoverable bulk copying of files to a database. 
     BACKGROUND OF THE INVENTION 
     FIG. 1 illustrates a computer (also called a file server) 20. The present invention is applicable to any computer which transfers data to a database, however, the invention will be described in reference to a computer which receives data from electronic test equipment 22. The data from the electronic test equipment is stored as a set of test data files 24. The test data files describe diagnostic information relating to the testing of a semiconductor wafer. Typical information in a test data file includes the electronic test equipment name, the wafer name, the die name, the date, the time, and a set of test parameters for the die. 
     FIG. 1 also illustrates an operating system 26 and application program 28 operating on the computer 20. FIG. 1 also illustrates a database program 30, which may be operated on the computer 20 or a separate computer. In the prior art, there are at least two ways to transfer test data files 24 or data from the operating system 26 or application program 28 to a database program 30. One technique is a standard insertion operation. For example, the &#34;Open Client-DB Library/C&#34; product sold by SYBASE, Incorporated, Emeryville, Calif., supports an &#34;insert&#34; command. The insert command results in data being inserted into the database 30 in multiple locations. For example, the data is stored to a data device, to a data device mirror, to a log device, and to a log device mirror. After each item is inserted, an acknowledgment is sent to the system from which the data arrived. This approach provides recoverable and consistent data in the case of a system failure, such as a power failure, a database crash, or disk failure. The problem with this approach is that it is relatively slow. The speed problem is largely attributable to the acknowledgment operation that is executed after each item is inserted into the database. In many cases the insertion and acknowledgment operations at the different database locations are performed sequentially, further slowing the process. The speed problem is especially acute in the case of test data files from electronic test equipment 22 because such files have large amounts of data. 
     Another approach to transferring data to a database is known as bulk copying. For example, the &#34;Open Client-DB Library/C&#34; product sold by SYBASE, Incorporated, Emeryville, Calif., supports a bulk copy &#34;bcp&#34; command. The main advantage of the bulk copy command over the insert command is speed. The high speed is achieved because acknowledgment signals are not sent for each item that is entered into the database. In addition, the transferred information is not redundantly written to a data log during the transfer. In view of these circumstances, it is problematic if the system fails before the bulk transfer is complete. In particular, since there is no acknowledgment operation, it is impossible to determine which information was transferred before the system failure. Thus, it is unknown which information is already in the database and which information still has to be transferred to the database. Because high-speed bulk transfers affect the recoverability of the database, database vendors discourage the use of bulk transfers in real time production systems, such as test data files 24 from electronic test equipment 22. 
     In view of the foregoing, it would be highly desirable to provide a technique for obtaining the speed benefits of bulk transfers to a database, while preserving file transfer status information in the case of a system failure. 
     SUMMARY OF THE INVENTION 
     A method of copying files to a database includes the step of constructing a table of file attributes characterizing each file of a set of files stored on a computer. A specific file from the set of files is then identified. A file selected field corresponding to the specific file is then marked within the table. The specific file is then transferred to a database where it is recorded without sending an acknowledgment. A file transfer status field for the specific file is then updated. The method of the invention provides for fast bulk copying of files to a database. The described table provides annotation for the bulk copying operation. Thus, in the case of a database system failure, the exact file transfer status of the bulk copying operation can be determined. While prior art systems allow multiple records to be inserted and extracted from a database, those transactions cannot be performed in an annotated bulk copying operation, as provided with the present invention. 
    
    
     BRIEF DESCRIPTION OF THE DRAWINGS 
     For a better understanding of the nature and objects of the invention, reference should be made to the following detailed description taken in conjunction with the accompanying drawings, in which: 
     FIG. 1 illustrates a computer system including a database program for bulk copying of files. 
     FIG. 2 illustrates a computer system including a file server with a bulk copy tracking routine to supervise the bulk copying of files to a database. 
     FIG. 3 illustrates processing steps associated with a bulk copy tracking routine in accordance with an embodiment of the invention. 
     Like reference numerals refer to corresponding parts throughout the several views of the drawings. 
    
    
     DETAILED DESCRIPTION OF THE INVENTION 
     FIG. 2 illustrates a computer 21 operated in accordance with an embodiment of the invention. The computer 21 executes annotated bulk file transfers to a database. The transferred files may be from any source, but the invention is described in reference to files generated in a production environment. In particular, electronic test equipment 22 is used to generate test data files 24. As in the case of the system of FIG. 1, each test data file may include the electronic test equipment name, the wafer name, the die name, the date, the time, and a set of test parameters for the die. 
     FIG. 2 also illustrates an operating system 26 and application program 28 operating on the computer 21. In addition, the figure illustrates a database program 30, which may be on the computer 21 or a separate computer. The elements described up to this point are consistent with the prior art elements described in reference to FIG. 1. The computer 21 of the present invention is modified to include a bulk copy tracking routine 32, which generates a file table 34. 
     In short, the bulk copy tracking routine 32 allows for annotated bulk copying operations to be performed. The annotation operation provides recoverability information in the case of a system failure, while the bulk copying operation provides for rapid file transfer sequences. 
     Processing steps associated with the bulk copy tracking routine 32 are illustrated in FIG. 3. The first processing step illustrated in FIG. 3 is to construct a file attribute table (step 42). The file attribute table describes each file and a set of predetermined attributes associated with each file. Table I below is an example of a file attribute table which may be used in accordance with the invention. 
     
                       TABLE 1______________________________________File Name  File Selected            Transfer Status                       Attribute.sub.-- 1                                Attribute.sub.-- N______________________________________123    1         1          XYX      ABC456            1            0                                                   DEF789            0            0                                                   GHI..______________________________________ 
    
     The example attribute table includes a field for the file name, a field to indicate whether the file has been selected, a transfer status field, and a set of attribute fields (Attribute --  1 to Attribute --  N). Attribute fields may include such attributes as the date and time the file was created. 
     The next step shown in FIG. 3 is to process a new file (step 44). That is, a single file from the set of received files is selected for processing. The table is then marked to indicate that the specific file is being processed (step 46). Referring to the example of Table I, the first column of the first row specifies a file &#34;123&#34;. The next column of the first row is a &#34;file selected&#34; field. By way of example, a digital one &#34;1&#34; is used to indicate that the file has been selected and a digital zero &#34;0&#34; is used to indicate that the file has not been selected. 
     The next processing step shown in FIG. 3 is to copy the file to the database (step 48). As discussed below, this operation entails loading data from the test data files 24 in an array, and then bulk copying the array to the database 30. 
     The next processing step shown in FIG. 3 is a determination whether the copy was successful (step 50). This decision is made with error messages associated with the copy operation, as discussed below. In the case of an unsuccessful copy operation, the table is marked accordingly (step 52). In the example table shown above, file 456 has been selected (as indicated by a digital one &#34;1&#34; in the file selected field), but the transfer has not been successful (as indicated by the digital zero &#34;0&#34; in the transfer status field). Since the transfer is not acceptable, the bulk copying operation is terminated (step 54). At this point, the table can be used to determine what has been copied to the database and what has not been copied to the database. Again relying upon the example of Table I above, file &#34;123&#34; has been successfully transferred, file &#34;456&#34; has been selected, but not transferred, and file &#34;789&#34; has not been selected or transferred. File transfer status codes indicative of a variety of file transfer results may be used, as discussed below. 
     If the copy operation is successful, then the bulk copy tracking routine 32 marks the table accordingly (step 56). As indicated above, Table I shows that file &#34;123&#34; has been successfully copied. Thereafter, a new file is selected for processing (step 44) and processing continues. 
     Observe that with the present invention, a file is treated as a unit. If one byte of the file is not successfully transferred, the entire file is considered as not being transferred to the database. While the prior art allows a grouping of records (arguably a &#34;file&#34;) to be inserted or extracted from a database, this operation is performed by treating each entry of the grouping as an individual element. That is, for a standard copying operation, if the final element of a group of records is not successfully transferred, the remaining elements associated with the group will still have been transferred into the database and an acknowledgment will have been sent for the entered elements. However, in the case of a bulk copy operation, the database will not generate an acknowledgment as individual elements of the file are loaded into the database. In the case of a bulk copying failure, there is no way to determine what portion of the file is in the database. That is, the prior art bulk copy operation is not annotated, thus, in the case of a system failure there is no reliable method for determining what information has been transferred to the database. With the present invention, when a file transfer fails, all records associated with the unsuccessfully transferred file may be deleted from the database. 
     Although the invention has been fully described, attention presently turns to a more detailed description of the operation of an embodiment of the invention so that the invention can be more fully appreciated. The following computer code in the C++ language is an example of a bulk copy tracking routine 32 in accordance with an embodiment of the invention. More particularly, the following computer code is directed toward step 48 of the bulk copy tracking routine 32. Step 48 relates to the operations of preparing for bulk copying and bulk copying to the database. While the following code explicitly describes an embodiment of step 48, it also serves to illustrate the other processing steps associated with the bulk copy tracking routine 32. 
     Table I above is an example of a file table 34 that may be used in accordance with the invention. After the table is constructed (step 42), and a new file is selected for processing (step 44), and the table is marked to indicate that processing has commenced (step 46), the bulk copying operation (step 48) is performed. The following code shows that the bulk copying operation can be implemented by loading data from a test data file 24 into a data array and then using the bulk copy &#34;bcp&#34; command to load the data array into the database program 30. 
     The initial block of code establishes a class &#34;ExampleTableData&#34;. A new class is created for each set of data that is written to the database program 30. The ExampleTableData class has data members and functions. The data members include a number of integer variables (e.g., iField1, iField2) and character variables (e.g., acField3, dField4). The data members are used to define the columns in the database 30 that will be populated. The code also defines a number of functions, including &#34;ExampleTableData();&#34; and &#34;Read (long iFileDescriptor)&#34;. 
     
         ______________________________________   class ExampleTableData   {   public:   int                                   iField1;   int                                   iField2;   char[128]                               acField3;   double                             dField4;   char[64]                                acField5;   ExampleTableData( );   ˜ExampleTableData( );   int Read (long iFileDescriptor);   ...   }______________________________________ 
    
     The following code refers to DBPROCESS, which is a class forming a portion of the &#34;Open Client-DB Library/C&#34; product sold by SYBASE, Incorporated, Emeryville, Calif. DBPROCESS is declared and initialized externally. The term &#34;dproc&#34; is a variable name. The term &#34;*pExampleTableRow&#34; is a pointer into the ExampleTableData described above. The &#34;GetNumberofRows()&#34; method returns an integer value specifying the number of rows in a table. The code also shows the &#34;iRowsRead&#34; variable being set to zero. The code also refers to an unsigned character &#34;cTag&#34;, which is a character string describing the contents of a portion of the test data file 24. The remaining declared variables in this program segment are used to implement the bulk copy &#34;bcp&#34; command. These variables are used because an array from the test data file 24 cannot be bound to a table of the database program 30. Instead, selected variables of an array must be bound to corresponding fields of a table in the database program. 
     
         ______________________________________extern DBPROCESS dbproc;int StuffTable ( )ExampleTableData *pExampleTableRow;int               iNumberOfRows = GetNumberOfRows ( );int               iRowsRead = 0;unsigned char             cTag;int                  iField1;int                   iField2;char[128]       acField3;double             dField4;char[64]     acField5;______________________________________ 
    
     The following &#34;if&#34; statement is used to allocate memory. If memory is not available, then NULL is true and an error message is written to the table using the &#34;ExitAndMarkstatusTable()&#34; method. The &#34;ExitAndMarkstatusTable()&#34; method can be viewed as a method to implement step 52 of FIG. 3. In this case, steps 42-48 of FIG. 3 are performed, but the file transfer is unsuccessful, so the table, e.g., Table I above is marked (step 52) and processing stops (step 54). File &#34;456&#34; of Table I is an example of this processing. 
     The &#34;while&#34; loop in the following code reads the &#34;cTag&#34; and the number of bytes (&#34;sizeof&#34;) associated with the &#34;cTag&#34;. Depending upon the identity of the &#34;cTag&#34; character string, a selected set of code is executed. By way of example, the following code shows &#34;EXAMPLE --  TABLE --  DATA&#34; as the &#34;cTag&#34; and a set of operations associated with this variable. The operations include reading an &#34;iFileDescriptor&#34; and incrementing the &#34;iRowsRead&#34; variable. The reading of the &#34;iFileDescriptor&#34; operates to load data into the ExampleTableRow so that this data can be subsequently transferred by the bulk copying operation. All rows are read in this manner until the end of file (&#34;EOF&#34;) character is read, in which case the loop is exited. At this point, all rows of the test data file 24 have been read. The number of rows is associated with the variable &#34;iRowsRead&#34;. 
     
         ______________________________________if( ( pExampleTableRow = new ExampleTableData [ iNumberOfRows ])== NULL )ExitAndMarkstatusTable ( );}while ( 1 ){read ( iFileDescriptor, &amp;cTag, sizeof( unsigned char ) );switch ( cTag ){...case EXAMPLE.sub.-- TABLE.sub.-- DATA:{pExampleTableRow [ iRowsRead ] . Read ( iFileDescriptor );iRowsRead ++;}...case EOF:break;}}______________________________________ 
    
     As indicated above, at this processing point it is known how many rows will have to be written to &#34;ExampleTable&#34;. The &#34;dbfreebuf(dbproc)&#34; statement is used to initialize the bulk copy &#34;bcp&#34; command. The first &#34;if&#34; command performs an initialization operation. If the operation fails, an error message field of the file table 34 (Table I above) is marked to indicate &#34;Can not do bcp --  int&#34;. The second &#34;if&#34; clause is used to bind all local variables to corresponding column names in the database 30 that will be written to. This is done by writing the variable &#34;iField1&#34; to &#34;dbproc&#34;, which allows the bulk copy &#34;bcp&#34; command to write the information to the database program 30. If this operation cannot be performed, an error message field of the file table 34 is marked to indicate &#34;Can not bind TABLE --  NAME (Field1)&#34;. 
     
         ______________________________________...// Initialize BCPdbfreebuf( dbproc );if( bcp.sub.-- init ( dbproc,&#34;DB.sub.-- NAME..TABLE.sub.-- NAME&#34;, NULL, NULL, DB.sub.-- TN )== FAIL )ExitAndMarkstatusTable ( &#34;Can not do bcp.sub.-- init[ );if( bcp.sub.-- bind( dbproc,( unsigned char * )&amp;iField1,0,-1,NULL,0,SYBINT2,1) ==FAIL )ExitAndMarkstatusTable ( &#34;Can not bind TABLE.sub.-- NAME ( Field1 )&#34;______________________________________); 
    
     The following code is used to send data to the database program 30. The &#34;for&#34; loop circulates until the &#34;iRowsRead&#34; integer value is reached. The first statement in the &#34;for&#34; loop is to assign previously bound variables to fields in a row of a database table. The first &#34;if&#34; clause in the &#34;for&#34; loop is used to send an array row to the database program 30 using the bulk copy &#34;bcp&#34; command. If the operation fails, an error message field of the file table 34 is marked &#34;Can not send row to TABLE1&#34;. The subsequent program statement actually writes the data to the database program 30 and returns an integer number &#34;i&#34; indicating the number of rows successfully written. If the correct number of rows was written, as checked with the &#34;if (i!=iRowsRead)&#34; statement, then processing continues. Otherwise, the file table 34 is marked to indicate &#34;BCP to TABLE1 failed&#34;. Processing continues until all rows have been processed. If all rows are successfully processed, then the &#34;return SUCCESS&#34; command is executed. This operation calls a method to mark the file table 34 to indicate that the transfer was successful. This operation can be viewed as step 56 of FIG. 3. At this point, a new file in the table 34 is selected (step 44) and processing continues in the manner previously described. 
     
         ______________________________________for ( int = 0; i &lt; iRowsRead, i++ )iField1 = pExampleTableRow[i].iField1if( bcp#sendrow( dbproc ) --=FAIL){ExitAndMarkstatusTable ( &#34;Can not send row to TABLE1&#34;);}}i = (int) bcp done ( dbproc );if( i!=iRowsRead ){ExitAndMarkstatusTable ( &#34;BCP to TABLE1 failed&#34; );}return SUCCESS;}______________________________________ 
    
     The file table 34 may be implemented in any number of ways. By way of example, the file table has been implemented with the following fields: TesterName (i.e., tester 22), ProductName (i.e., the product being tested), LotName (i.e., the product lot being tested), BeginProgramTime (i.e., the time the test equipment 22 began to execute the testing run), LDBFileSize (i.e., the size of the test data file), EndProgramTime, BashfulName (i.e., the file name associated with the run), PCT22NETTime (i.e., the time that data was transferred from the test equipment 22 to the file server 21), PEDBTransferTime (i.e., the start time of transfer from file server 21 to database 30), StufferSuccessCode (e.g., file transfer status, such as 0=file not seen, 1=transfer started, 2=transfer successful, 3=transfer failed, 4=corrupted file, etc.), StufferDetailCode (i.e., variables characterizing corrupted files), DetailText (i.e., a detailed error message), AlteraLotStepDoneSeqNum (i.e., a pointer to a row in the table), and LastStuffTime (i.e., the time the last file was stuffed). Many of these fields are loaded by the previously described &#34;ExitAndMarkStatusTable&#34; and &#34;SUCCESS&#34; methods. 
     In sum, the bulk copy tracking routine 32 of the invention operates on top of a standard bulk copying protocol. In particular, it generates a table to record file transfer status information. The table can then be used in the case of a database failure or other event which prevents the completion of a bulk copying operation. In such an event, it is possible to discern what information has been transferred to the database. Prior art bulk copy processes cannot make this determination. The invention exploits the speed advantage of bulk copy operations, while providing recoverable information that is not otherwise available with bulk copy operations. 
     The foregoing description, for purposes of explanation, used specific nomenclature to provide a thorough understanding of the invention. However, it will be apparent to one skilled in the art that the specific details are not required in order to practice the invention. In other instances, well known computing devices are shown in block diagram form in order to avoid unnecessary distraction from the underlying invention. Thus, the foregoing descriptions of specific embodiments of the present invention are presented for purposes of illustration and description. They are not intended to be exhaustive or to limit the invention to the precise forms disclosed, obviously many modifications and variations are possible in view of the above teachings. The embodiments were chosen and described in order to best explain the principles of the invention and its practical applications, to thereby enable others skilled in the art to best utilize the invention and various embodiments with various modifications as are suited to the particular use contemplated. It is intended that the scope of the invention be defined by the following claims and their equivalents.