**************************************************************** * * COMMENT SECTION * * DATE 1993/06/22 EMBEDDED COBOL LANGUAGE * NIST SQL VALIDATION TEST SUITE V6.0 * DISCLAIMER: * This program was written by employees of NIST to test SQL * implementations for conformance to the SQL standards. * NIST assumes no responsibility for any party's use of * this program. * * IST007.PCO * WRITTEN BY: David W. Flater * TRANSLATED AUTOMATICALLY FROM EMBEDDED C BY CHRIS SCHANZLE * * THIS ROUTINE TESTS THE INFORMATION SCHEMA FOR * TRANSITIONAL SQL. * * REFERENCES * ANSI SQL-1992 * 21 Information Schema and Definition Schema * X3H2-93-389 Corrections to FIPS Transitional SQL * ****************************************************************
MOVE"FLATER "TO uid CALL"AUTHID"USING uid MOVE"not logged in, not"TO uidx EXECSQLSELECT USER INTO :uidx FROM HU.ECCO END-EXEC MOVE SQLCODE TO SQL-COD EXECSQL ROLLBACK WORK END-EXEC MOVE SQLCODE TO SQL-COD if (uid NOT = uidx) then DISPLAY"ERROR: User ", uid " expected. User ", uidx "
- " connected" STOPRUN END-IF MOVE 0 TO errcnt
DISPLAY "SQL Test Suite, V6.0, Embedded COBOL, ist007.pco" DISPLAY "59-byte ID" DISPLAY"TEd Version #" *date_time print ACCEPT TO-DAY FROMDATE ACCEPT THE-TIME FROMTIME DISPLAY"Date run YYMMDD: " TO-DAY " at hhmmssff: " THE-TIME
******************** BEGIN TEST0609 ******************* MOVE 1 TO flag
*Transitional SQL. USAGE_PRIVILEGES is required for *TSQL, but domains, character sets, collations, and *translations are not. This test also checks for existence *of columns pertaining to domains, character sets, *collations, and translations in the other TSQL data *structures.
*FIPS PUB 127-2 section 14.2 # 35 says: * In Entry SQL or Intermediate SQL, some of these tables *may have empty or trivial contents, but an implementation *supporting this feature is required to process statements *that properly reference any of these tables.
DISPLAY" TEST0609 " DISPLAY"Orphaned IS data structures, Transitional SQL" DISPLAY" Reference FIPS PUB 127-2;" DISPLAY"Also ANSI X3H2-93-148 Corrections to ANSI
- " SQL-1992," DISPLAY" page 16 -- changes to COLUMNS view," DISPLAY"and X3H2-93-389 Corrections to FIPS Transitional
- " SQL" DISPLAY" - - - - - - - - - - - - - - - - - - -"
EXECSQLSELECTCOUNT (DISTINCT OBJECT_CAT) INTO :ctr1 FROM INFO_SCHEM.USAGE_PRIVILEGES END-EXEC MOVE SQLCODE TO SQL-COD
*Relaxed pass condition in case it's empty.
PERFORM CHCKOK DISPLAY"ctr1 should be 0 or 1; its value is ", ctr1 if (ctr1 NOT = 0 AND ctr1 NOT = 1) then MOVE 0 TO flag END-IF
DISPLAY"SELECT TABLE_CAT INTO :catlog" DISPLAY"FROM INFO_SCHEM.TABLES" DISPLAY"WHERE TABLE_NAME = 'WCOV';"
*Note to translator: catlog is too long to initialize the entir MOVE"xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"TO catlog EXECSQLSELECT TABLE_CAT INTO :catlog FROM INFO_SCHEM.TABLES
WHERE TABLE_NAME = 'WCOV'END-EXEC MOVE SQLCODE TO SQL-COD PERFORM CHCKOK DISPLAY"catlog is '", catlog "'"
DISPLAY"IMPORTANT: If SQLSTATE indicated truncation," DISPLAY"increase the size of the catlog string and re-" DISPLAY"run the test; otherwise you will fail needlessly."
*This is overkill but it checks for NULLs in TABLES.
DISPLAY"SELECT COUNT(*) INTO :ctr1" DISPLAY"FROM INFO_SCHEM.TABLES" DISPLAY"WHERE TABLE_CAT <> :catlog" DISPLAY"OR TABLE_CAT IS NULL;"
COMPUTE ctr1 = -1 EXECSQLSELECTCOUNT(*) INTO :ctr1 FROM INFO_SCHEM.TABLES
WHERE TABLE_CAT <> :catlog OR TABLE_CAT ISNULLEND-EXEC MOVE SQLCODE TO SQL-COD
PERFORM CHCKOK DISPLAY"ctr1 should be 0; its value is ", ctr1 if (ctr1 NOT = 0) then MOVE 0 TO flag END-IF
DISPLAY"SELECT COUNT(*) INTO :ctr1" DISPLAY"FROM INFO_SCHEM.VIEWS" DISPLAY"WHERE TABLE_CAT <> :catlog" DISPLAY"OR TABLE_CAT IS NULL;"
COMPUTE ctr1 = -1 EXECSQLSELECTCOUNT(*) INTO :ctr1 FROM INFO_SCHEM.VIEWS
WHERE TABLE_CAT <> :catlog OR TABLE_CAT ISNULLEND-EXEC MOVE SQLCODE TO SQL-COD
PERFORM CHCKOK DISPLAY"ctr1 should be 0; its value is ", ctr1 if (ctr1 NOT = 0) then MOVE 0 TO flag END-IF
DISPLAY"SELECT COUNT(*) INTO :ctr1" DISPLAY"FROM INFO_SCHEM.COLUMNS" DISPLAY"WHERE TABLE_CAT <> :catlog" DISPLAY"OR TABLE_CAT IS NULL;"
COMPUTE ctr1 = -1 EXECSQLSELECTCOUNT(*) INTO :ctr1 FROM INFO_SCHEM.COLUMNS
WHERE TABLE_CAT <> :catlog OR TABLE_CAT ISNULLEND-EXEC MOVE SQLCODE TO SQL-COD
PERFORM CHCKOK DISPLAY"ctr1 should be 0; its value is ", ctr1 if (ctr1 NOT = 0) then MOVE 0 TO flag END-IF
DISPLAY"SELECT COUNT(*) INTO :ctr1" DISPLAY"FROM INFO_SCHEM.SCHEMATA" DISPLAY"WHERE CAT_NAME <> :catlog" DISPLAY"OR CAT_NAME IS NULL;"
COMPUTE ctr1 = -1 EXECSQLSELECTCOUNT(*) INTO :ctr1 FROM INFO_SCHEM.SCHEMATA
WHERE CAT_NAME <> :catlog OR CAT_NAME ISNULLEND-EXEC MOVE SQLCODE TO SQL-COD
PERFORM CHCKOK DISPLAY"ctr1 should be 0; its value is ", ctr1 if (ctr1 NOT = 0) then MOVE 0 TO flag END-IF
DISPLAY"SELECT COUNT(*) INTO :ctr1" DISPLAY"FROM INFO_SCHEM.TABLE_PRIVILEGES" DISPLAY"WHERE TABLE_CAT <> :catlog" DISPLAY"OR TABLE_CAT IS NULL;"
COMPUTE ctr1 = -1 EXECSQLSELECTCOUNT(*) INTO :ctr1 FROM INFO_SCHEM.TABLE_PRIVILEGES
WHERE TABLE_CAT <> :catlog OR TABLE_CAT ISNULLEND-EXEC MOVE SQLCODE TO SQL-COD
PERFORM CHCKOK DISPLAY"ctr1 should be 0; its value is ", ctr1 if (ctr1 NOT = 0) then MOVE 0 TO flag END-IF
DISPLAY"SELECT COUNT(*) INTO :ctr1" DISPLAY"FROM INFO_SCHEM.COLUMN_PRIVILEGES" DISPLAY"WHERE TABLE_CAT <> :catlog" DISPLAY"OR TABLE_CAT IS NULL;"
COMPUTE ctr1 = -1 EXECSQLSELECTCOUNT(*) INTO :ctr1 FROM INFO_SCHEM.COLUMN_PRIVILEGES
WHERE TABLE_CAT <> :catlog OR TABLE_CAT ISNULLEND-EXEC MOVE SQLCODE TO SQL-COD
PERFORM CHCKOK DISPLAY"ctr1 should be 0; its value is ", ctr1 if (ctr1 NOT = 0) then MOVE 0 TO flag END-IF
DISPLAY"SELECT COUNT(*) INTO :ctr1" DISPLAY"FROM INFO_SCHEM.USAGE_PRIVILEGES" DISPLAY"WHERE OBJECT_CAT <> :catlog" DISPLAY"OR OBJECT_CAT IS NULL;"
COMPUTE ctr1 = -1 EXECSQLSELECTCOUNT(*) INTO :ctr1 FROM INFO_SCHEM.USAGE_PRIVILEGES
WHERE OBJECT_CAT <> :catlog OR OBJECT_CAT ISNULLEND-EXEC MOVE SQLCODE TO SQL-COD
PERFORM CHCKOK DISPLAY"ctr1 should be 0; its value is ", ctr1 if (ctr1 NOT = 0) then MOVE 0 TO flag END-IF
EXECSQLSELECT CHAR_SET_CAT,
CHAR_SET_SCHEM,
CHAR_SET_NAME,
COLLATION_CAT,
COLLATION_SCHEM,
COLLATION_NAME,
DOMAIN_CAT,
DOMAIN_SCHEM,
DOMAIN_NAME,
INTERVAL_TYPE,
INTERVAL_PREC INTO :junk1:indic1,
:junk2:indic2,
:junk3:indic3,
:junk4:indic4,
:junk5:indic5,
:junk6:indic6,
:junk7:indic7,
:junk8:indic8,
:junk9:indic9,
:junk10:indica,
:junk11:indicb FROM INFO_SCHEM.COLUMNS
WHERE TABLE_SCHEM = 'FLATER' AND TABLE_NAME = 'USIG' AND COLUMN_NAME = 'C1'END-EXEC MOVE SQLCODE TO SQL-COD
*Ignore values of parameters DISPLAY"SQLCODE should be >= 0; its value is ", SQL-COD if (SQLCODE < 0) then MOVE 0 TO flag END-IF DISPLAY"SQLSTATE should be 00000 or 01004; its value is ",
SQLSTATE PERFORM NOSUBCLASS THRU EXIT-NOSUBCLASS if (NORMSQ NOT = "00000"AND NORMSQ NOT = "01004") then MOVE 0 TO flag END-IF if (NORMSQ = "00000"AND NORMSQ NOT = SQLSTATE) then DISPLAY"Valid implementation-defined SQLSTATE accepted." END-IF
EXECSQLSELECT DEF_CHAR_SET_CAT,
DEF_CHAR_SET_SCHEM,
DEF_CHAR_SET_NAME INTO :junk1:indic1,
:junk2:indic2,
:junk3:indic3 FROM INFO_SCHEM.SCHEMATA
WHERE SCHEM_NAME = 'FLATER'END-EXEC MOVE SQLCODE TO SQL-COD
*Ignore values of parameters DISPLAY"SQLCODE should be >= 0; its value is ", SQL-COD if (SQLCODE < 0) then MOVE 0 TO flag END-IF DISPLAY"SQLSTATE should be 00000 or 01004; its value is ",
SQLSTATE PERFORM NOSUBCLASS THRU EXIT-NOSUBCLASS if (NORMSQ NOT = "00000"AND NORMSQ NOT = "01004") then MOVE 0 TO flag END-IF if (NORMSQ = "00000"AND NORMSQ NOT = SQLSTATE) then DISPLAY"Valid implementation-defined SQLSTATE accepted." END-IF
*The regular rigamarole for USAGE_PRIVILEGES.
*Verify visibility condition
COMPUTE ctr1 = -1 DISPLAY"SELECT COUNT(*) INTO :ctr1" DISPLAY"FROM INFO_SCHEM.USAGE_PRIVILEGES" DISPLAY"WHERE GRANTEE NOT IN ('PUBLIC', USER)" DISPLAY"AND GRANTOR <> USER;"
EXECSQLSELECTCOUNT(*) INTO :ctr1 FROM INFO_SCHEM.USAGE_PRIVILEGES
WHERE GRANTEE NOTIN ('PUBLIC', USER) AND GRANTOR <> USER END-EXEC MOVE SQLCODE TO SQL-COD
PERFORM CHCKOK DISPLAY"ctr1 should be 0; its value is ", ctr1 if (ctr1 NOT = 0) then MOVE 0 TO flag END-IF
*Verify existence of 'USAGE' AS PRIVILEGE_TYPE
COMPUTE ctr1 = -1 DISPLAY"SELECT COUNT(*) INTO :ctr1" DISPLAY"FROM INFO_SCHEM.USAGE_PRIVILEGES" DISPLAY"WHERE PRIVILEGE_TYPE <> 'USAGE'" DISPLAY"OR PRIVILEGE_TYPE IS NULL;"
EXECSQLSELECTCOUNT(*) INTO :ctr1 FROM INFO_SCHEM.USAGE_PRIVILEGES
WHERE PRIVILEGE_TYPE <> 'USAGE' OR PRIVILEGE_TYPE ISNULLEND-EXEC MOVE SQLCODE TO SQL-COD
PERFORM CHCKOK DISPLAY"ctr1 should be 0; its value is ", ctr1 if (ctr1 NOT = 0) then MOVE 0 TO flag END-IF
DISPLAY"SELECT COUNT(*) INTO :ctr1" DISPLAY"FROM INFO_SCHEM.USAGE_PRIVILEGES" DISPLAY"WHERE IS_GRANTABLE NOT IN" DISPLAY"('YES', 'NO');"
COMPUTE ctr1 = -1 EXECSQLSELECTCOUNT(*) INTO :ctr1 FROM INFO_SCHEM.USAGE_PRIVILEGES
WHERE IS_GRANTABLE NOTIN
('YES', 'NO') END-EXEC MOVE SQLCODE TO SQL-COD
PERFORM CHCKOK DISPLAY"ctr1 should be 0; its value is ", ctr1 if (ctr1 NOT = 0) then MOVE 0 TO flag END-IF
*Verify constraint USAGE_PRIVILEGES_PRIMARY_KEY
DISPLAY"SELECT COUNT(*) INTO :ctr1" DISPLAY"FROM INFO_SCHEM.USAGE_PRIVILEGES" DISPLAY"WHERE GRANTOR IS NULL" DISPLAY"OR GRANTEE IS NULL" DISPLAY"OR OBJECT_SCHEM IS NULL" DISPLAY"OR OBJECT_NAME IS NULL" DISPLAY"OR OBJECT_TYPE IS NULL;"
COMPUTE ctr1 = -1 EXECSQLSELECTCOUNT(*) INTO :ctr1 FROM INFO_SCHEM.USAGE_PRIVILEGES
WHERE GRANTOR ISNULL OR GRANTEE ISNULL OR OBJECT_SCHEM ISNULL OR OBJECT_NAME ISNULL OR OBJECT_TYPE ISNULLEND-EXEC MOVE SQLCODE TO SQL-COD
PERFORM CHCKOK DISPLAY"ctr1 should be 0; its value is ", ctr1 if (ctr1 NOT = 0) then MOVE 0 TO flag END-IF
COMPUTE ctr1 = -1 DISPLAY"SELECT COUNT(*) INTO :ctr1" DISPLAY"FROM INFO_SCHEM.USAGE_PRIVILEGES;"
EXECSQLSELECTCOUNT(*) INTO :ctr1 FROM INFO_SCHEM.USAGE_PRIVILEGES END-EXEC MOVE SQLCODE TO SQL-COD
COMPUTE ctr2 = -1 EXECSQLSELECTCOUNT(*) INTO :ctr2 FROM INFO_SCHEM.USAGE_PRIVILEGES A,
INFO_SCHEM.USAGE_PRIVILEGES B
WHERE A.GRANTOR = B.GRANTOR AND A.GRANTEE = B.GRANTEE AND A.OBJECT_SCHEM = B.OBJECT_SCHEM AND A.OBJECT_NAME = B.OBJECT_NAME AND A.OBJECT_TYPE = B.OBJECT_TYPE END-EXEC MOVE SQLCODE TO SQL-COD
PERFORM CHCKOK DISPLAY"ctr1 should be equal to ctr2." DISPLAY"ctr1 is ", ctr1 "; ctr2 is ", ctr2 "." if (ctr1 NOT = ctr2) then MOVE 0 TO flag END-IF
*It might be reasonable to check the row for SQL_TEXT, but *I'll omit it since it's an orphaned feature. The only *requirement is that, IF there is anything at all in the *table, then it meets all of the above constraints.
EXECSQL ROLLBACK WORK END-EXEC MOVE SQLCODE TO SQL-COD
if ( flag = 1 ) then DISPLAY" *** pass *** " EXECSQLINSERTINTO HU.TESTREPORT
VALUES('0609','pass','PCO') END-EXEC MOVE SQLCODE TO SQL-COD else DISPLAY" ist007.pco *** fail *** " EXECSQLINSERTINTO HU.TESTREPORT
VALUES('0609','fail','PCO') END-EXEC MOVE SQLCODE TO SQL-COD COMPUTE errcnt = errcnt + 1 END-IF
EXECSQL COMMIT WORK END-EXEC MOVE SQLCODE TO SQL-COD ******************** END TEST0609 ********************
**** TESTER MAY CHOOSE TO INSERT CODE FOR errcnt > 0 STOPRUN.
* **** Procedures for PERFORM statements
*Test SQLCODE and SQLSTATE for normal completion.
CHCKOK. DISPLAY"SQLCODE should be 0; its value is ", SQL-COD DISPLAY"SQLSTATE should be 00000; its value is ", SQLSTATE PERFORM NOSUBCLASS THRU EXIT-NOSUBCLASS if (SQLCODE NOT = 0 OR NORMSQ NOT = "00000") then MOVE 0 TO flag END-IF if (NORMSQ = "00000"AND NORMSQ NOT = SQLSTATE) then DISPLAY"Valid implementation-defined SQLSTATE accepted." END-IF
.
NOSUBCLASS.
*This routine replaces valid implementation-defined *subclasses with 000. This replacement equates valid *implementation-defined subclasses with the 000 value *expected by the test case; otherwise the test will fail. *After calling NOSUBCLASS, NORMSQ will be tested * SQLSTATE will be printed.
MOVE SQLSTATE TO NORMSQ
MOVE 3 TO norm1 *subclass begins in position 3 of char array NORMSQ *valid subclass begins with 5-9, I-Z, end of ALPNUM table PERFORMVARYING norm2 FROM 14 BY 1 UNTIL norm2 > 36 if (NORMSQX(norm1) = ALPNUM(norm2)) then MOVE"0"TO NORMSQX(norm1) END-IF END-PERFORM
*Quit if NORMSQ is unchanged. Subclass is not impl.-def. *Changed NORMSQ means implementation-defined subclass, *so proceed to zero it out, if valid (0-9,A-Z) if (NORMSQ = SQLSTATE) then GOTO EXIT-NOSUBCLASS END-IF
MOVE 4 TO norm1 *examining position 4 of char array NORMSQ *valid characters are 0-9, A-Z PERFORMVARYING norm2 FROM 1 BY 1 UNTIL norm2 > 36 if (NORMSQX(norm1) = ALPNUM(norm2)) then MOVE"0"TO NORMSQX(norm1) END-IF END-PERFORM
MOVE 5 TO norm1 *valid characters are 0-9, A-Z *examining position 5 of char array NORMSQ PERFORMVARYING norm2 FROM 1 BY 1 UNTIL norm2 > 36 if (NORMSQX(norm1) = ALPNUM(norm2)) then MOVE"0"TO NORMSQX(norm1) END-IF END-PERFORM
*implementation-defined subclasses are allowed for warnings *(class = 01). These equate to successful completion *SQLSTATE values of 00000. *Reference SQL-92 4.28 SQL-transactions, paragraph 2
if (NORMSQX(1) = "0"AND NORMSQX(2) = "1") then MOVE"0"TO NORMSQX(2) END-IF
.
EXIT-NOSUBCLASS. EXIT.
[ Verzeichnis aufwärts0.8unsichere Verbindung
Übersetzung europäischer Sprachen durch Browser
]