From 0ff7c14cf79900d9c24bc585429b3657b5021cba Mon Sep 17 00:00:00 2001 From: nigelbayliss Date: Tue, 19 Jun 2018 12:34:09 +0100 Subject: [PATCH 01/16] fg --- optimizer/fine_grained/README.md | 22 + optimizer/fine_grained/plan.sql | 7 + optimizer/fine_grained/q.sql | 27 + optimizer/fine_grained/sql.sql | 19 + optimizer/fine_grained/tab.sql | 32 + optimizer/fine_grained/tests.lst | 8381 ++++++++++++++++++++++++++++++ optimizer/fine_grained/tests.sql | 339 ++ 7 files changed, 8827 insertions(+) create mode 100644 optimizer/fine_grained/README.md create mode 100644 optimizer/fine_grained/plan.sql create mode 100644 optimizer/fine_grained/q.sql create mode 100644 optimizer/fine_grained/sql.sql create mode 100644 optimizer/fine_grained/tab.sql create mode 100644 optimizer/fine_grained/tests.lst create mode 100644 optimizer/fine_grained/tests.sql diff --git a/optimizer/fine_grained/README.md b/optimizer/fine_grained/README.md new file mode 100644 index 00000000..4580c4a3 --- /dev/null +++ b/optimizer/fine_grained/README.md @@ -0,0 +1,22 @@ +This directory contains examples of fine-grained cursor invalidation. + +The test.sql is provided to give you ideas on how you can try this feature out for yourself. + +They are in quite a raw state because I originally wrote the examples for my own benefit to explore the boundaries of this feature. In particular, there is a mixture of some DDL that *will* allow SQL statements to use rolling invalidation and some DDL will not. Some of the PROMPT comments may be incorrect now because the test was created before Oracle Database 12c R2 was released. + +### Note + +The example here was run on Oracle Database 12c Release 2. + +The test case drops tables T1 and T2. + +### DISCLAIMER + +* These scripts are provided for educational purposes only. +* They are NOT supported by Oracle World Wide Technical Support. +* The scripts have been tested and they appear to work as intended. +* You should always run scripts on a test instance. + +### WARNING + +* These scripts drop and create tables. For use on test databases diff --git a/optimizer/fine_grained/plan.sql b/optimizer/fine_grained/plan.sql new file mode 100644 index 00000000..eb92d5d0 --- /dev/null +++ b/optimizer/fine_grained/plan.sql @@ -0,0 +1,7 @@ +set linesize 200 +set tab off +set pagesize 1000 +column plan_table_output format a180 + +SELECT * +FROM table(DBMS_XPLAN.DISPLAY_CURSOR(FORMAT=>'TYPICAL')); diff --git a/optimizer/fine_grained/q.sql b/optimizer/fine_grained/q.sql new file mode 100644 index 00000000..586721ac --- /dev/null +++ b/optimizer/fine_grained/q.sql @@ -0,0 +1,27 @@ +alter system flush shared_pool; + +select /* TESTFG */ count(*) from t1 where id = 1; +@plan +select /* TESTFG */ count(*) from t1 where val1 = 1; +@plan +select /* TESTFG */ count(*) from t2 where id = 1; +@plan +select /* TESTFG */ count(*) from t2 where id = 1+150000; +@plan +select /* TESTFG */ count(*) from t2 where val1 = 1; +@plan +select /* TESTFG */ /*+ INDEX_FFS(t new1) */ sum(val2) from t1 t; +@plan +select /* TESTFG */ count(*) from t2 where id < (select max(id) from t1); +@plan +select /* TESTFG */ /*+ USE_INVISIBLE_INDEXES */ count(*) from t1 where val2<50; +@plan +select /* TESTFG */ count(*) from t2 partition (p2); +@plan +select /* TESTFG */ count(*) from t2 partition (p1); +@plan +update /* TESTFG */ t1 set val1 = val1 + 1 where val1 < 50; +update /* TESTFG */ t2 set val1 = val1 + 1 where val1 < 50; +update /* TESTFG */ t1 set val1 = val1 + 1 where id < 50; +update /* TESTFG */ t2 set val1 = val1 + 1 where id < 50; +commit; diff --git a/optimizer/fine_grained/sql.sql b/optimizer/fine_grained/sql.sql new file mode 100644 index 00000000..5152824b --- /dev/null +++ b/optimizer/fine_grained/sql.sql @@ -0,0 +1,19 @@ +column EXACT_MATCHING_SIGNATURE format 99999999999999999999999999999999999 +set linesize 300 +set tab off +column sql_text format a85 +column is_shareable format a20 +column IS_ROLLING_INVALID format a20 +column IS_ROLLING_REFRESH_INVALID format a20 +column DDL_NO_INVALIDATE format a20 + +select sql_id,sql_text,child_number +, is_shareable, OBJECT_STATUS, INVALIDATIONS,IS_ROLLING_INVALID,IS_ROLLING_REFRESH_INVALID ,DDL_NO_INVALIDATE +from v$sql +where sql_text like '%TESTFG%' and sql_text not like '%v$sql%' +order by 2; + +select sql_id,is_shareable, IS_ROLLING_INVALID,IS_ROLLING_REFRESH_INVALID +from v$sql +where sql_text like '%TESTVG%' and sql_text not like '%v$sql%' +order by 2; diff --git a/optimizer/fine_grained/tab.sql b/optimizer/fine_grained/tab.sql new file mode 100644 index 00000000..a975e9d2 --- /dev/null +++ b/optimizer/fine_grained/tab.sql @@ -0,0 +1,32 @@ +drop table t1; +drop table t2; + +create table t1 (id number(10) not null, val1 number(10) not null, val2 number(10) not null); + +create table t2 (id number(10) not null, val1 number(10) not null, val2 number(10) not null) +partition by range (id) ( + partition p1 values less than (100000) +, partition p2 values less than (200000) +) +/ + +insert into t1 select rownum,rownum,rownum from ( +select 1 +from dual connect by rownum < 10000); + +insert into t2 select rownum,rownum,rownum from ( +select 1 +from dual connect by rownum < 10000); + +insert into t2 select rownum+100000,rownum,rownum from ( +select 1 +from dual connect by rownum < 10000); + + +create index t1i on t1 (id); +create index t2i on t2 (id) local ( +partition p1i, +partition p2i); + +exec dbms_stats.gather_table_stats(ownname=>user,tabname=>'t1'); +exec dbms_stats.gather_table_stats(ownname=>user,tabname=>'t2'); diff --git a/optimizer/fine_grained/tests.lst b/optimizer/fine_grained/tests.lst new file mode 100644 index 00000000..6ac4b717 --- /dev/null +++ b/optimizer/fine_grained/tests.lst @@ -0,0 +1,8381 @@ +SQL> @tests + +Table dropped. + + +Table dropped. + + +Table created. + + +Table created. + + +9999 rows created. + + +9999 rows created. + + +9999 rows created. + + +Index created. + + +Index created. + + +PL/SQL procedure successfully completed. + + +PL/SQL procedure successfully completed. + + +System altered. + + + COUNT(*) +---------- + 1 + + +PLAN_TABLE_OUTPUT +------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ +SQL_ID cf016xd0knzrh, child number 0 +------------------------------------- +select /* TESTFG */ count(*) from t1 where id = 1 + +Plan hash value: 1736604837 + +-------------------------------------------------------------------------- +| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time | +-------------------------------------------------------------------------- +| 0 | SELECT STATEMENT | | | | 1 (100)| | +| 1 | SORT AGGREGATE | | 1 | 4 | | | +|* 2 | INDEX RANGE SCAN| T1I | 1 | 4 | 1 (0)| 00:00:01 | +-------------------------------------------------------------------------- + +Predicate Information (identified by operation id): +--------------------------------------------------- + + 2 - access("ID"=1) + + +19 rows selected. + + + COUNT(*) +---------- + 1 + + +PLAN_TABLE_OUTPUT +------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ +SQL_ID gvd4z9ba14uh3, child number 0 +------------------------------------- +select /* TESTFG */ count(*) from t1 where val1 = 1 + +Plan hash value: 3724264953 + +--------------------------------------------------------------------------- +| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time | +--------------------------------------------------------------------------- +| 0 | SELECT STATEMENT | | | | 9 (100)| | +| 1 | SORT AGGREGATE | | 1 | 4 | | | +|* 2 | TABLE ACCESS FULL| T1 | 1 | 4 | 9 (0)| 00:00:01 | +--------------------------------------------------------------------------- + +Predicate Information (identified by operation id): +--------------------------------------------------- + + 2 - filter("VAL1"=1) + + +19 rows selected. + + + COUNT(*) +---------- + 1 + + +PLAN_TABLE_OUTPUT +------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ +SQL_ID 1y9y6gg3r5sry, child number 0 +------------------------------------- +select /* TESTFG */ count(*) from t2 where id = 1 + +Plan hash value: 1317774485 + +------------------------------------------------------------------------------------------------ +| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time | Pstart| Pstop | +------------------------------------------------------------------------------------------------ +| 0 | SELECT STATEMENT | | | | 1 (100)| | | | +| 1 | SORT AGGREGATE | | 1 | 4 | | | | | +| 2 | PARTITION RANGE SINGLE| | 1 | 4 | 1 (0)| 00:00:01 | 1 | 1 | +|* 3 | INDEX RANGE SCAN | T2I | 1 | 4 | 1 (0)| 00:00:01 | 1 | 1 | +------------------------------------------------------------------------------------------------ + +Predicate Information (identified by operation id): +--------------------------------------------------- + + 3 - access("ID"=1) + + +20 rows selected. + + + COUNT(*) +---------- + 0 + + +PLAN_TABLE_OUTPUT +------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ +SQL_ID dcvq5bcm8yqm9, child number 0 +------------------------------------- +select /* TESTFG */ count(*) from t2 where id = 1+150000 + +Plan hash value: 1317774485 + +------------------------------------------------------------------------------------------------ +| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time | Pstart| Pstop | +------------------------------------------------------------------------------------------------ +| 0 | SELECT STATEMENT | | | | 1 (100)| | | | +| 1 | SORT AGGREGATE | | 1 | 5 | | | | | +| 2 | PARTITION RANGE SINGLE| | 1 | 5 | 1 (0)| 00:00:01 | 2 | 2 | +|* 3 | INDEX RANGE SCAN | T2I | 1 | 5 | 1 (0)| 00:00:01 | 2 | 2 | +------------------------------------------------------------------------------------------------ + +Predicate Information (identified by operation id): +--------------------------------------------------- + + 3 - access("ID"=150001) + + +20 rows selected. + + + COUNT(*) +---------- + 2 + + +PLAN_TABLE_OUTPUT +------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ +SQL_ID 9jh4ms6ruztw2, child number 0 +------------------------------------- +select /* TESTFG */ count(*) from t2 where val1 = 1 + +Plan hash value: 611317447 + +--------------------------------------------------------------------------------------------- +| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time | Pstart| Pstop | +--------------------------------------------------------------------------------------------- +| 0 | SELECT STATEMENT | | | | 16 (100)| | | | +| 1 | SORT AGGREGATE | | 1 | 4 | | | | | +| 2 | PARTITION RANGE ALL| | 2 | 8 | 16 (0)| 00:00:01 | 1 | 2 | +|* 3 | TABLE ACCESS FULL | T2 | 2 | 8 | 16 (0)| 00:00:01 | 1 | 2 | +--------------------------------------------------------------------------------------------- + +Predicate Information (identified by operation id): +--------------------------------------------------- + + 3 - filter("VAL1"=1) + + +20 rows selected. + + + SUM(VAL2) +---------- + 49995000 + + +PLAN_TABLE_OUTPUT +------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ +SQL_ID 31pkfzpmx1b62, child number 0 +------------------------------------- +select /* TESTFG */ /*+ INDEX_FFS(t new1) */ sum(val2) from t1 t + +Plan hash value: 3724264953 + +--------------------------------------------------------------------------- +| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time | +--------------------------------------------------------------------------- +| 0 | SELECT STATEMENT | | | | 9 (100)| | +| 1 | SORT AGGREGATE | | 1 | 4 | | | +| 2 | TABLE ACCESS FULL| T1 | 9999 | 39996 | 9 (0)| 00:00:01 | +--------------------------------------------------------------------------- + + +14 rows selected. + + + COUNT(*) +---------- + 9998 + + +PLAN_TABLE_OUTPUT +------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ +SQL_ID czjk2xd0vn20k, child number 0 +------------------------------------- +select /* TESTFG */ count(*) from t2 where id < (select max(id) from t1) + +Plan hash value: 682288026 + +------------------------------------------------------------------------------------------------------ +| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time | Pstart| Pstop | +------------------------------------------------------------------------------------------------------ +| 0 | SELECT STATEMENT | | | | 2 (100)| | | | +| 1 | SORT AGGREGATE | | 1 | 5 | | | | | +| 2 | PARTITION RANGE ITERATOR | | 1000 | 5000 | 2 (0)| 00:00:01 | 1 | KEY | +|* 3 | INDEX RANGE SCAN | T2I | 1000 | 5000 | 2 (0)| 00:00:01 | 1 | KEY | +| 4 | SORT AGGREGATE | | 1 | 4 | | | | | +| 5 | INDEX FULL SCAN (MIN/MAX)| T1I | 1 | 4 | 2 (0)| 00:00:01 | | | +------------------------------------------------------------------------------------------------------ + +Predicate Information (identified by operation id): +--------------------------------------------------- + + 3 - access("ID"<) + + +22 rows selected. + + + COUNT(*) +---------- + 49 + + +PLAN_TABLE_OUTPUT +------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ +SQL_ID ax2r0jyjs0hbb, child number 0 +------------------------------------- +select /* TESTFG */ /*+ USE_INVISIBLE_INDEXES */ count(*) from t1 where +val2<50 + +Plan hash value: 3724264953 + +--------------------------------------------------------------------------- +| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time | +--------------------------------------------------------------------------- +| 0 | SELECT STATEMENT | | | | 9 (100)| | +| 1 | SORT AGGREGATE | | 1 | 4 | | | +|* 2 | TABLE ACCESS FULL| T1 | 49 | 196 | 9 (0)| 00:00:01 | +--------------------------------------------------------------------------- + +Predicate Information (identified by operation id): +--------------------------------------------------- + + 2 - filter("VAL2"<50) + + +20 rows selected. + + + COUNT(*) +---------- + 9999 + + +PLAN_TABLE_OUTPUT +------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ +SQL_ID 7c65qbgku7can, child number 0 +------------------------------------- +select /* TESTFG */ count(*) from t2 partition (p2) + +Plan hash value: 3928439236 + +---------------------------------------------------------------------------------------- +| Id | Operation | Name | Rows | Cost (%CPU)| Time | Pstart| Pstop | +---------------------------------------------------------------------------------------- +| 0 | SELECT STATEMENT | | | 8 (100)| | | | +| 1 | SORT AGGREGATE | | 1 | | | | | +| 2 | PARTITION RANGE SINGLE| | 9999 | 8 (0)| 00:00:01 | 2 | 2 | +| 3 | INDEX FAST FULL SCAN | T2I | 9999 | 8 (0)| 00:00:01 | 2 | 2 | +---------------------------------------------------------------------------------------- + + +15 rows selected. + + + COUNT(*) +---------- + 9999 + + +PLAN_TABLE_OUTPUT +------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ +SQL_ID 221p0y74xg65x, child number 0 +------------------------------------- +select /* TESTFG */ count(*) from t2 partition (p1) + +Plan hash value: 3928439236 + +---------------------------------------------------------------------------------------- +| Id | Operation | Name | Rows | Cost (%CPU)| Time | Pstart| Pstop | +---------------------------------------------------------------------------------------- +| 0 | SELECT STATEMENT | | | 7 (100)| | | | +| 1 | SORT AGGREGATE | | 1 | | | | | +| 2 | PARTITION RANGE SINGLE| | 9999 | 7 (0)| 00:00:01 | 1 | 1 | +| 3 | INDEX FAST FULL SCAN | T2I | 9999 | 7 (0)| 00:00:01 | 1 | 1 | +---------------------------------------------------------------------------------------- + + +15 rows selected. + + +49 rows updated. + + +98 rows updated. + + +49 rows updated. + + +49 rows updated. + + +Commit complete. + + +SQL_ID SQL_TEXT CHILD_NUMBER IS_SHAREABLE OBJECT_STATUS INVALIDATIONS IS_ROLLING_INVALID IS_ROLLING_REFRESH_I DDL_NO_INVALIDATE +------------- ------------------------------------------------------------------------------------- ------------ -------------------- ------------------- ------------- -------------------- -------------------- -------------------- +31pkfzpmx1b62 select /* TESTFG */ /*+ INDEX_FFS(t new1) */ sum(val2) from t1 t 0 Y VALID 0 N N N +ax2r0jyjs0hbb select /* TESTFG */ /*+ USE_INVISIBLE_INDEXES */ count(*) from t1 where val2<50 0 Y VALID 0 N N N +cf016xd0knzrh select /* TESTFG */ count(*) from t1 where id = 1 0 Y VALID 0 N N N +gvd4z9ba14uh3 select /* TESTFG */ count(*) from t1 where val1 = 1 0 Y VALID 0 N N N +221p0y74xg65x select /* TESTFG */ count(*) from t2 partition (p1) 0 Y VALID 0 N N N +7c65qbgku7can select /* TESTFG */ count(*) from t2 partition (p2) 0 Y VALID 0 N N N +czjk2xd0vn20k select /* TESTFG */ count(*) from t2 where id < (select max(id) from t1) 0 Y VALID 0 N N N +1y9y6gg3r5sry select /* TESTFG */ count(*) from t2 where id = 1 0 Y VALID 0 N N N +dcvq5bcm8yqm9 select /* TESTFG */ count(*) from t2 where id = 1+150000 0 Y VALID 0 N N N +9jh4ms6ruztw2 select /* TESTFG */ count(*) from t2 where val1 = 1 0 Y VALID 0 N N N +bcsj7p128xh77 update /* TESTFG */ t1 set val1 = val1 + 1 where id < 50 0 Y VALID 0 N N N +bdhfwydh894qk update /* TESTFG */ t1 set val1 = val1 + 1 where val1 < 50 0 Y VALID 0 N N N +6a6m4fq5b9v7r update /* TESTFG */ t2 set val1 = val1 + 1 where id < 50 0 Y VALID 0 N N N +24qkp15shu1gp update /* TESTFG */ t2 set val1 = val1 + 1 where val1 < 50 0 Y VALID 0 N N N + +14 rows selected. + + +no rows selected + +SQL> -- +SQL> -- CREATE INDEX (visible) +SQL> -- +SQL> create index new1 on t1 (val2) deferred invalidation; + +Index created. + +SQL> create index new2 on t2 (val2) local deferred invalidation; + +Index created. + +SQL> set echo off + +SQL_ID SQL_TEXT CHILD_NUMBER IS_SHAREABLE OBJECT_STATUS INVALIDATIONS IS_ROLLING_INVALID IS_ROLLING_REFRESH_I DDL_NO_INVALIDATE +------------- ------------------------------------------------------------------------------------- ------------ -------------------- ------------------- ------------- -------------------- -------------------- -------------------- +31pkfzpmx1b62 select /* TESTFG */ /*+ INDEX_FFS(t new1) */ sum(val2) from t1 t 0 Y VALID 0 Y N N +ax2r0jyjs0hbb select /* TESTFG */ /*+ USE_INVISIBLE_INDEXES */ count(*) from t1 where val2<50 0 Y VALID 0 Y N N +cf016xd0knzrh select /* TESTFG */ count(*) from t1 where id = 1 0 Y VALID 0 Y N N +gvd4z9ba14uh3 select /* TESTFG */ count(*) from t1 where val1 = 1 0 Y VALID 0 Y N N +221p0y74xg65x select /* TESTFG */ count(*) from t2 partition (p1) 0 Y VALID 0 Y N N +7c65qbgku7can select /* TESTFG */ count(*) from t2 partition (p2) 0 Y VALID 0 Y N N +czjk2xd0vn20k select /* TESTFG */ count(*) from t2 where id < (select max(id) from t1) 0 Y VALID 0 Y N N +1y9y6gg3r5sry select /* TESTFG */ count(*) from t2 where id = 1 0 Y VALID 0 Y N N +dcvq5bcm8yqm9 select /* TESTFG */ count(*) from t2 where id = 1+150000 0 Y VALID 0 Y N N +9jh4ms6ruztw2 select /* TESTFG */ count(*) from t2 where val1 = 1 0 Y VALID 0 Y N N +bcsj7p128xh77 update /* TESTFG */ t1 set val1 = val1 + 1 where id < 50 0 Y INVALID_UNAUTH 1 N N N +bdhfwydh894qk update /* TESTFG */ t1 set val1 = val1 + 1 where val1 < 50 0 Y INVALID_UNAUTH 1 N N N +6a6m4fq5b9v7r update /* TESTFG */ t2 set val1 = val1 + 1 where id < 50 0 Y INVALID_UNAUTH 1 N N N +24qkp15shu1gp update /* TESTFG */ t2 set val1 = val1 + 1 where val1 < 50 0 Y INVALID_UNAUTH 1 N N N + +14 rows selected. + + +no rows selected + +Press + + +Table dropped. + + +Table dropped. + + +Table created. + + +Table created. + + +9999 rows created. + + +9999 rows created. + + +9999 rows created. + + +Index created. + + +Index created. + + +PL/SQL procedure successfully completed. + + +PL/SQL procedure successfully completed. + + +System altered. + + + COUNT(*) +---------- + 1 + + +PLAN_TABLE_OUTPUT +------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ +SQL_ID cf016xd0knzrh, child number 0 +------------------------------------- +select /* TESTFG */ count(*) from t1 where id = 1 + +Plan hash value: 1736604837 + +-------------------------------------------------------------------------- +| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time | +-------------------------------------------------------------------------- +| 0 | SELECT STATEMENT | | | | 1 (100)| | +| 1 | SORT AGGREGATE | | 1 | 4 | | | +|* 2 | INDEX RANGE SCAN| T1I | 1 | 4 | 1 (0)| 00:00:01 | +-------------------------------------------------------------------------- + +Predicate Information (identified by operation id): +--------------------------------------------------- + + 2 - access("ID"=1) + + +19 rows selected. + + + COUNT(*) +---------- + 1 + + +PLAN_TABLE_OUTPUT +------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ +SQL_ID gvd4z9ba14uh3, child number 0 +------------------------------------- +select /* TESTFG */ count(*) from t1 where val1 = 1 + +Plan hash value: 3724264953 + +--------------------------------------------------------------------------- +| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time | +--------------------------------------------------------------------------- +| 0 | SELECT STATEMENT | | | | 9 (100)| | +| 1 | SORT AGGREGATE | | 1 | 4 | | | +|* 2 | TABLE ACCESS FULL| T1 | 1 | 4 | 9 (0)| 00:00:01 | +--------------------------------------------------------------------------- + +Predicate Information (identified by operation id): +--------------------------------------------------- + + 2 - filter("VAL1"=1) + + +19 rows selected. + + + COUNT(*) +---------- + 1 + + +PLAN_TABLE_OUTPUT +------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ +SQL_ID 1y9y6gg3r5sry, child number 0 +------------------------------------- +select /* TESTFG */ count(*) from t2 where id = 1 + +Plan hash value: 1317774485 + +------------------------------------------------------------------------------------------------ +| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time | Pstart| Pstop | +------------------------------------------------------------------------------------------------ +| 0 | SELECT STATEMENT | | | | 1 (100)| | | | +| 1 | SORT AGGREGATE | | 1 | 4 | | | | | +| 2 | PARTITION RANGE SINGLE| | 1 | 4 | 1 (0)| 00:00:01 | 1 | 1 | +|* 3 | INDEX RANGE SCAN | T2I | 1 | 4 | 1 (0)| 00:00:01 | 1 | 1 | +------------------------------------------------------------------------------------------------ + +Predicate Information (identified by operation id): +--------------------------------------------------- + + 3 - access("ID"=1) + + +20 rows selected. + + + COUNT(*) +---------- + 0 + + +PLAN_TABLE_OUTPUT +------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ +SQL_ID dcvq5bcm8yqm9, child number 0 +------------------------------------- +select /* TESTFG */ count(*) from t2 where id = 1+150000 + +Plan hash value: 1317774485 + +------------------------------------------------------------------------------------------------ +| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time | Pstart| Pstop | +------------------------------------------------------------------------------------------------ +| 0 | SELECT STATEMENT | | | | 1 (100)| | | | +| 1 | SORT AGGREGATE | | 1 | 5 | | | | | +| 2 | PARTITION RANGE SINGLE| | 1 | 5 | 1 (0)| 00:00:01 | 2 | 2 | +|* 3 | INDEX RANGE SCAN | T2I | 1 | 5 | 1 (0)| 00:00:01 | 2 | 2 | +------------------------------------------------------------------------------------------------ + +Predicate Information (identified by operation id): +--------------------------------------------------- + + 3 - access("ID"=150001) + + +20 rows selected. + + + COUNT(*) +---------- + 2 + + +PLAN_TABLE_OUTPUT +------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ +SQL_ID 9jh4ms6ruztw2, child number 0 +------------------------------------- +select /* TESTFG */ count(*) from t2 where val1 = 1 + +Plan hash value: 611317447 + +--------------------------------------------------------------------------------------------- +| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time | Pstart| Pstop | +--------------------------------------------------------------------------------------------- +| 0 | SELECT STATEMENT | | | | 16 (100)| | | | +| 1 | SORT AGGREGATE | | 1 | 4 | | | | | +| 2 | PARTITION RANGE ALL| | 2 | 8 | 16 (0)| 00:00:01 | 1 | 2 | +|* 3 | TABLE ACCESS FULL | T2 | 2 | 8 | 16 (0)| 00:00:01 | 1 | 2 | +--------------------------------------------------------------------------------------------- + +Predicate Information (identified by operation id): +--------------------------------------------------- + + 3 - filter("VAL1"=1) + + +20 rows selected. + + + SUM(VAL2) +---------- + 49995000 + + +PLAN_TABLE_OUTPUT +------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ +SQL_ID 31pkfzpmx1b62, child number 0 +------------------------------------- +select /* TESTFG */ /*+ INDEX_FFS(t new1) */ sum(val2) from t1 t + +Plan hash value: 3724264953 + +--------------------------------------------------------------------------- +| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time | +--------------------------------------------------------------------------- +| 0 | SELECT STATEMENT | | | | 9 (100)| | +| 1 | SORT AGGREGATE | | 1 | 4 | | | +| 2 | TABLE ACCESS FULL| T1 | 9999 | 39996 | 9 (0)| 00:00:01 | +--------------------------------------------------------------------------- + + +14 rows selected. + + + COUNT(*) +---------- + 9998 + + +PLAN_TABLE_OUTPUT +------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ +SQL_ID czjk2xd0vn20k, child number 0 +------------------------------------- +select /* TESTFG */ count(*) from t2 where id < (select max(id) from t1) + +Plan hash value: 682288026 + +------------------------------------------------------------------------------------------------------ +| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time | Pstart| Pstop | +------------------------------------------------------------------------------------------------------ +| 0 | SELECT STATEMENT | | | | 2 (100)| | | | +| 1 | SORT AGGREGATE | | 1 | 5 | | | | | +| 2 | PARTITION RANGE ITERATOR | | 1000 | 5000 | 2 (0)| 00:00:01 | 1 | KEY | +|* 3 | INDEX RANGE SCAN | T2I | 1000 | 5000 | 2 (0)| 00:00:01 | 1 | KEY | +| 4 | SORT AGGREGATE | | 1 | 4 | | | | | +| 5 | INDEX FULL SCAN (MIN/MAX)| T1I | 1 | 4 | 2 (0)| 00:00:01 | | | +------------------------------------------------------------------------------------------------------ + +Predicate Information (identified by operation id): +--------------------------------------------------- + + 3 - access("ID"<) + + +22 rows selected. + + + COUNT(*) +---------- + 49 + + +PLAN_TABLE_OUTPUT +------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ +SQL_ID ax2r0jyjs0hbb, child number 0 +------------------------------------- +select /* TESTFG */ /*+ USE_INVISIBLE_INDEXES */ count(*) from t1 where +val2<50 + +Plan hash value: 3724264953 + +--------------------------------------------------------------------------- +| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time | +--------------------------------------------------------------------------- +| 0 | SELECT STATEMENT | | | | 9 (100)| | +| 1 | SORT AGGREGATE | | 1 | 4 | | | +|* 2 | TABLE ACCESS FULL| T1 | 49 | 196 | 9 (0)| 00:00:01 | +--------------------------------------------------------------------------- + +Predicate Information (identified by operation id): +--------------------------------------------------- + + 2 - filter("VAL2"<50) + + +20 rows selected. + + + COUNT(*) +---------- + 9999 + + +PLAN_TABLE_OUTPUT +------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ +SQL_ID 7c65qbgku7can, child number 0 +------------------------------------- +select /* TESTFG */ count(*) from t2 partition (p2) + +Plan hash value: 3928439236 + +---------------------------------------------------------------------------------------- +| Id | Operation | Name | Rows | Cost (%CPU)| Time | Pstart| Pstop | +---------------------------------------------------------------------------------------- +| 0 | SELECT STATEMENT | | | 8 (100)| | | | +| 1 | SORT AGGREGATE | | 1 | | | | | +| 2 | PARTITION RANGE SINGLE| | 9999 | 8 (0)| 00:00:01 | 2 | 2 | +| 3 | INDEX FAST FULL SCAN | T2I | 9999 | 8 (0)| 00:00:01 | 2 | 2 | +---------------------------------------------------------------------------------------- + + +15 rows selected. + + + COUNT(*) +---------- + 9999 + + +PLAN_TABLE_OUTPUT +------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ +SQL_ID 221p0y74xg65x, child number 0 +------------------------------------- +select /* TESTFG */ count(*) from t2 partition (p1) + +Plan hash value: 3928439236 + +---------------------------------------------------------------------------------------- +| Id | Operation | Name | Rows | Cost (%CPU)| Time | Pstart| Pstop | +---------------------------------------------------------------------------------------- +| 0 | SELECT STATEMENT | | | 7 (100)| | | | +| 1 | SORT AGGREGATE | | 1 | | | | | +| 2 | PARTITION RANGE SINGLE| | 9999 | 7 (0)| 00:00:01 | 1 | 1 | +| 3 | INDEX FAST FULL SCAN | T2I | 9999 | 7 (0)| 00:00:01 | 1 | 1 | +---------------------------------------------------------------------------------------- + + +15 rows selected. + + +49 rows updated. + + +98 rows updated. + + +49 rows updated. + + +49 rows updated. + + +Commit complete. + + +SQL_ID SQL_TEXT CHILD_NUMBER IS_SHAREABLE OBJECT_STATUS INVALIDATIONS IS_ROLLING_INVALID IS_ROLLING_REFRESH_I DDL_NO_INVALIDATE +------------- ------------------------------------------------------------------------------------- ------------ -------------------- ------------------- ------------- -------------------- -------------------- -------------------- +31pkfzpmx1b62 select /* TESTFG */ /*+ INDEX_FFS(t new1) */ sum(val2) from t1 t 0 Y VALID 0 N N N +ax2r0jyjs0hbb select /* TESTFG */ /*+ USE_INVISIBLE_INDEXES */ count(*) from t1 where val2<50 0 Y VALID 0 N N N +cf016xd0knzrh select /* TESTFG */ count(*) from t1 where id = 1 0 Y VALID 0 N N N +gvd4z9ba14uh3 select /* TESTFG */ count(*) from t1 where val1 = 1 0 Y VALID 0 N N N +221p0y74xg65x select /* TESTFG */ count(*) from t2 partition (p1) 0 Y VALID 0 N N N +7c65qbgku7can select /* TESTFG */ count(*) from t2 partition (p2) 0 Y VALID 0 N N N +czjk2xd0vn20k select /* TESTFG */ count(*) from t2 where id < (select max(id) from t1) 0 Y VALID 0 N N N +1y9y6gg3r5sry select /* TESTFG */ count(*) from t2 where id = 1 0 Y VALID 0 N N N +dcvq5bcm8yqm9 select /* TESTFG */ count(*) from t2 where id = 1+150000 0 Y VALID 0 N N N +9jh4ms6ruztw2 select /* TESTFG */ count(*) from t2 where val1 = 1 0 Y VALID 0 N N N +bcsj7p128xh77 update /* TESTFG */ t1 set val1 = val1 + 1 where id < 50 0 Y VALID 0 N N N +bdhfwydh894qk update /* TESTFG */ t1 set val1 = val1 + 1 where val1 < 50 0 Y VALID 0 N N N +6a6m4fq5b9v7r update /* TESTFG */ t2 set val1 = val1 + 1 where id < 50 0 Y VALID 0 N N N +24qkp15shu1gp update /* TESTFG */ t2 set val1 = val1 + 1 where val1 < 50 0 Y VALID 0 N N N + +14 rows selected. + + +no rows selected + +SQL> -- +SQL> -- CREATE INDEX (invisible) +SQL> -- +SQL> create index new1 on t1 (val2) invisible deferred invalidation; + +Index created. + +SQL> create index new2 on t2 (val2) invisible local deferred invalidation; + +Index created. + +SQL> set echo off + +SQL_ID SQL_TEXT CHILD_NUMBER IS_SHAREABLE OBJECT_STATUS INVALIDATIONS IS_ROLLING_INVALID IS_ROLLING_REFRESH_I DDL_NO_INVALIDATE +------------- ------------------------------------------------------------------------------------- ------------ -------------------- ------------------- ------------- -------------------- -------------------- -------------------- +31pkfzpmx1b62 select /* TESTFG */ /*+ INDEX_FFS(t new1) */ sum(val2) from t1 t 0 Y VALID 0 Y N N +ax2r0jyjs0hbb select /* TESTFG */ /*+ USE_INVISIBLE_INDEXES */ count(*) from t1 where val2<50 0 Y VALID 0 Y N N +cf016xd0knzrh select /* TESTFG */ count(*) from t1 where id = 1 0 Y VALID 0 Y N N +gvd4z9ba14uh3 select /* TESTFG */ count(*) from t1 where val1 = 1 0 Y VALID 0 Y N N +221p0y74xg65x select /* TESTFG */ count(*) from t2 partition (p1) 0 Y VALID 0 Y N N +7c65qbgku7can select /* TESTFG */ count(*) from t2 partition (p2) 0 Y VALID 0 Y N N +czjk2xd0vn20k select /* TESTFG */ count(*) from t2 where id < (select max(id) from t1) 0 Y VALID 0 Y N N +1y9y6gg3r5sry select /* TESTFG */ count(*) from t2 where id = 1 0 Y VALID 0 Y N N +dcvq5bcm8yqm9 select /* TESTFG */ count(*) from t2 where id = 1+150000 0 Y VALID 0 Y N N +9jh4ms6ruztw2 select /* TESTFG */ count(*) from t2 where val1 = 1 0 Y VALID 0 Y N N +bcsj7p128xh77 update /* TESTFG */ t1 set val1 = val1 + 1 where id < 50 0 Y INVALID_UNAUTH 1 N N N +bdhfwydh894qk update /* TESTFG */ t1 set val1 = val1 + 1 where val1 < 50 0 Y INVALID_UNAUTH 1 N N N +6a6m4fq5b9v7r update /* TESTFG */ t2 set val1 = val1 + 1 where id < 50 0 Y INVALID_UNAUTH 1 N N N +24qkp15shu1gp update /* TESTFG */ t2 set val1 = val1 + 1 where val1 < 50 0 Y INVALID_UNAUTH 1 N N N + +14 rows selected. + + +no rows selected + +Press + + +Table dropped. + + +Table dropped. + + +Table created. + + +Table created. + + +9999 rows created. + + +9999 rows created. + + +9999 rows created. + + +Index created. + + +Index created. + + +PL/SQL procedure successfully completed. + + +PL/SQL procedure successfully completed. + + +System altered. + + + COUNT(*) +---------- + 1 + + +PLAN_TABLE_OUTPUT +------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ +SQL_ID cf016xd0knzrh, child number 0 +------------------------------------- +select /* TESTFG */ count(*) from t1 where id = 1 + +Plan hash value: 1736604837 + +-------------------------------------------------------------------------- +| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time | +-------------------------------------------------------------------------- +| 0 | SELECT STATEMENT | | | | 1 (100)| | +| 1 | SORT AGGREGATE | | 1 | 4 | | | +|* 2 | INDEX RANGE SCAN| T1I | 1 | 4 | 1 (0)| 00:00:01 | +-------------------------------------------------------------------------- + +Predicate Information (identified by operation id): +--------------------------------------------------- + + 2 - access("ID"=1) + + +19 rows selected. + + + COUNT(*) +---------- + 1 + + +PLAN_TABLE_OUTPUT +------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ +SQL_ID gvd4z9ba14uh3, child number 0 +------------------------------------- +select /* TESTFG */ count(*) from t1 where val1 = 1 + +Plan hash value: 3724264953 + +--------------------------------------------------------------------------- +| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time | +--------------------------------------------------------------------------- +| 0 | SELECT STATEMENT | | | | 9 (100)| | +| 1 | SORT AGGREGATE | | 1 | 4 | | | +|* 2 | TABLE ACCESS FULL| T1 | 1 | 4 | 9 (0)| 00:00:01 | +--------------------------------------------------------------------------- + +Predicate Information (identified by operation id): +--------------------------------------------------- + + 2 - filter("VAL1"=1) + + +19 rows selected. + + + COUNT(*) +---------- + 1 + + +PLAN_TABLE_OUTPUT +------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ +SQL_ID 1y9y6gg3r5sry, child number 0 +------------------------------------- +select /* TESTFG */ count(*) from t2 where id = 1 + +Plan hash value: 1317774485 + +------------------------------------------------------------------------------------------------ +| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time | Pstart| Pstop | +------------------------------------------------------------------------------------------------ +| 0 | SELECT STATEMENT | | | | 1 (100)| | | | +| 1 | SORT AGGREGATE | | 1 | 4 | | | | | +| 2 | PARTITION RANGE SINGLE| | 1 | 4 | 1 (0)| 00:00:01 | 1 | 1 | +|* 3 | INDEX RANGE SCAN | T2I | 1 | 4 | 1 (0)| 00:00:01 | 1 | 1 | +------------------------------------------------------------------------------------------------ + +Predicate Information (identified by operation id): +--------------------------------------------------- + + 3 - access("ID"=1) + + +20 rows selected. + + + COUNT(*) +---------- + 0 + + +PLAN_TABLE_OUTPUT +------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ +SQL_ID dcvq5bcm8yqm9, child number 0 +------------------------------------- +select /* TESTFG */ count(*) from t2 where id = 1+150000 + +Plan hash value: 1317774485 + +------------------------------------------------------------------------------------------------ +| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time | Pstart| Pstop | +------------------------------------------------------------------------------------------------ +| 0 | SELECT STATEMENT | | | | 1 (100)| | | | +| 1 | SORT AGGREGATE | | 1 | 5 | | | | | +| 2 | PARTITION RANGE SINGLE| | 1 | 5 | 1 (0)| 00:00:01 | 2 | 2 | +|* 3 | INDEX RANGE SCAN | T2I | 1 | 5 | 1 (0)| 00:00:01 | 2 | 2 | +------------------------------------------------------------------------------------------------ + +Predicate Information (identified by operation id): +--------------------------------------------------- + + 3 - access("ID"=150001) + + +20 rows selected. + + + COUNT(*) +---------- + 2 + + +PLAN_TABLE_OUTPUT +------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ +SQL_ID 9jh4ms6ruztw2, child number 0 +------------------------------------- +select /* TESTFG */ count(*) from t2 where val1 = 1 + +Plan hash value: 611317447 + +--------------------------------------------------------------------------------------------- +| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time | Pstart| Pstop | +--------------------------------------------------------------------------------------------- +| 0 | SELECT STATEMENT | | | | 16 (100)| | | | +| 1 | SORT AGGREGATE | | 1 | 4 | | | | | +| 2 | PARTITION RANGE ALL| | 2 | 8 | 16 (0)| 00:00:01 | 1 | 2 | +|* 3 | TABLE ACCESS FULL | T2 | 2 | 8 | 16 (0)| 00:00:01 | 1 | 2 | +--------------------------------------------------------------------------------------------- + +Predicate Information (identified by operation id): +--------------------------------------------------- + + 3 - filter("VAL1"=1) + + +20 rows selected. + + + SUM(VAL2) +---------- + 49995000 + + +PLAN_TABLE_OUTPUT +------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ +SQL_ID 31pkfzpmx1b62, child number 0 +------------------------------------- +select /* TESTFG */ /*+ INDEX_FFS(t new1) */ sum(val2) from t1 t + +Plan hash value: 3724264953 + +--------------------------------------------------------------------------- +| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time | +--------------------------------------------------------------------------- +| 0 | SELECT STATEMENT | | | | 9 (100)| | +| 1 | SORT AGGREGATE | | 1 | 4 | | | +| 2 | TABLE ACCESS FULL| T1 | 9999 | 39996 | 9 (0)| 00:00:01 | +--------------------------------------------------------------------------- + + +14 rows selected. + + + COUNT(*) +---------- + 9998 + + +PLAN_TABLE_OUTPUT +------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ +SQL_ID czjk2xd0vn20k, child number 0 +------------------------------------- +select /* TESTFG */ count(*) from t2 where id < (select max(id) from t1) + +Plan hash value: 682288026 + +------------------------------------------------------------------------------------------------------ +| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time | Pstart| Pstop | +------------------------------------------------------------------------------------------------------ +| 0 | SELECT STATEMENT | | | | 2 (100)| | | | +| 1 | SORT AGGREGATE | | 1 | 5 | | | | | +| 2 | PARTITION RANGE ITERATOR | | 1000 | 5000 | 2 (0)| 00:00:01 | 1 | KEY | +|* 3 | INDEX RANGE SCAN | T2I | 1000 | 5000 | 2 (0)| 00:00:01 | 1 | KEY | +| 4 | SORT AGGREGATE | | 1 | 4 | | | | | +| 5 | INDEX FULL SCAN (MIN/MAX)| T1I | 1 | 4 | 2 (0)| 00:00:01 | | | +------------------------------------------------------------------------------------------------------ + +Predicate Information (identified by operation id): +--------------------------------------------------- + + 3 - access("ID"<) + + +22 rows selected. + + + COUNT(*) +---------- + 49 + + +PLAN_TABLE_OUTPUT +------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ +SQL_ID ax2r0jyjs0hbb, child number 0 +------------------------------------- +select /* TESTFG */ /*+ USE_INVISIBLE_INDEXES */ count(*) from t1 where +val2<50 + +Plan hash value: 3724264953 + +--------------------------------------------------------------------------- +| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time | +--------------------------------------------------------------------------- +| 0 | SELECT STATEMENT | | | | 9 (100)| | +| 1 | SORT AGGREGATE | | 1 | 4 | | | +|* 2 | TABLE ACCESS FULL| T1 | 49 | 196 | 9 (0)| 00:00:01 | +--------------------------------------------------------------------------- + +Predicate Information (identified by operation id): +--------------------------------------------------- + + 2 - filter("VAL2"<50) + + +20 rows selected. + + + COUNT(*) +---------- + 9999 + + +PLAN_TABLE_OUTPUT +------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ +SQL_ID 7c65qbgku7can, child number 0 +------------------------------------- +select /* TESTFG */ count(*) from t2 partition (p2) + +Plan hash value: 3928439236 + +---------------------------------------------------------------------------------------- +| Id | Operation | Name | Rows | Cost (%CPU)| Time | Pstart| Pstop | +---------------------------------------------------------------------------------------- +| 0 | SELECT STATEMENT | | | 8 (100)| | | | +| 1 | SORT AGGREGATE | | 1 | | | | | +| 2 | PARTITION RANGE SINGLE| | 9999 | 8 (0)| 00:00:01 | 2 | 2 | +| 3 | INDEX FAST FULL SCAN | T2I | 9999 | 8 (0)| 00:00:01 | 2 | 2 | +---------------------------------------------------------------------------------------- + + +15 rows selected. + + + COUNT(*) +---------- + 9999 + + +PLAN_TABLE_OUTPUT +------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ +SQL_ID 221p0y74xg65x, child number 0 +------------------------------------- +select /* TESTFG */ count(*) from t2 partition (p1) + +Plan hash value: 3928439236 + +---------------------------------------------------------------------------------------- +| Id | Operation | Name | Rows | Cost (%CPU)| Time | Pstart| Pstop | +---------------------------------------------------------------------------------------- +| 0 | SELECT STATEMENT | | | 7 (100)| | | | +| 1 | SORT AGGREGATE | | 1 | | | | | +| 2 | PARTITION RANGE SINGLE| | 9999 | 7 (0)| 00:00:01 | 1 | 1 | +| 3 | INDEX FAST FULL SCAN | T2I | 9999 | 7 (0)| 00:00:01 | 1 | 1 | +---------------------------------------------------------------------------------------- + + +15 rows selected. + + +49 rows updated. + + +98 rows updated. + + +49 rows updated. + + +49 rows updated. + + +Commit complete. + + +SQL_ID SQL_TEXT CHILD_NUMBER IS_SHAREABLE OBJECT_STATUS INVALIDATIONS IS_ROLLING_INVALID IS_ROLLING_REFRESH_I DDL_NO_INVALIDATE +------------- ------------------------------------------------------------------------------------- ------------ -------------------- ------------------- ------------- -------------------- -------------------- -------------------- +31pkfzpmx1b62 select /* TESTFG */ /*+ INDEX_FFS(t new1) */ sum(val2) from t1 t 0 Y VALID 0 N N N +ax2r0jyjs0hbb select /* TESTFG */ /*+ USE_INVISIBLE_INDEXES */ count(*) from t1 where val2<50 0 Y VALID 0 N N N +cf016xd0knzrh select /* TESTFG */ count(*) from t1 where id = 1 0 Y VALID 0 N N N +gvd4z9ba14uh3 select /* TESTFG */ count(*) from t1 where val1 = 1 0 Y VALID 0 N N N +221p0y74xg65x select /* TESTFG */ count(*) from t2 partition (p1) 0 Y VALID 0 N N N +7c65qbgku7can select /* TESTFG */ count(*) from t2 partition (p2) 0 Y VALID 0 N N N +czjk2xd0vn20k select /* TESTFG */ count(*) from t2 where id < (select max(id) from t1) 0 Y VALID 0 N N N +1y9y6gg3r5sry select /* TESTFG */ count(*) from t2 where id = 1 0 Y VALID 0 N N N +dcvq5bcm8yqm9 select /* TESTFG */ count(*) from t2 where id = 1+150000 0 Y VALID 0 N N N +9jh4ms6ruztw2 select /* TESTFG */ count(*) from t2 where val1 = 1 0 Y VALID 0 N N N +bcsj7p128xh77 update /* TESTFG */ t1 set val1 = val1 + 1 where id < 50 0 Y VALID 0 N N N +bdhfwydh894qk update /* TESTFG */ t1 set val1 = val1 + 1 where val1 < 50 0 Y VALID 0 N N N +6a6m4fq5b9v7r update /* TESTFG */ t2 set val1 = val1 + 1 where id < 50 0 Y VALID 0 N N N +24qkp15shu1gp update /* TESTFG */ t2 set val1 = val1 + 1 where val1 < 50 0 Y VALID 0 N N N + +14 rows selected. + + +no rows selected + +SQL> -- +SQL> -- DROP INDEX +SQL> -- +SQL> drop index t1i deferred invalidation; + +Index dropped. + +SQL> drop index t2i deferred invalidation; + +Index dropped. + +SQL> set echo off + +SQL_ID SQL_TEXT CHILD_NUMBER IS_SHAREABLE OBJECT_STATUS INVALIDATIONS IS_ROLLING_INVALID IS_ROLLING_REFRESH_I DDL_NO_INVALIDATE +------------- ------------------------------------------------------------------------------------- ------------ -------------------- ------------------- ------------- -------------------- -------------------- -------------------- +31pkfzpmx1b62 select /* TESTFG */ /*+ INDEX_FFS(t new1) */ sum(val2) from t1 t 0 Y VALID 0 Y N N +ax2r0jyjs0hbb select /* TESTFG */ /*+ USE_INVISIBLE_INDEXES */ count(*) from t1 where val2<50 0 Y VALID 0 Y N N +cf016xd0knzrh select /* TESTFG */ count(*) from t1 where id = 1 0 Y INVALID_UNAUTH 1 N N N +gvd4z9ba14uh3 select /* TESTFG */ count(*) from t1 where val1 = 1 0 Y VALID 0 Y N N +221p0y74xg65x select /* TESTFG */ count(*) from t2 partition (p1) 0 Y INVALID_UNAUTH 1 N N N +7c65qbgku7can select /* TESTFG */ count(*) from t2 partition (p2) 0 Y INVALID_UNAUTH 1 N N N +czjk2xd0vn20k select /* TESTFG */ count(*) from t2 where id < (select max(id) from t1) 0 Y INVALID_UNAUTH 1 N N N +1y9y6gg3r5sry select /* TESTFG */ count(*) from t2 where id = 1 0 Y INVALID_UNAUTH 1 N N N +dcvq5bcm8yqm9 select /* TESTFG */ count(*) from t2 where id = 1+150000 0 Y INVALID_UNAUTH 1 N N N +9jh4ms6ruztw2 select /* TESTFG */ count(*) from t2 where val1 = 1 0 Y VALID 0 Y N N +bcsj7p128xh77 update /* TESTFG */ t1 set val1 = val1 + 1 where id < 50 0 Y INVALID_UNAUTH 1 N N N +bdhfwydh894qk update /* TESTFG */ t1 set val1 = val1 + 1 where val1 < 50 0 Y INVALID_UNAUTH 1 N N N +6a6m4fq5b9v7r update /* TESTFG */ t2 set val1 = val1 + 1 where id < 50 0 Y INVALID_UNAUTH 1 N N N +24qkp15shu1gp update /* TESTFG */ t2 set val1 = val1 + 1 where val1 < 50 0 Y INVALID_UNAUTH 1 N N N + +14 rows selected. + + +no rows selected + +Press + + +Table dropped. + + +Table dropped. + + +Table created. + + +Table created. + + +9999 rows created. + + +9999 rows created. + + +9999 rows created. + + +Index created. + + +Index created. + + +PL/SQL procedure successfully completed. + + +PL/SQL procedure successfully completed. + + +System altered. + + + COUNT(*) +---------- + 1 + + +PLAN_TABLE_OUTPUT +------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ +SQL_ID cf016xd0knzrh, child number 0 +------------------------------------- +select /* TESTFG */ count(*) from t1 where id = 1 + +Plan hash value: 1736604837 + +-------------------------------------------------------------------------- +| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time | +-------------------------------------------------------------------------- +| 0 | SELECT STATEMENT | | | | 1 (100)| | +| 1 | SORT AGGREGATE | | 1 | 4 | | | +|* 2 | INDEX RANGE SCAN| T1I | 1 | 4 | 1 (0)| 00:00:01 | +-------------------------------------------------------------------------- + +Predicate Information (identified by operation id): +--------------------------------------------------- + + 2 - access("ID"=1) + + +19 rows selected. + + + COUNT(*) +---------- + 1 + + +PLAN_TABLE_OUTPUT +------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ +SQL_ID gvd4z9ba14uh3, child number 0 +------------------------------------- +select /* TESTFG */ count(*) from t1 where val1 = 1 + +Plan hash value: 3724264953 + +--------------------------------------------------------------------------- +| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time | +--------------------------------------------------------------------------- +| 0 | SELECT STATEMENT | | | | 9 (100)| | +| 1 | SORT AGGREGATE | | 1 | 4 | | | +|* 2 | TABLE ACCESS FULL| T1 | 1 | 4 | 9 (0)| 00:00:01 | +--------------------------------------------------------------------------- + +Predicate Information (identified by operation id): +--------------------------------------------------- + + 2 - filter("VAL1"=1) + + +19 rows selected. + + + COUNT(*) +---------- + 1 + + +PLAN_TABLE_OUTPUT +------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ +SQL_ID 1y9y6gg3r5sry, child number 0 +------------------------------------- +select /* TESTFG */ count(*) from t2 where id = 1 + +Plan hash value: 1317774485 + +------------------------------------------------------------------------------------------------ +| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time | Pstart| Pstop | +------------------------------------------------------------------------------------------------ +| 0 | SELECT STATEMENT | | | | 1 (100)| | | | +| 1 | SORT AGGREGATE | | 1 | 4 | | | | | +| 2 | PARTITION RANGE SINGLE| | 1 | 4 | 1 (0)| 00:00:01 | 1 | 1 | +|* 3 | INDEX RANGE SCAN | T2I | 1 | 4 | 1 (0)| 00:00:01 | 1 | 1 | +------------------------------------------------------------------------------------------------ + +Predicate Information (identified by operation id): +--------------------------------------------------- + + 3 - access("ID"=1) + + +20 rows selected. + + + COUNT(*) +---------- + 0 + + +PLAN_TABLE_OUTPUT +------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ +SQL_ID dcvq5bcm8yqm9, child number 0 +------------------------------------- +select /* TESTFG */ count(*) from t2 where id = 1+150000 + +Plan hash value: 1317774485 + +------------------------------------------------------------------------------------------------ +| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time | Pstart| Pstop | +------------------------------------------------------------------------------------------------ +| 0 | SELECT STATEMENT | | | | 1 (100)| | | | +| 1 | SORT AGGREGATE | | 1 | 5 | | | | | +| 2 | PARTITION RANGE SINGLE| | 1 | 5 | 1 (0)| 00:00:01 | 2 | 2 | +|* 3 | INDEX RANGE SCAN | T2I | 1 | 5 | 1 (0)| 00:00:01 | 2 | 2 | +------------------------------------------------------------------------------------------------ + +Predicate Information (identified by operation id): +--------------------------------------------------- + + 3 - access("ID"=150001) + + +20 rows selected. + + + COUNT(*) +---------- + 2 + + +PLAN_TABLE_OUTPUT +------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ +SQL_ID 9jh4ms6ruztw2, child number 0 +------------------------------------- +select /* TESTFG */ count(*) from t2 where val1 = 1 + +Plan hash value: 611317447 + +--------------------------------------------------------------------------------------------- +| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time | Pstart| Pstop | +--------------------------------------------------------------------------------------------- +| 0 | SELECT STATEMENT | | | | 15 (100)| | | | +| 1 | SORT AGGREGATE | | 1 | 4 | | | | | +| 2 | PARTITION RANGE ALL| | 2 | 8 | 15 (0)| 00:00:01 | 1 | 2 | +|* 3 | TABLE ACCESS FULL | T2 | 2 | 8 | 15 (0)| 00:00:01 | 1 | 2 | +--------------------------------------------------------------------------------------------- + +Predicate Information (identified by operation id): +--------------------------------------------------- + + 3 - filter("VAL1"=1) + + +20 rows selected. + + + SUM(VAL2) +---------- + 49995000 + + +PLAN_TABLE_OUTPUT +------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ +SQL_ID 31pkfzpmx1b62, child number 0 +------------------------------------- +select /* TESTFG */ /*+ INDEX_FFS(t new1) */ sum(val2) from t1 t + +Plan hash value: 3724264953 + +--------------------------------------------------------------------------- +| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time | +--------------------------------------------------------------------------- +| 0 | SELECT STATEMENT | | | | 9 (100)| | +| 1 | SORT AGGREGATE | | 1 | 4 | | | +| 2 | TABLE ACCESS FULL| T1 | 9999 | 39996 | 9 (0)| 00:00:01 | +--------------------------------------------------------------------------- + + +14 rows selected. + + + COUNT(*) +---------- + 9998 + + +PLAN_TABLE_OUTPUT +------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ +SQL_ID czjk2xd0vn20k, child number 0 +------------------------------------- +select /* TESTFG */ count(*) from t2 where id < (select max(id) from t1) + +Plan hash value: 682288026 + +------------------------------------------------------------------------------------------------------ +| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time | Pstart| Pstop | +------------------------------------------------------------------------------------------------------ +| 0 | SELECT STATEMENT | | | | 2 (100)| | | | +| 1 | SORT AGGREGATE | | 1 | 5 | | | | | +| 2 | PARTITION RANGE ITERATOR | | 1000 | 5000 | 2 (0)| 00:00:01 | 1 | KEY | +|* 3 | INDEX RANGE SCAN | T2I | 1000 | 5000 | 2 (0)| 00:00:01 | 1 | KEY | +| 4 | SORT AGGREGATE | | 1 | 4 | | | | | +| 5 | INDEX FULL SCAN (MIN/MAX)| T1I | 1 | 4 | 2 (0)| 00:00:01 | | | +------------------------------------------------------------------------------------------------------ + +Predicate Information (identified by operation id): +--------------------------------------------------- + + 3 - access("ID"<) + + +22 rows selected. + + + COUNT(*) +---------- + 49 + + +PLAN_TABLE_OUTPUT +------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ +SQL_ID ax2r0jyjs0hbb, child number 0 +------------------------------------- +select /* TESTFG */ /*+ USE_INVISIBLE_INDEXES */ count(*) from t1 where +val2<50 + +Plan hash value: 3724264953 + +--------------------------------------------------------------------------- +| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time | +--------------------------------------------------------------------------- +| 0 | SELECT STATEMENT | | | | 9 (100)| | +| 1 | SORT AGGREGATE | | 1 | 4 | | | +|* 2 | TABLE ACCESS FULL| T1 | 49 | 196 | 9 (0)| 00:00:01 | +--------------------------------------------------------------------------- + +Predicate Information (identified by operation id): +--------------------------------------------------- + + 2 - filter("VAL2"<50) + + +20 rows selected. + + + COUNT(*) +---------- + 9999 + + +PLAN_TABLE_OUTPUT +------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ +SQL_ID 7c65qbgku7can, child number 0 +------------------------------------- +select /* TESTFG */ count(*) from t2 partition (p2) + +Plan hash value: 3928439236 + +---------------------------------------------------------------------------------------- +| Id | Operation | Name | Rows | Cost (%CPU)| Time | Pstart| Pstop | +---------------------------------------------------------------------------------------- +| 0 | SELECT STATEMENT | | | 8 (100)| | | | +| 1 | SORT AGGREGATE | | 1 | | | | | +| 2 | PARTITION RANGE SINGLE| | 9999 | 8 (0)| 00:00:01 | 2 | 2 | +| 3 | INDEX FAST FULL SCAN | T2I | 9999 | 8 (0)| 00:00:01 | 2 | 2 | +---------------------------------------------------------------------------------------- + + +15 rows selected. + + + COUNT(*) +---------- + 9999 + + +PLAN_TABLE_OUTPUT +------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ +SQL_ID 221p0y74xg65x, child number 0 +------------------------------------- +select /* TESTFG */ count(*) from t2 partition (p1) + +Plan hash value: 3928439236 + +---------------------------------------------------------------------------------------- +| Id | Operation | Name | Rows | Cost (%CPU)| Time | Pstart| Pstop | +---------------------------------------------------------------------------------------- +| 0 | SELECT STATEMENT | | | 7 (100)| | | | +| 1 | SORT AGGREGATE | | 1 | | | | | +| 2 | PARTITION RANGE SINGLE| | 9999 | 7 (0)| 00:00:01 | 1 | 1 | +| 3 | INDEX FAST FULL SCAN | T2I | 9999 | 7 (0)| 00:00:01 | 1 | 1 | +---------------------------------------------------------------------------------------- + + +15 rows selected. + + +49 rows updated. + + +98 rows updated. + + +49 rows updated. + + +49 rows updated. + + +Commit complete. + + +SQL_ID SQL_TEXT CHILD_NUMBER IS_SHAREABLE OBJECT_STATUS INVALIDATIONS IS_ROLLING_INVALID IS_ROLLING_REFRESH_I DDL_NO_INVALIDATE +------------- ------------------------------------------------------------------------------------- ------------ -------------------- ------------------- ------------- -------------------- -------------------- -------------------- +31pkfzpmx1b62 select /* TESTFG */ /*+ INDEX_FFS(t new1) */ sum(val2) from t1 t 0 Y VALID 0 N N N +ax2r0jyjs0hbb select /* TESTFG */ /*+ USE_INVISIBLE_INDEXES */ count(*) from t1 where val2<50 0 Y VALID 0 N N N +cf016xd0knzrh select /* TESTFG */ count(*) from t1 where id = 1 0 Y VALID 0 N N N +gvd4z9ba14uh3 select /* TESTFG */ count(*) from t1 where val1 = 1 0 Y VALID 0 N N N +221p0y74xg65x select /* TESTFG */ count(*) from t2 partition (p1) 0 Y VALID 0 N N N +7c65qbgku7can select /* TESTFG */ count(*) from t2 partition (p2) 0 Y VALID 0 N N N +czjk2xd0vn20k select /* TESTFG */ count(*) from t2 where id < (select max(id) from t1) 0 Y VALID 0 N N N +1y9y6gg3r5sry select /* TESTFG */ count(*) from t2 where id = 1 0 Y VALID 0 N N N +dcvq5bcm8yqm9 select /* TESTFG */ count(*) from t2 where id = 1+150000 0 Y VALID 0 N N N +9jh4ms6ruztw2 select /* TESTFG */ count(*) from t2 where val1 = 1 0 Y VALID 0 N N N +bcsj7p128xh77 update /* TESTFG */ t1 set val1 = val1 + 1 where id < 50 0 Y VALID 0 N N N +bdhfwydh894qk update /* TESTFG */ t1 set val1 = val1 + 1 where val1 < 50 0 Y VALID 0 N N N +6a6m4fq5b9v7r update /* TESTFG */ t2 set val1 = val1 + 1 where id < 50 0 Y VALID 0 N N N +24qkp15shu1gp update /* TESTFG */ t2 set val1 = val1 + 1 where val1 < 50 0 Y VALID 0 N N N + +14 rows selected. + + +no rows selected + +SQL> -- +SQL> -- INDEX UNUSABLE +SQL> -- +SQL> alter index t1i unusable deferred invalidation; + +Index altered. + +SQL> alter index t2i modify partition p1i unusable deferred invalidation; +alter index t2i modify partition p1i unusable deferred invalidation + * +ERROR at line 1: +ORA-14048: a partition maintenance operation may not be combined with other operations + + +SQL> +SQL> alter session set CURSOR_INVALIDATION = 'deferred'; + +Session altered. + +SQL> alter index t2i modify partition p1i unusable; + +Index altered. + +SQL> alter session set CURSOR_INVALIDATION = 'immediate'; + +Session altered. + +SQL> +SQL> set echo off + +SQL_ID SQL_TEXT CHILD_NUMBER IS_SHAREABLE OBJECT_STATUS INVALIDATIONS IS_ROLLING_INVALID IS_ROLLING_REFRESH_I DDL_NO_INVALIDATE +------------- ------------------------------------------------------------------------------------- ------------ -------------------- ------------------- ------------- -------------------- -------------------- -------------------- +31pkfzpmx1b62 select /* TESTFG */ /*+ INDEX_FFS(t new1) */ sum(val2) from t1 t 0 Y VALID 0 Y N N +ax2r0jyjs0hbb select /* TESTFG */ /*+ USE_INVISIBLE_INDEXES */ count(*) from t1 where val2<50 0 Y VALID 0 Y N N +cf016xd0knzrh select /* TESTFG */ count(*) from t1 where id = 1 0 Y INVALID_UNAUTH 1 N N N +gvd4z9ba14uh3 select /* TESTFG */ count(*) from t1 where val1 = 1 0 Y VALID 0 Y N N +221p0y74xg65x select /* TESTFG */ count(*) from t2 partition (p1) 0 Y INVALID_UNAUTH 1 N N N +7c65qbgku7can select /* TESTFG */ count(*) from t2 partition (p2) 0 Y INVALID_UNAUTH 1 N N N +czjk2xd0vn20k select /* TESTFG */ count(*) from t2 where id < (select max(id) from t1) 0 Y INVALID_UNAUTH 1 N N N +1y9y6gg3r5sry select /* TESTFG */ count(*) from t2 where id = 1 0 Y INVALID_UNAUTH 1 N N N +dcvq5bcm8yqm9 select /* TESTFG */ count(*) from t2 where id = 1+150000 0 Y INVALID_UNAUTH 1 N N N +9jh4ms6ruztw2 select /* TESTFG */ count(*) from t2 where val1 = 1 0 Y INVALID_UNAUTH 1 N N N +bcsj7p128xh77 update /* TESTFG */ t1 set val1 = val1 + 1 where id < 50 0 Y INVALID_UNAUTH 1 N N N +bdhfwydh894qk update /* TESTFG */ t1 set val1 = val1 + 1 where val1 < 50 0 Y INVALID_UNAUTH 1 N N N +6a6m4fq5b9v7r update /* TESTFG */ t2 set val1 = val1 + 1 where id < 50 0 Y INVALID_UNAUTH 1 N N N +24qkp15shu1gp update /* TESTFG */ t2 set val1 = val1 + 1 where val1 < 50 0 Y INVALID_UNAUTH 1 N N N + +14 rows selected. + + +no rows selected + +Press + + +Table dropped. + + +Table dropped. + + +Table created. + + +Table created. + + +9999 rows created. + + +9999 rows created. + + +9999 rows created. + + +Index created. + + +Index created. + + +PL/SQL procedure successfully completed. + + +PL/SQL procedure successfully completed. + + +System altered. + + + COUNT(*) +---------- + 1 + + +PLAN_TABLE_OUTPUT +------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ +SQL_ID cf016xd0knzrh, child number 0 +------------------------------------- +select /* TESTFG */ count(*) from t1 where id = 1 + +Plan hash value: 1736604837 + +-------------------------------------------------------------------------- +| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time | +-------------------------------------------------------------------------- +| 0 | SELECT STATEMENT | | | | 1 (100)| | +| 1 | SORT AGGREGATE | | 1 | 4 | | | +|* 2 | INDEX RANGE SCAN| T1I | 1 | 4 | 1 (0)| 00:00:01 | +-------------------------------------------------------------------------- + +Predicate Information (identified by operation id): +--------------------------------------------------- + + 2 - access("ID"=1) + + +19 rows selected. + + + COUNT(*) +---------- + 1 + + +PLAN_TABLE_OUTPUT +------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ +SQL_ID gvd4z9ba14uh3, child number 0 +------------------------------------- +select /* TESTFG */ count(*) from t1 where val1 = 1 + +Plan hash value: 3724264953 + +--------------------------------------------------------------------------- +| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time | +--------------------------------------------------------------------------- +| 0 | SELECT STATEMENT | | | | 8 (100)| | +| 1 | SORT AGGREGATE | | 1 | 4 | | | +|* 2 | TABLE ACCESS FULL| T1 | 1 | 4 | 8 (0)| 00:00:01 | +--------------------------------------------------------------------------- + +Predicate Information (identified by operation id): +--------------------------------------------------- + + 2 - filter("VAL1"=1) + + +19 rows selected. + + + COUNT(*) +---------- + 1 + + +PLAN_TABLE_OUTPUT +------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ +SQL_ID 1y9y6gg3r5sry, child number 0 +------------------------------------- +select /* TESTFG */ count(*) from t2 where id = 1 + +Plan hash value: 1317774485 + +------------------------------------------------------------------------------------------------ +| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time | Pstart| Pstop | +------------------------------------------------------------------------------------------------ +| 0 | SELECT STATEMENT | | | | 1 (100)| | | | +| 1 | SORT AGGREGATE | | 1 | 4 | | | | | +| 2 | PARTITION RANGE SINGLE| | 1 | 4 | 1 (0)| 00:00:01 | 1 | 1 | +|* 3 | INDEX RANGE SCAN | T2I | 1 | 4 | 1 (0)| 00:00:01 | 1 | 1 | +------------------------------------------------------------------------------------------------ + +Predicate Information (identified by operation id): +--------------------------------------------------- + + 3 - access("ID"=1) + + +20 rows selected. + + + COUNT(*) +---------- + 0 + + +PLAN_TABLE_OUTPUT +------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ +SQL_ID dcvq5bcm8yqm9, child number 0 +------------------------------------- +select /* TESTFG */ count(*) from t2 where id = 1+150000 + +Plan hash value: 1317774485 + +------------------------------------------------------------------------------------------------ +| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time | Pstart| Pstop | +------------------------------------------------------------------------------------------------ +| 0 | SELECT STATEMENT | | | | 1 (100)| | | | +| 1 | SORT AGGREGATE | | 1 | 5 | | | | | +| 2 | PARTITION RANGE SINGLE| | 1 | 5 | 1 (0)| 00:00:01 | 2 | 2 | +|* 3 | INDEX RANGE SCAN | T2I | 1 | 5 | 1 (0)| 00:00:01 | 2 | 2 | +------------------------------------------------------------------------------------------------ + +Predicate Information (identified by operation id): +--------------------------------------------------- + + 3 - access("ID"=150001) + + +20 rows selected. + + + COUNT(*) +---------- + 2 + + +PLAN_TABLE_OUTPUT +------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ +SQL_ID 9jh4ms6ruztw2, child number 0 +------------------------------------- +select /* TESTFG */ count(*) from t2 where val1 = 1 + +Plan hash value: 611317447 + +--------------------------------------------------------------------------------------------- +| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time | Pstart| Pstop | +--------------------------------------------------------------------------------------------- +| 0 | SELECT STATEMENT | | | | 16 (100)| | | | +| 1 | SORT AGGREGATE | | 1 | 4 | | | | | +| 2 | PARTITION RANGE ALL| | 2 | 8 | 16 (0)| 00:00:01 | 1 | 2 | +|* 3 | TABLE ACCESS FULL | T2 | 2 | 8 | 16 (0)| 00:00:01 | 1 | 2 | +--------------------------------------------------------------------------------------------- + +Predicate Information (identified by operation id): +--------------------------------------------------- + + 3 - filter("VAL1"=1) + + +20 rows selected. + + + SUM(VAL2) +---------- + 49995000 + + +PLAN_TABLE_OUTPUT +------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ +SQL_ID 31pkfzpmx1b62, child number 0 +------------------------------------- +select /* TESTFG */ /*+ INDEX_FFS(t new1) */ sum(val2) from t1 t + +Plan hash value: 3724264953 + +--------------------------------------------------------------------------- +| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time | +--------------------------------------------------------------------------- +| 0 | SELECT STATEMENT | | | | 8 (100)| | +| 1 | SORT AGGREGATE | | 1 | 4 | | | +| 2 | TABLE ACCESS FULL| T1 | 9999 | 39996 | 8 (0)| 00:00:01 | +--------------------------------------------------------------------------- + + +14 rows selected. + + + COUNT(*) +---------- + 9998 + + +PLAN_TABLE_OUTPUT +------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ +SQL_ID czjk2xd0vn20k, child number 0 +------------------------------------- +select /* TESTFG */ count(*) from t2 where id < (select max(id) from t1) + +Plan hash value: 682288026 + +------------------------------------------------------------------------------------------------------ +| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time | Pstart| Pstop | +------------------------------------------------------------------------------------------------------ +| 0 | SELECT STATEMENT | | | | 2 (100)| | | | +| 1 | SORT AGGREGATE | | 1 | 5 | | | | | +| 2 | PARTITION RANGE ITERATOR | | 1000 | 5000 | 2 (0)| 00:00:01 | 1 | KEY | +|* 3 | INDEX RANGE SCAN | T2I | 1000 | 5000 | 2 (0)| 00:00:01 | 1 | KEY | +| 4 | SORT AGGREGATE | | 1 | 4 | | | | | +| 5 | INDEX FULL SCAN (MIN/MAX)| T1I | 1 | 4 | 2 (0)| 00:00:01 | | | +------------------------------------------------------------------------------------------------------ + +Predicate Information (identified by operation id): +--------------------------------------------------- + + 3 - access("ID"<) + + +22 rows selected. + + + COUNT(*) +---------- + 49 + + +PLAN_TABLE_OUTPUT +------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ +SQL_ID ax2r0jyjs0hbb, child number 0 +------------------------------------- +select /* TESTFG */ /*+ USE_INVISIBLE_INDEXES */ count(*) from t1 where +val2<50 + +Plan hash value: 3724264953 + +--------------------------------------------------------------------------- +| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time | +--------------------------------------------------------------------------- +| 0 | SELECT STATEMENT | | | | 8 (100)| | +| 1 | SORT AGGREGATE | | 1 | 4 | | | +|* 2 | TABLE ACCESS FULL| T1 | 49 | 196 | 8 (0)| 00:00:01 | +--------------------------------------------------------------------------- + +Predicate Information (identified by operation id): +--------------------------------------------------- + + 2 - filter("VAL2"<50) + + +20 rows selected. + + + COUNT(*) +---------- + 9999 + + +PLAN_TABLE_OUTPUT +------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ +SQL_ID 7c65qbgku7can, child number 0 +------------------------------------- +select /* TESTFG */ count(*) from t2 partition (p2) + +Plan hash value: 3928439236 + +---------------------------------------------------------------------------------------- +| Id | Operation | Name | Rows | Cost (%CPU)| Time | Pstart| Pstop | +---------------------------------------------------------------------------------------- +| 0 | SELECT STATEMENT | | | 8 (100)| | | | +| 1 | SORT AGGREGATE | | 1 | | | | | +| 2 | PARTITION RANGE SINGLE| | 9999 | 8 (0)| 00:00:01 | 2 | 2 | +| 3 | INDEX FAST FULL SCAN | T2I | 9999 | 8 (0)| 00:00:01 | 2 | 2 | +---------------------------------------------------------------------------------------- + + +15 rows selected. + + + COUNT(*) +---------- + 9999 + + +PLAN_TABLE_OUTPUT +------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ +SQL_ID 221p0y74xg65x, child number 0 +------------------------------------- +select /* TESTFG */ count(*) from t2 partition (p1) + +Plan hash value: 3928439236 + +---------------------------------------------------------------------------------------- +| Id | Operation | Name | Rows | Cost (%CPU)| Time | Pstart| Pstop | +---------------------------------------------------------------------------------------- +| 0 | SELECT STATEMENT | | | 7 (100)| | | | +| 1 | SORT AGGREGATE | | 1 | | | | | +| 2 | PARTITION RANGE SINGLE| | 9999 | 7 (0)| 00:00:01 | 1 | 1 | +| 3 | INDEX FAST FULL SCAN | T2I | 9999 | 7 (0)| 00:00:01 | 1 | 1 | +---------------------------------------------------------------------------------------- + + +15 rows selected. + + +49 rows updated. + + +98 rows updated. + + +49 rows updated. + + +49 rows updated. + + +Commit complete. + + +SQL_ID SQL_TEXT CHILD_NUMBER IS_SHAREABLE OBJECT_STATUS INVALIDATIONS IS_ROLLING_INVALID IS_ROLLING_REFRESH_I DDL_NO_INVALIDATE +------------- ------------------------------------------------------------------------------------- ------------ -------------------- ------------------- ------------- -------------------- -------------------- -------------------- +31pkfzpmx1b62 select /* TESTFG */ /*+ INDEX_FFS(t new1) */ sum(val2) from t1 t 0 Y VALID 0 N N N +ax2r0jyjs0hbb select /* TESTFG */ /*+ USE_INVISIBLE_INDEXES */ count(*) from t1 where val2<50 0 Y VALID 0 N N N +cf016xd0knzrh select /* TESTFG */ count(*) from t1 where id = 1 0 Y VALID 0 N N N +gvd4z9ba14uh3 select /* TESTFG */ count(*) from t1 where val1 = 1 0 Y VALID 0 N N N +221p0y74xg65x select /* TESTFG */ count(*) from t2 partition (p1) 0 Y VALID 0 N N N +7c65qbgku7can select /* TESTFG */ count(*) from t2 partition (p2) 0 Y VALID 0 N N N +czjk2xd0vn20k select /* TESTFG */ count(*) from t2 where id < (select max(id) from t1) 0 Y VALID 0 N N N +1y9y6gg3r5sry select /* TESTFG */ count(*) from t2 where id = 1 0 Y VALID 0 N N N +dcvq5bcm8yqm9 select /* TESTFG */ count(*) from t2 where id = 1+150000 0 Y VALID 0 N N N +9jh4ms6ruztw2 select /* TESTFG */ count(*) from t2 where val1 = 1 0 Y VALID 0 N N N +bcsj7p128xh77 update /* TESTFG */ t1 set val1 = val1 + 1 where id < 50 0 Y VALID 0 N N N +bdhfwydh894qk update /* TESTFG */ t1 set val1 = val1 + 1 where val1 < 50 0 Y VALID 0 N N N +6a6m4fq5b9v7r update /* TESTFG */ t2 set val1 = val1 + 1 where id < 50 0 Y VALID 0 N N N +24qkp15shu1gp update /* TESTFG */ t2 set val1 = val1 + 1 where val1 < 50 0 Y VALID 0 N N N + +14 rows selected. + + +no rows selected + +SQL> -- +SQL> -- INDEX REBUILD +SQL> -- +SQL> alter index t1i rebuild deferred invalidation; + +Index altered. + +SQL> alter index t2i rebuild partition p1i deferred invalidation; + +Index altered. + +SQL> set echo off + +SQL_ID SQL_TEXT CHILD_NUMBER IS_SHAREABLE OBJECT_STATUS INVALIDATIONS IS_ROLLING_INVALID IS_ROLLING_REFRESH_I DDL_NO_INVALIDATE +------------- ------------------------------------------------------------------------------------- ------------ -------------------- ------------------- ------------- -------------------- -------------------- -------------------- +31pkfzpmx1b62 select /* TESTFG */ /*+ INDEX_FFS(t new1) */ sum(val2) from t1 t 0 Y VALID 0 Y N N +ax2r0jyjs0hbb select /* TESTFG */ /*+ USE_INVISIBLE_INDEXES */ count(*) from t1 where val2<50 0 Y VALID 0 Y N N +cf016xd0knzrh select /* TESTFG */ count(*) from t1 where id = 1 0 Y VALID 0 N Y N +gvd4z9ba14uh3 select /* TESTFG */ count(*) from t1 where val1 = 1 0 Y VALID 0 Y N N +221p0y74xg65x select /* TESTFG */ count(*) from t2 partition (p1) 0 Y VALID 0 N Y N +7c65qbgku7can select /* TESTFG */ count(*) from t2 partition (p2) 0 Y VALID 0 N Y N +czjk2xd0vn20k select /* TESTFG */ count(*) from t2 where id < (select max(id) from t1) 0 Y VALID 0 N Y N +1y9y6gg3r5sry select /* TESTFG */ count(*) from t2 where id = 1 0 Y VALID 0 N Y N +dcvq5bcm8yqm9 select /* TESTFG */ count(*) from t2 where id = 1+150000 0 Y VALID 0 N Y N +9jh4ms6ruztw2 select /* TESTFG */ count(*) from t2 where val1 = 1 0 Y VALID 0 N N Y +bcsj7p128xh77 update /* TESTFG */ t1 set val1 = val1 + 1 where id < 50 0 Y VALID 0 N Y N +bdhfwydh894qk update /* TESTFG */ t1 set val1 = val1 + 1 where val1 < 50 0 Y VALID 0 N Y N +6a6m4fq5b9v7r update /* TESTFG */ t2 set val1 = val1 + 1 where id < 50 0 Y VALID 0 N Y N +24qkp15shu1gp update /* TESTFG */ t2 set val1 = val1 + 1 where val1 < 50 0 Y VALID 0 N Y N + +14 rows selected. + + +no rows selected + + +Table dropped. + + +Table dropped. + + +Table created. + + +Table created. + + +9999 rows created. + + +9999 rows created. + + +9999 rows created. + + +Index created. + + +Index created. + + +PL/SQL procedure successfully completed. + + +PL/SQL procedure successfully completed. + +Get rid of indexes... +SQL> drop index t1i; + +Index dropped. + +SQL> drop index t2i; + +Index dropped. + +SQL> set echo off + +System altered. + + + COUNT(*) +---------- + 1 + + +PLAN_TABLE_OUTPUT +------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ +SQL_ID cf016xd0knzrh, child number 0 +------------------------------------- +select /* TESTFG */ count(*) from t1 where id = 1 + +Plan hash value: 3724264953 + +--------------------------------------------------------------------------- +| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time | +--------------------------------------------------------------------------- +| 0 | SELECT STATEMENT | | | | 9 (100)| | +| 1 | SORT AGGREGATE | | 1 | 4 | | | +|* 2 | TABLE ACCESS FULL| T1 | 1 | 4 | 9 (0)| 00:00:01 | +--------------------------------------------------------------------------- + +Predicate Information (identified by operation id): +--------------------------------------------------- + + 2 - filter("ID"=1) + + +19 rows selected. + + + COUNT(*) +---------- + 1 + + +PLAN_TABLE_OUTPUT +------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ +SQL_ID gvd4z9ba14uh3, child number 0 +------------------------------------- +select /* TESTFG */ count(*) from t1 where val1 = 1 + +Plan hash value: 3724264953 + +--------------------------------------------------------------------------- +| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time | +--------------------------------------------------------------------------- +| 0 | SELECT STATEMENT | | | | 9 (100)| | +| 1 | SORT AGGREGATE | | 1 | 4 | | | +|* 2 | TABLE ACCESS FULL| T1 | 1 | 4 | 9 (0)| 00:00:01 | +--------------------------------------------------------------------------- + +Predicate Information (identified by operation id): +--------------------------------------------------- + + 2 - filter("VAL1"=1) + + +19 rows selected. + + + COUNT(*) +---------- + 1 + + +PLAN_TABLE_OUTPUT +------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ +SQL_ID 1y9y6gg3r5sry, child number 0 +------------------------------------- +select /* TESTFG */ count(*) from t2 where id = 1 + +Plan hash value: 2457353553 + +------------------------------------------------------------------------------------------------ +| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time | Pstart| Pstop | +------------------------------------------------------------------------------------------------ +| 0 | SELECT STATEMENT | | | | 9 (100)| | | | +| 1 | SORT AGGREGATE | | 1 | 4 | | | | | +| 2 | PARTITION RANGE SINGLE| | 1 | 4 | 9 (0)| 00:00:01 | 1 | 1 | +|* 3 | TABLE ACCESS FULL | T2 | 1 | 4 | 9 (0)| 00:00:01 | 1 | 1 | +------------------------------------------------------------------------------------------------ + +Predicate Information (identified by operation id): +--------------------------------------------------- + + 3 - filter("ID"=1) + + +20 rows selected. + + + COUNT(*) +---------- + 0 + + +PLAN_TABLE_OUTPUT +------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ +SQL_ID dcvq5bcm8yqm9, child number 0 +------------------------------------- +select /* TESTFG */ count(*) from t2 where id = 1+150000 + +Plan hash value: 2457353553 + +------------------------------------------------------------------------------------------------ +| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time | Pstart| Pstop | +------------------------------------------------------------------------------------------------ +| 0 | SELECT STATEMENT | | | | 9 (100)| | | | +| 1 | SORT AGGREGATE | | 1 | 5 | | | | | +| 2 | PARTITION RANGE SINGLE| | 1 | 5 | 9 (0)| 00:00:01 | 2 | 2 | +|* 3 | TABLE ACCESS FULL | T2 | 1 | 5 | 9 (0)| 00:00:01 | 2 | 2 | +------------------------------------------------------------------------------------------------ + +Predicate Information (identified by operation id): +--------------------------------------------------- + + 3 - filter("ID"=150001) + + +20 rows selected. + + + COUNT(*) +---------- + 2 + + +PLAN_TABLE_OUTPUT +------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ +SQL_ID 9jh4ms6ruztw2, child number 0 +------------------------------------- +select /* TESTFG */ count(*) from t2 where val1 = 1 + +Plan hash value: 611317447 + +--------------------------------------------------------------------------------------------- +| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time | Pstart| Pstop | +--------------------------------------------------------------------------------------------- +| 0 | SELECT STATEMENT | | | | 16 (100)| | | | +| 1 | SORT AGGREGATE | | 1 | 4 | | | | | +| 2 | PARTITION RANGE ALL| | 2 | 8 | 16 (0)| 00:00:01 | 1 | 2 | +|* 3 | TABLE ACCESS FULL | T2 | 2 | 8 | 16 (0)| 00:00:01 | 1 | 2 | +--------------------------------------------------------------------------------------------- + +Predicate Information (identified by operation id): +--------------------------------------------------- + + 3 - filter("VAL1"=1) + + +20 rows selected. + + + SUM(VAL2) +---------- + 49995000 + + +PLAN_TABLE_OUTPUT +------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ +SQL_ID 31pkfzpmx1b62, child number 0 +------------------------------------- +select /* TESTFG */ /*+ INDEX_FFS(t new1) */ sum(val2) from t1 t + +Plan hash value: 3724264953 + +--------------------------------------------------------------------------- +| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time | +--------------------------------------------------------------------------- +| 0 | SELECT STATEMENT | | | | 9 (100)| | +| 1 | SORT AGGREGATE | | 1 | 4 | | | +| 2 | TABLE ACCESS FULL| T1 | 9999 | 39996 | 9 (0)| 00:00:01 | +--------------------------------------------------------------------------- + + +14 rows selected. + + + COUNT(*) +---------- + 9998 + + +PLAN_TABLE_OUTPUT +------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ +SQL_ID czjk2xd0vn20k, child number 0 +------------------------------------- +select /* TESTFG */ count(*) from t2 where id < (select max(id) from t1) + +Plan hash value: 771265474 + +-------------------------------------------------------------------------------------------------- +| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time | Pstart| Pstop | +-------------------------------------------------------------------------------------------------- +| 0 | SELECT STATEMENT | | | | 25 (100)| | | | +| 1 | SORT AGGREGATE | | 1 | 5 | | | | | +| 2 | PARTITION RANGE ITERATOR| | 1000 | 5000 | 16 (0)| 00:00:01 | 1 | KEY | +|* 3 | TABLE ACCESS FULL | T2 | 1000 | 5000 | 16 (0)| 00:00:01 | 1 | KEY | +| 4 | SORT AGGREGATE | | 1 | 4 | | | | | +| 5 | TABLE ACCESS FULL | T1 | 9999 | 39996 | 9 (0)| 00:00:01 | | | +-------------------------------------------------------------------------------------------------- + +Predicate Information (identified by operation id): +--------------------------------------------------- + + 3 - filter("ID"<) + + +22 rows selected. + + + COUNT(*) +---------- + 49 + + +PLAN_TABLE_OUTPUT +------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ +SQL_ID ax2r0jyjs0hbb, child number 0 +------------------------------------- +select /* TESTFG */ /*+ USE_INVISIBLE_INDEXES */ count(*) from t1 where +val2<50 + +Plan hash value: 3724264953 + +--------------------------------------------------------------------------- +| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time | +--------------------------------------------------------------------------- +| 0 | SELECT STATEMENT | | | | 9 (100)| | +| 1 | SORT AGGREGATE | | 1 | 4 | | | +|* 2 | TABLE ACCESS FULL| T1 | 49 | 196 | 9 (0)| 00:00:01 | +--------------------------------------------------------------------------- + +Predicate Information (identified by operation id): +--------------------------------------------------- + + 2 - filter("VAL2"<50) + + +20 rows selected. + + + COUNT(*) +---------- + 9999 + + +PLAN_TABLE_OUTPUT +------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ +SQL_ID 7c65qbgku7can, child number 0 +------------------------------------- +select /* TESTFG */ count(*) from t2 partition (p2) + +Plan hash value: 2457353553 + +---------------------------------------------------------------------------------------- +| Id | Operation | Name | Rows | Cost (%CPU)| Time | Pstart| Pstop | +---------------------------------------------------------------------------------------- +| 0 | SELECT STATEMENT | | | 9 (100)| | | | +| 1 | SORT AGGREGATE | | 1 | | | | | +| 2 | PARTITION RANGE SINGLE| | 9999 | 9 (0)| 00:00:01 | 2 | 2 | +| 3 | TABLE ACCESS FULL | T2 | 9999 | 9 (0)| 00:00:01 | 2 | 2 | +---------------------------------------------------------------------------------------- + + +15 rows selected. + + + COUNT(*) +---------- + 9999 + + +PLAN_TABLE_OUTPUT +------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ +SQL_ID 221p0y74xg65x, child number 0 +------------------------------------- +select /* TESTFG */ count(*) from t2 partition (p1) + +Plan hash value: 2457353553 + +---------------------------------------------------------------------------------------- +| Id | Operation | Name | Rows | Cost (%CPU)| Time | Pstart| Pstop | +---------------------------------------------------------------------------------------- +| 0 | SELECT STATEMENT | | | 9 (100)| | | | +| 1 | SORT AGGREGATE | | 1 | | | | | +| 2 | PARTITION RANGE SINGLE| | 9999 | 9 (0)| 00:00:01 | 1 | 1 | +| 3 | TABLE ACCESS FULL | T2 | 9999 | 9 (0)| 00:00:01 | 1 | 1 | +---------------------------------------------------------------------------------------- + + +15 rows selected. + + +49 rows updated. + + +98 rows updated. + + +49 rows updated. + + +49 rows updated. + + +Commit complete. + + +SQL_ID SQL_TEXT CHILD_NUMBER IS_SHAREABLE OBJECT_STATUS INVALIDATIONS IS_ROLLING_INVALID IS_ROLLING_REFRESH_I DDL_NO_INVALIDATE +------------- ------------------------------------------------------------------------------------- ------------ -------------------- ------------------- ------------- -------------------- -------------------- -------------------- +31pkfzpmx1b62 select /* TESTFG */ /*+ INDEX_FFS(t new1) */ sum(val2) from t1 t 0 Y VALID 0 N N N +ax2r0jyjs0hbb select /* TESTFG */ /*+ USE_INVISIBLE_INDEXES */ count(*) from t1 where val2<50 0 Y VALID 0 N N N +cf016xd0knzrh select /* TESTFG */ count(*) from t1 where id = 1 0 Y VALID 0 N N N +gvd4z9ba14uh3 select /* TESTFG */ count(*) from t1 where val1 = 1 0 Y VALID 0 N N N +221p0y74xg65x select /* TESTFG */ count(*) from t2 partition (p1) 0 Y VALID 0 N N N +7c65qbgku7can select /* TESTFG */ count(*) from t2 partition (p2) 0 Y VALID 0 N N N +czjk2xd0vn20k select /* TESTFG */ count(*) from t2 where id < (select max(id) from t1) 0 Y VALID 0 N N N +1y9y6gg3r5sry select /* TESTFG */ count(*) from t2 where id = 1 0 Y VALID 0 N N N +dcvq5bcm8yqm9 select /* TESTFG */ count(*) from t2 where id = 1+150000 0 Y VALID 0 N N N +9jh4ms6ruztw2 select /* TESTFG */ count(*) from t2 where val1 = 1 0 Y VALID 0 N N N +bcsj7p128xh77 update /* TESTFG */ t1 set val1 = val1 + 1 where id < 50 0 Y VALID 0 N N N +bdhfwydh894qk update /* TESTFG */ t1 set val1 = val1 + 1 where val1 < 50 0 Y VALID 0 N N N +6a6m4fq5b9v7r update /* TESTFG */ t2 set val1 = val1 + 1 where id < 50 0 Y VALID 0 N N N +24qkp15shu1gp update /* TESTFG */ t2 set val1 = val1 + 1 where val1 < 50 0 Y VALID 0 N N N + +14 rows selected. + + +no rows selected + +SQL> -- +SQL> -- TRUNCATE TABLE/PARTITION +SQL> -- +SQL> -- ## NOTE Accepted but might not implemented because T1 is not partitioned... +SQL> truncate table t1 deferred invalidation; + +Table truncated. + +SQL> alter table t2 truncate partition p1 deferred invalidation; + +Table truncated. + +SQL> set echo off +### Truncate partition is fine-grained, but truncate table is not + +SQL_ID SQL_TEXT CHILD_NUMBER IS_SHAREABLE OBJECT_STATUS INVALIDATIONS IS_ROLLING_INVALID IS_ROLLING_REFRESH_I DDL_NO_INVALIDATE +------------- ------------------------------------------------------------------------------------- ------------ -------------------- ------------------- ------------- -------------------- -------------------- -------------------- +31pkfzpmx1b62 select /* TESTFG */ /*+ INDEX_FFS(t new1) */ sum(val2) from t1 t 0 Y INVALID_UNAUTH 1 N N N +ax2r0jyjs0hbb select /* TESTFG */ /*+ USE_INVISIBLE_INDEXES */ count(*) from t1 where val2<50 0 Y INVALID_UNAUTH 1 N N N +cf016xd0knzrh select /* TESTFG */ count(*) from t1 where id = 1 0 Y INVALID_UNAUTH 1 N N N +gvd4z9ba14uh3 select /* TESTFG */ count(*) from t1 where val1 = 1 0 Y INVALID_UNAUTH 1 N N N +221p0y74xg65x select /* TESTFG */ count(*) from t2 partition (p1) 0 Y VALID 0 N Y N +7c65qbgku7can select /* TESTFG */ count(*) from t2 partition (p2) 0 Y VALID 0 N Y N +czjk2xd0vn20k select /* TESTFG */ count(*) from t2 where id < (select max(id) from t1) 0 Y INVALID_UNAUTH 1 N N N +1y9y6gg3r5sry select /* TESTFG */ count(*) from t2 where id = 1 0 Y VALID 0 N Y N +dcvq5bcm8yqm9 select /* TESTFG */ count(*) from t2 where id = 1+150000 0 Y VALID 0 N Y N +9jh4ms6ruztw2 select /* TESTFG */ count(*) from t2 where val1 = 1 0 Y VALID 0 N Y N +bcsj7p128xh77 update /* TESTFG */ t1 set val1 = val1 + 1 where id < 50 0 Y INVALID_UNAUTH 1 N N N +bdhfwydh894qk update /* TESTFG */ t1 set val1 = val1 + 1 where val1 < 50 0 Y INVALID_UNAUTH 1 N N N +6a6m4fq5b9v7r update /* TESTFG */ t2 set val1 = val1 + 1 where id < 50 0 Y VALID 0 N Y N +24qkp15shu1gp update /* TESTFG */ t2 set val1 = val1 + 1 where val1 < 50 0 Y VALID 0 N Y N + +14 rows selected. + + +no rows selected + + +Table dropped. + + +Table dropped. + + +Table created. + + +Table created. + + +9999 rows created. + + +9999 rows created. + + +9999 rows created. + + +Index created. + + +Index created. + + +PL/SQL procedure successfully completed. + + +PL/SQL procedure successfully completed. + +Get rid of indexes... +SQL> drop index t1i; + +Index dropped. + +SQL> drop index t2i; + +Index dropped. + +SQL> set echo off + +System altered. + + + COUNT(*) +---------- + 1 + + +PLAN_TABLE_OUTPUT +------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ +SQL_ID cf016xd0knzrh, child number 0 +------------------------------------- +select /* TESTFG */ count(*) from t1 where id = 1 + +Plan hash value: 3724264953 + +--------------------------------------------------------------------------- +| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time | +--------------------------------------------------------------------------- +| 0 | SELECT STATEMENT | | | | 9 (100)| | +| 1 | SORT AGGREGATE | | 1 | 4 | | | +|* 2 | TABLE ACCESS FULL| T1 | 1 | 4 | 9 (0)| 00:00:01 | +--------------------------------------------------------------------------- + +Predicate Information (identified by operation id): +--------------------------------------------------- + + 2 - filter("ID"=1) + + +19 rows selected. + + + COUNT(*) +---------- + 1 + + +PLAN_TABLE_OUTPUT +------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ +SQL_ID gvd4z9ba14uh3, child number 0 +------------------------------------- +select /* TESTFG */ count(*) from t1 where val1 = 1 + +Plan hash value: 3724264953 + +--------------------------------------------------------------------------- +| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time | +--------------------------------------------------------------------------- +| 0 | SELECT STATEMENT | | | | 9 (100)| | +| 1 | SORT AGGREGATE | | 1 | 4 | | | +|* 2 | TABLE ACCESS FULL| T1 | 1 | 4 | 9 (0)| 00:00:01 | +--------------------------------------------------------------------------- + +Predicate Information (identified by operation id): +--------------------------------------------------- + + 2 - filter("VAL1"=1) + + +19 rows selected. + + + COUNT(*) +---------- + 1 + + +PLAN_TABLE_OUTPUT +------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ +SQL_ID 1y9y6gg3r5sry, child number 0 +------------------------------------- +select /* TESTFG */ count(*) from t2 where id = 1 + +Plan hash value: 2457353553 + +------------------------------------------------------------------------------------------------ +| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time | Pstart| Pstop | +------------------------------------------------------------------------------------------------ +| 0 | SELECT STATEMENT | | | | 9 (100)| | | | +| 1 | SORT AGGREGATE | | 1 | 4 | | | | | +| 2 | PARTITION RANGE SINGLE| | 1 | 4 | 9 (0)| 00:00:01 | 1 | 1 | +|* 3 | TABLE ACCESS FULL | T2 | 1 | 4 | 9 (0)| 00:00:01 | 1 | 1 | +------------------------------------------------------------------------------------------------ + +Predicate Information (identified by operation id): +--------------------------------------------------- + + 3 - filter("ID"=1) + + +20 rows selected. + + + COUNT(*) +---------- + 0 + + +PLAN_TABLE_OUTPUT +------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ +SQL_ID dcvq5bcm8yqm9, child number 0 +------------------------------------- +select /* TESTFG */ count(*) from t2 where id = 1+150000 + +Plan hash value: 2457353553 + +------------------------------------------------------------------------------------------------ +| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time | Pstart| Pstop | +------------------------------------------------------------------------------------------------ +| 0 | SELECT STATEMENT | | | | 9 (100)| | | | +| 1 | SORT AGGREGATE | | 1 | 5 | | | | | +| 2 | PARTITION RANGE SINGLE| | 1 | 5 | 9 (0)| 00:00:01 | 2 | 2 | +|* 3 | TABLE ACCESS FULL | T2 | 1 | 5 | 9 (0)| 00:00:01 | 2 | 2 | +------------------------------------------------------------------------------------------------ + +Predicate Information (identified by operation id): +--------------------------------------------------- + + 3 - filter("ID"=150001) + + +20 rows selected. + + + COUNT(*) +---------- + 2 + + +PLAN_TABLE_OUTPUT +------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ +SQL_ID 9jh4ms6ruztw2, child number 0 +------------------------------------- +select /* TESTFG */ count(*) from t2 where val1 = 1 + +Plan hash value: 611317447 + +--------------------------------------------------------------------------------------------- +| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time | Pstart| Pstop | +--------------------------------------------------------------------------------------------- +| 0 | SELECT STATEMENT | | | | 16 (100)| | | | +| 1 | SORT AGGREGATE | | 1 | 4 | | | | | +| 2 | PARTITION RANGE ALL| | 2 | 8 | 16 (0)| 00:00:01 | 1 | 2 | +|* 3 | TABLE ACCESS FULL | T2 | 2 | 8 | 16 (0)| 00:00:01 | 1 | 2 | +--------------------------------------------------------------------------------------------- + +Predicate Information (identified by operation id): +--------------------------------------------------- + + 3 - filter("VAL1"=1) + + +20 rows selected. + + + SUM(VAL2) +---------- + 49995000 + + +PLAN_TABLE_OUTPUT +------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ +SQL_ID 31pkfzpmx1b62, child number 0 +------------------------------------- +select /* TESTFG */ /*+ INDEX_FFS(t new1) */ sum(val2) from t1 t + +Plan hash value: 3724264953 + +--------------------------------------------------------------------------- +| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time | +--------------------------------------------------------------------------- +| 0 | SELECT STATEMENT | | | | 9 (100)| | +| 1 | SORT AGGREGATE | | 1 | 4 | | | +| 2 | TABLE ACCESS FULL| T1 | 9999 | 39996 | 9 (0)| 00:00:01 | +--------------------------------------------------------------------------- + + +14 rows selected. + + + COUNT(*) +---------- + 9998 + + +PLAN_TABLE_OUTPUT +------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ +SQL_ID czjk2xd0vn20k, child number 0 +------------------------------------- +select /* TESTFG */ count(*) from t2 where id < (select max(id) from t1) + +Plan hash value: 771265474 + +-------------------------------------------------------------------------------------------------- +| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time | Pstart| Pstop | +-------------------------------------------------------------------------------------------------- +| 0 | SELECT STATEMENT | | | | 25 (100)| | | | +| 1 | SORT AGGREGATE | | 1 | 5 | | | | | +| 2 | PARTITION RANGE ITERATOR| | 1000 | 5000 | 16 (0)| 00:00:01 | 1 | KEY | +|* 3 | TABLE ACCESS FULL | T2 | 1000 | 5000 | 16 (0)| 00:00:01 | 1 | KEY | +| 4 | SORT AGGREGATE | | 1 | 4 | | | | | +| 5 | TABLE ACCESS FULL | T1 | 9999 | 39996 | 9 (0)| 00:00:01 | | | +-------------------------------------------------------------------------------------------------- + +Predicate Information (identified by operation id): +--------------------------------------------------- + + 3 - filter("ID"<) + + +22 rows selected. + + + COUNT(*) +---------- + 49 + + +PLAN_TABLE_OUTPUT +------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ +SQL_ID ax2r0jyjs0hbb, child number 0 +------------------------------------- +select /* TESTFG */ /*+ USE_INVISIBLE_INDEXES */ count(*) from t1 where +val2<50 + +Plan hash value: 3724264953 + +--------------------------------------------------------------------------- +| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time | +--------------------------------------------------------------------------- +| 0 | SELECT STATEMENT | | | | 9 (100)| | +| 1 | SORT AGGREGATE | | 1 | 4 | | | +|* 2 | TABLE ACCESS FULL| T1 | 49 | 196 | 9 (0)| 00:00:01 | +--------------------------------------------------------------------------- + +Predicate Information (identified by operation id): +--------------------------------------------------- + + 2 - filter("VAL2"<50) + + +20 rows selected. + + + COUNT(*) +---------- + 9999 + + +PLAN_TABLE_OUTPUT +------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ +SQL_ID 7c65qbgku7can, child number 0 +------------------------------------- +select /* TESTFG */ count(*) from t2 partition (p2) + +Plan hash value: 2457353553 + +---------------------------------------------------------------------------------------- +| Id | Operation | Name | Rows | Cost (%CPU)| Time | Pstart| Pstop | +---------------------------------------------------------------------------------------- +| 0 | SELECT STATEMENT | | | 9 (100)| | | | +| 1 | SORT AGGREGATE | | 1 | | | | | +| 2 | PARTITION RANGE SINGLE| | 9999 | 9 (0)| 00:00:01 | 2 | 2 | +| 3 | TABLE ACCESS FULL | T2 | 9999 | 9 (0)| 00:00:01 | 2 | 2 | +---------------------------------------------------------------------------------------- + + +15 rows selected. + + + COUNT(*) +---------- + 9999 + + +PLAN_TABLE_OUTPUT +------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ +SQL_ID 221p0y74xg65x, child number 0 +------------------------------------- +select /* TESTFG */ count(*) from t2 partition (p1) + +Plan hash value: 2457353553 + +---------------------------------------------------------------------------------------- +| Id | Operation | Name | Rows | Cost (%CPU)| Time | Pstart| Pstop | +---------------------------------------------------------------------------------------- +| 0 | SELECT STATEMENT | | | 9 (100)| | | | +| 1 | SORT AGGREGATE | | 1 | | | | | +| 2 | PARTITION RANGE SINGLE| | 9999 | 9 (0)| 00:00:01 | 1 | 1 | +| 3 | TABLE ACCESS FULL | T2 | 9999 | 9 (0)| 00:00:01 | 1 | 1 | +---------------------------------------------------------------------------------------- + + +15 rows selected. + + +49 rows updated. + + +98 rows updated. + + +49 rows updated. + + +49 rows updated. + + +Commit complete. + + +SQL_ID SQL_TEXT CHILD_NUMBER IS_SHAREABLE OBJECT_STATUS INVALIDATIONS IS_ROLLING_INVALID IS_ROLLING_REFRESH_I DDL_NO_INVALIDATE +------------- ------------------------------------------------------------------------------------- ------------ -------------------- ------------------- ------------- -------------------- -------------------- -------------------- +31pkfzpmx1b62 select /* TESTFG */ /*+ INDEX_FFS(t new1) */ sum(val2) from t1 t 0 Y VALID 0 N N N +ax2r0jyjs0hbb select /* TESTFG */ /*+ USE_INVISIBLE_INDEXES */ count(*) from t1 where val2<50 0 Y VALID 0 N N N +cf016xd0knzrh select /* TESTFG */ count(*) from t1 where id = 1 0 Y VALID 0 N N N +gvd4z9ba14uh3 select /* TESTFG */ count(*) from t1 where val1 = 1 0 Y VALID 0 N N N +221p0y74xg65x select /* TESTFG */ count(*) from t2 partition (p1) 0 Y VALID 0 N N N +7c65qbgku7can select /* TESTFG */ count(*) from t2 partition (p2) 0 Y VALID 0 N N N +czjk2xd0vn20k select /* TESTFG */ count(*) from t2 where id < (select max(id) from t1) 0 Y VALID 0 N N N +1y9y6gg3r5sry select /* TESTFG */ count(*) from t2 where id = 1 0 Y VALID 0 N N N +dcvq5bcm8yqm9 select /* TESTFG */ count(*) from t2 where id = 1+150000 0 Y VALID 0 N N N +9jh4ms6ruztw2 select /* TESTFG */ count(*) from t2 where val1 = 1 0 Y VALID 0 N N N +bcsj7p128xh77 update /* TESTFG */ t1 set val1 = val1 + 1 where id < 50 0 Y VALID 0 N N N +bdhfwydh894qk update /* TESTFG */ t1 set val1 = val1 + 1 where val1 < 50 0 Y VALID 0 N N N +6a6m4fq5b9v7r update /* TESTFG */ t2 set val1 = val1 + 1 where id < 50 0 Y VALID 0 N N N +24qkp15shu1gp update /* TESTFG */ t2 set val1 = val1 + 1 where val1 < 50 0 Y VALID 0 N N N + +14 rows selected. + + +no rows selected + +SQL> -- +SQL> -- MOVE TABLE/PARTITION +SQL> -- +SQL> -- ## NOTE Accepted but might not implemented... +SQL> alter table t1 move deferred invalidation; + +Table altered. + +SQL> alter table t2 move partition p1 deferred invalidation; + +Table altered. + +SQL> set echo off +### Truncate partition is fine-grained, but truncate table is not + +SQL_ID SQL_TEXT CHILD_NUMBER IS_SHAREABLE OBJECT_STATUS INVALIDATIONS IS_ROLLING_INVALID IS_ROLLING_REFRESH_I DDL_NO_INVALIDATE +------------- ------------------------------------------------------------------------------------- ------------ -------------------- ------------------- ------------- -------------------- -------------------- -------------------- +31pkfzpmx1b62 select /* TESTFG */ /*+ INDEX_FFS(t new1) */ sum(val2) from t1 t 0 Y INVALID_UNAUTH 1 N N N +ax2r0jyjs0hbb select /* TESTFG */ /*+ USE_INVISIBLE_INDEXES */ count(*) from t1 where val2<50 0 Y INVALID_UNAUTH 1 N N N +cf016xd0knzrh select /* TESTFG */ count(*) from t1 where id = 1 0 Y INVALID_UNAUTH 1 N N N +gvd4z9ba14uh3 select /* TESTFG */ count(*) from t1 where val1 = 1 0 Y INVALID_UNAUTH 1 N N N +221p0y74xg65x select /* TESTFG */ count(*) from t2 partition (p1) 0 Y VALID 0 N Y N +7c65qbgku7can select /* TESTFG */ count(*) from t2 partition (p2) 0 Y VALID 0 N Y N +czjk2xd0vn20k select /* TESTFG */ count(*) from t2 where id < (select max(id) from t1) 0 Y INVALID_UNAUTH 1 N N N +1y9y6gg3r5sry select /* TESTFG */ count(*) from t2 where id = 1 0 Y VALID 0 N Y N +dcvq5bcm8yqm9 select /* TESTFG */ count(*) from t2 where id = 1+150000 0 Y VALID 0 N Y N +9jh4ms6ruztw2 select /* TESTFG */ count(*) from t2 where val1 = 1 0 Y VALID 0 N Y N +bcsj7p128xh77 update /* TESTFG */ t1 set val1 = val1 + 1 where id < 50 0 Y INVALID_UNAUTH 1 N N N +bdhfwydh894qk update /* TESTFG */ t1 set val1 = val1 + 1 where val1 < 50 0 Y INVALID_UNAUTH 1 N N N +6a6m4fq5b9v7r update /* TESTFG */ t2 set val1 = val1 + 1 where id < 50 0 Y VALID 0 N Y N +24qkp15shu1gp update /* TESTFG */ t2 set val1 = val1 + 1 where val1 < 50 0 Y VALID 0 N Y N + +14 rows selected. + + +no rows selected + + +Table dropped. + + +Table dropped. + + +Table created. + + +Table created. + + +9999 rows created. + + +9999 rows created. + + +9999 rows created. + + +Index created. + + +Index created. + + +PL/SQL procedure successfully completed. + + +PL/SQL procedure successfully completed. + +Get rid of indexes... +SQL> drop index t1i; + +Index dropped. + +SQL> drop index t2i; + +Index dropped. + +SQL> set echo off + +System altered. + + + COUNT(*) +---------- + 1 + + +PLAN_TABLE_OUTPUT +------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ +SQL_ID cf016xd0knzrh, child number 0 +------------------------------------- +select /* TESTFG */ count(*) from t1 where id = 1 + +Plan hash value: 3724264953 + +--------------------------------------------------------------------------- +| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time | +--------------------------------------------------------------------------- +| 0 | SELECT STATEMENT | | | | 9 (100)| | +| 1 | SORT AGGREGATE | | 1 | 4 | | | +|* 2 | TABLE ACCESS FULL| T1 | 1 | 4 | 9 (0)| 00:00:01 | +--------------------------------------------------------------------------- + +Predicate Information (identified by operation id): +--------------------------------------------------- + + 2 - filter("ID"=1) + + +19 rows selected. + + + COUNT(*) +---------- + 1 + + +PLAN_TABLE_OUTPUT +------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ +SQL_ID gvd4z9ba14uh3, child number 0 +------------------------------------- +select /* TESTFG */ count(*) from t1 where val1 = 1 + +Plan hash value: 3724264953 + +--------------------------------------------------------------------------- +| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time | +--------------------------------------------------------------------------- +| 0 | SELECT STATEMENT | | | | 9 (100)| | +| 1 | SORT AGGREGATE | | 1 | 4 | | | +|* 2 | TABLE ACCESS FULL| T1 | 1 | 4 | 9 (0)| 00:00:01 | +--------------------------------------------------------------------------- + +Predicate Information (identified by operation id): +--------------------------------------------------- + + 2 - filter("VAL1"=1) + + +19 rows selected. + + + COUNT(*) +---------- + 1 + + +PLAN_TABLE_OUTPUT +------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ +SQL_ID 1y9y6gg3r5sry, child number 0 +------------------------------------- +select /* TESTFG */ count(*) from t2 where id = 1 + +Plan hash value: 2457353553 + +------------------------------------------------------------------------------------------------ +| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time | Pstart| Pstop | +------------------------------------------------------------------------------------------------ +| 0 | SELECT STATEMENT | | | | 9 (100)| | | | +| 1 | SORT AGGREGATE | | 1 | 4 | | | | | +| 2 | PARTITION RANGE SINGLE| | 1 | 4 | 9 (0)| 00:00:01 | 1 | 1 | +|* 3 | TABLE ACCESS FULL | T2 | 1 | 4 | 9 (0)| 00:00:01 | 1 | 1 | +------------------------------------------------------------------------------------------------ + +Predicate Information (identified by operation id): +--------------------------------------------------- + + 3 - filter("ID"=1) + + +20 rows selected. + + + COUNT(*) +---------- + 0 + + +PLAN_TABLE_OUTPUT +------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ +SQL_ID dcvq5bcm8yqm9, child number 0 +------------------------------------- +select /* TESTFG */ count(*) from t2 where id = 1+150000 + +Plan hash value: 2457353553 + +------------------------------------------------------------------------------------------------ +| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time | Pstart| Pstop | +------------------------------------------------------------------------------------------------ +| 0 | SELECT STATEMENT | | | | 9 (100)| | | | +| 1 | SORT AGGREGATE | | 1 | 5 | | | | | +| 2 | PARTITION RANGE SINGLE| | 1 | 5 | 9 (0)| 00:00:01 | 2 | 2 | +|* 3 | TABLE ACCESS FULL | T2 | 1 | 5 | 9 (0)| 00:00:01 | 2 | 2 | +------------------------------------------------------------------------------------------------ + +Predicate Information (identified by operation id): +--------------------------------------------------- + + 3 - filter("ID"=150001) + + +20 rows selected. + + + COUNT(*) +---------- + 2 + + +PLAN_TABLE_OUTPUT +------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ +SQL_ID 9jh4ms6ruztw2, child number 0 +------------------------------------- +select /* TESTFG */ count(*) from t2 where val1 = 1 + +Plan hash value: 611317447 + +--------------------------------------------------------------------------------------------- +| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time | Pstart| Pstop | +--------------------------------------------------------------------------------------------- +| 0 | SELECT STATEMENT | | | | 16 (100)| | | | +| 1 | SORT AGGREGATE | | 1 | 4 | | | | | +| 2 | PARTITION RANGE ALL| | 2 | 8 | 16 (0)| 00:00:01 | 1 | 2 | +|* 3 | TABLE ACCESS FULL | T2 | 2 | 8 | 16 (0)| 00:00:01 | 1 | 2 | +--------------------------------------------------------------------------------------------- + +Predicate Information (identified by operation id): +--------------------------------------------------- + + 3 - filter("VAL1"=1) + + +20 rows selected. + + + SUM(VAL2) +---------- + 49995000 + + +PLAN_TABLE_OUTPUT +------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ +SQL_ID 31pkfzpmx1b62, child number 0 +------------------------------------- +select /* TESTFG */ /*+ INDEX_FFS(t new1) */ sum(val2) from t1 t + +Plan hash value: 3724264953 + +--------------------------------------------------------------------------- +| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time | +--------------------------------------------------------------------------- +| 0 | SELECT STATEMENT | | | | 9 (100)| | +| 1 | SORT AGGREGATE | | 1 | 4 | | | +| 2 | TABLE ACCESS FULL| T1 | 9999 | 39996 | 9 (0)| 00:00:01 | +--------------------------------------------------------------------------- + + +14 rows selected. + + + COUNT(*) +---------- + 9998 + + +PLAN_TABLE_OUTPUT +------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ +SQL_ID czjk2xd0vn20k, child number 0 +------------------------------------- +select /* TESTFG */ count(*) from t2 where id < (select max(id) from t1) + +Plan hash value: 771265474 + +-------------------------------------------------------------------------------------------------- +| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time | Pstart| Pstop | +-------------------------------------------------------------------------------------------------- +| 0 | SELECT STATEMENT | | | | 25 (100)| | | | +| 1 | SORT AGGREGATE | | 1 | 5 | | | | | +| 2 | PARTITION RANGE ITERATOR| | 1000 | 5000 | 16 (0)| 00:00:01 | 1 | KEY | +|* 3 | TABLE ACCESS FULL | T2 | 1000 | 5000 | 16 (0)| 00:00:01 | 1 | KEY | +| 4 | SORT AGGREGATE | | 1 | 4 | | | | | +| 5 | TABLE ACCESS FULL | T1 | 9999 | 39996 | 9 (0)| 00:00:01 | | | +-------------------------------------------------------------------------------------------------- + +Predicate Information (identified by operation id): +--------------------------------------------------- + + 3 - filter("ID"<) + + +22 rows selected. + + + COUNT(*) +---------- + 49 + + +PLAN_TABLE_OUTPUT +------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ +SQL_ID ax2r0jyjs0hbb, child number 0 +------------------------------------- +select /* TESTFG */ /*+ USE_INVISIBLE_INDEXES */ count(*) from t1 where +val2<50 + +Plan hash value: 3724264953 + +--------------------------------------------------------------------------- +| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time | +--------------------------------------------------------------------------- +| 0 | SELECT STATEMENT | | | | 9 (100)| | +| 1 | SORT AGGREGATE | | 1 | 4 | | | +|* 2 | TABLE ACCESS FULL| T1 | 49 | 196 | 9 (0)| 00:00:01 | +--------------------------------------------------------------------------- + +Predicate Information (identified by operation id): +--------------------------------------------------- + + 2 - filter("VAL2"<50) + + +20 rows selected. + + + COUNT(*) +---------- + 9999 + + +PLAN_TABLE_OUTPUT +------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ +SQL_ID 7c65qbgku7can, child number 0 +------------------------------------- +select /* TESTFG */ count(*) from t2 partition (p2) + +Plan hash value: 2457353553 + +---------------------------------------------------------------------------------------- +| Id | Operation | Name | Rows | Cost (%CPU)| Time | Pstart| Pstop | +---------------------------------------------------------------------------------------- +| 0 | SELECT STATEMENT | | | 9 (100)| | | | +| 1 | SORT AGGREGATE | | 1 | | | | | +| 2 | PARTITION RANGE SINGLE| | 9999 | 9 (0)| 00:00:01 | 2 | 2 | +| 3 | TABLE ACCESS FULL | T2 | 9999 | 9 (0)| 00:00:01 | 2 | 2 | +---------------------------------------------------------------------------------------- + + +15 rows selected. + + + COUNT(*) +---------- + 9999 + + +PLAN_TABLE_OUTPUT +------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ +SQL_ID 221p0y74xg65x, child number 0 +------------------------------------- +select /* TESTFG */ count(*) from t2 partition (p1) + +Plan hash value: 2457353553 + +---------------------------------------------------------------------------------------- +| Id | Operation | Name | Rows | Cost (%CPU)| Time | Pstart| Pstop | +---------------------------------------------------------------------------------------- +| 0 | SELECT STATEMENT | | | 9 (100)| | | | +| 1 | SORT AGGREGATE | | 1 | | | | | +| 2 | PARTITION RANGE SINGLE| | 9999 | 9 (0)| 00:00:01 | 1 | 1 | +| 3 | TABLE ACCESS FULL | T2 | 9999 | 9 (0)| 00:00:01 | 1 | 1 | +---------------------------------------------------------------------------------------- + + +15 rows selected. + + +49 rows updated. + + +98 rows updated. + + +49 rows updated. + + +49 rows updated. + + +Commit complete. + + +SQL_ID SQL_TEXT CHILD_NUMBER IS_SHAREABLE OBJECT_STATUS INVALIDATIONS IS_ROLLING_INVALID IS_ROLLING_REFRESH_I DDL_NO_INVALIDATE +------------- ------------------------------------------------------------------------------------- ------------ -------------------- ------------------- ------------- -------------------- -------------------- -------------------- +31pkfzpmx1b62 select /* TESTFG */ /*+ INDEX_FFS(t new1) */ sum(val2) from t1 t 0 Y VALID 0 N N N +ax2r0jyjs0hbb select /* TESTFG */ /*+ USE_INVISIBLE_INDEXES */ count(*) from t1 where val2<50 0 Y VALID 0 N N N +cf016xd0knzrh select /* TESTFG */ count(*) from t1 where id = 1 0 Y VALID 0 N N N +gvd4z9ba14uh3 select /* TESTFG */ count(*) from t1 where val1 = 1 0 Y VALID 0 N N N +221p0y74xg65x select /* TESTFG */ count(*) from t2 partition (p1) 0 Y VALID 0 N N N +7c65qbgku7can select /* TESTFG */ count(*) from t2 partition (p2) 0 Y VALID 0 N N N +czjk2xd0vn20k select /* TESTFG */ count(*) from t2 where id < (select max(id) from t1) 0 Y VALID 0 N N N +1y9y6gg3r5sry select /* TESTFG */ count(*) from t2 where id = 1 0 Y VALID 0 N N N +dcvq5bcm8yqm9 select /* TESTFG */ count(*) from t2 where id = 1+150000 0 Y VALID 0 N N N +9jh4ms6ruztw2 select /* TESTFG */ count(*) from t2 where val1 = 1 0 Y VALID 0 N N N +bcsj7p128xh77 update /* TESTFG */ t1 set val1 = val1 + 1 where id < 50 0 Y VALID 0 N N N +bdhfwydh894qk update /* TESTFG */ t1 set val1 = val1 + 1 where val1 < 50 0 Y VALID 0 N N N +6a6m4fq5b9v7r update /* TESTFG */ t2 set val1 = val1 + 1 where id < 50 0 Y VALID 0 N N N +24qkp15shu1gp update /* TESTFG */ t2 set val1 = val1 + 1 where val1 < 50 0 Y VALID 0 N N N + +14 rows selected. + + +no rows selected + +SQL> -- +SQL> -- MOVE TABLE/PARTITION +SQL> -- +SQL> -- ## NOTE Accepted but might not be implemented... +SQL> alter table t1 move deferred invalidation; + +Table altered. + +SQL> alter table t2 move deferred invalidation; +alter table t2 move deferred invalidation + * +ERROR at line 1: +ORA-14511: cannot perform operation on a partitioned object + + +SQL> set echo off + +SQL_ID SQL_TEXT CHILD_NUMBER IS_SHAREABLE OBJECT_STATUS INVALIDATIONS IS_ROLLING_INVALID IS_ROLLING_REFRESH_I DDL_NO_INVALIDATE +------------- ------------------------------------------------------------------------------------- ------------ -------------------- ------------------- ------------- -------------------- -------------------- -------------------- +31pkfzpmx1b62 select /* TESTFG */ /*+ INDEX_FFS(t new1) */ sum(val2) from t1 t 0 Y INVALID_UNAUTH 1 N N N +ax2r0jyjs0hbb select /* TESTFG */ /*+ USE_INVISIBLE_INDEXES */ count(*) from t1 where val2<50 0 Y INVALID_UNAUTH 1 N N N +cf016xd0knzrh select /* TESTFG */ count(*) from t1 where id = 1 0 Y INVALID_UNAUTH 1 N N N +gvd4z9ba14uh3 select /* TESTFG */ count(*) from t1 where val1 = 1 0 Y INVALID_UNAUTH 1 N N N +221p0y74xg65x select /* TESTFG */ count(*) from t2 partition (p1) 0 Y VALID 0 N N N +7c65qbgku7can select /* TESTFG */ count(*) from t2 partition (p2) 0 Y VALID 0 N N N +czjk2xd0vn20k select /* TESTFG */ count(*) from t2 where id < (select max(id) from t1) 0 Y INVALID_UNAUTH 1 N N N +1y9y6gg3r5sry select /* TESTFG */ count(*) from t2 where id = 1 0 Y VALID 0 N N N +dcvq5bcm8yqm9 select /* TESTFG */ count(*) from t2 where id = 1+150000 0 Y VALID 0 N N N +9jh4ms6ruztw2 select /* TESTFG */ count(*) from t2 where val1 = 1 0 Y VALID 0 N N N +bcsj7p128xh77 update /* TESTFG */ t1 set val1 = val1 + 1 where id < 50 0 Y INVALID_UNAUTH 1 N N N +bdhfwydh894qk update /* TESTFG */ t1 set val1 = val1 + 1 where val1 < 50 0 Y INVALID_UNAUTH 1 N N N +6a6m4fq5b9v7r update /* TESTFG */ t2 set val1 = val1 + 1 where id < 50 0 Y VALID 0 N N N +24qkp15shu1gp update /* TESTFG */ t2 set val1 = val1 + 1 where val1 < 50 0 Y VALID 0 N N N + +14 rows selected. + + +no rows selected + + +Table dropped. + + +Table dropped. + + +Table created. + + +Table created. + + +9999 rows created. + + +9999 rows created. + + +9999 rows created. + + +Index created. + + +Index created. + + +PL/SQL procedure successfully completed. + + +PL/SQL procedure successfully completed. + +Get rid of indexes... +SQL> drop index t1i; + +Index dropped. + +SQL> drop index t2i; + +Index dropped. + +SQL> set echo off + +System altered. + + + COUNT(*) +---------- + 1 + + +PLAN_TABLE_OUTPUT +------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ +SQL_ID cf016xd0knzrh, child number 0 +------------------------------------- +select /* TESTFG */ count(*) from t1 where id = 1 + +Plan hash value: 3724264953 + +--------------------------------------------------------------------------- +| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time | +--------------------------------------------------------------------------- +| 0 | SELECT STATEMENT | | | | 9 (100)| | +| 1 | SORT AGGREGATE | | 1 | 4 | | | +|* 2 | TABLE ACCESS FULL| T1 | 1 | 4 | 9 (0)| 00:00:01 | +--------------------------------------------------------------------------- + +Predicate Information (identified by operation id): +--------------------------------------------------- + + 2 - filter("ID"=1) + + +19 rows selected. + + + COUNT(*) +---------- + 1 + + +PLAN_TABLE_OUTPUT +------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ +SQL_ID gvd4z9ba14uh3, child number 0 +------------------------------------- +select /* TESTFG */ count(*) from t1 where val1 = 1 + +Plan hash value: 3724264953 + +--------------------------------------------------------------------------- +| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time | +--------------------------------------------------------------------------- +| 0 | SELECT STATEMENT | | | | 9 (100)| | +| 1 | SORT AGGREGATE | | 1 | 4 | | | +|* 2 | TABLE ACCESS FULL| T1 | 1 | 4 | 9 (0)| 00:00:01 | +--------------------------------------------------------------------------- + +Predicate Information (identified by operation id): +--------------------------------------------------- + + 2 - filter("VAL1"=1) + + +19 rows selected. + + + COUNT(*) +---------- + 1 + + +PLAN_TABLE_OUTPUT +------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ +SQL_ID 1y9y6gg3r5sry, child number 0 +------------------------------------- +select /* TESTFG */ count(*) from t2 where id = 1 + +Plan hash value: 2457353553 + +------------------------------------------------------------------------------------------------ +| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time | Pstart| Pstop | +------------------------------------------------------------------------------------------------ +| 0 | SELECT STATEMENT | | | | 9 (100)| | | | +| 1 | SORT AGGREGATE | | 1 | 4 | | | | | +| 2 | PARTITION RANGE SINGLE| | 1 | 4 | 9 (0)| 00:00:01 | 1 | 1 | +|* 3 | TABLE ACCESS FULL | T2 | 1 | 4 | 9 (0)| 00:00:01 | 1 | 1 | +------------------------------------------------------------------------------------------------ + +Predicate Information (identified by operation id): +--------------------------------------------------- + + 3 - filter("ID"=1) + + +20 rows selected. + + + COUNT(*) +---------- + 0 + + +PLAN_TABLE_OUTPUT +------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ +SQL_ID dcvq5bcm8yqm9, child number 0 +------------------------------------- +select /* TESTFG */ count(*) from t2 where id = 1+150000 + +Plan hash value: 2457353553 + +------------------------------------------------------------------------------------------------ +| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time | Pstart| Pstop | +------------------------------------------------------------------------------------------------ +| 0 | SELECT STATEMENT | | | | 9 (100)| | | | +| 1 | SORT AGGREGATE | | 1 | 5 | | | | | +| 2 | PARTITION RANGE SINGLE| | 1 | 5 | 9 (0)| 00:00:01 | 2 | 2 | +|* 3 | TABLE ACCESS FULL | T2 | 1 | 5 | 9 (0)| 00:00:01 | 2 | 2 | +------------------------------------------------------------------------------------------------ + +Predicate Information (identified by operation id): +--------------------------------------------------- + + 3 - filter("ID"=150001) + + +20 rows selected. + + + COUNT(*) +---------- + 2 + + +PLAN_TABLE_OUTPUT +------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ +SQL_ID 9jh4ms6ruztw2, child number 0 +------------------------------------- +select /* TESTFG */ count(*) from t2 where val1 = 1 + +Plan hash value: 611317447 + +--------------------------------------------------------------------------------------------- +| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time | Pstart| Pstop | +--------------------------------------------------------------------------------------------- +| 0 | SELECT STATEMENT | | | | 16 (100)| | | | +| 1 | SORT AGGREGATE | | 1 | 4 | | | | | +| 2 | PARTITION RANGE ALL| | 2 | 8 | 16 (0)| 00:00:01 | 1 | 2 | +|* 3 | TABLE ACCESS FULL | T2 | 2 | 8 | 16 (0)| 00:00:01 | 1 | 2 | +--------------------------------------------------------------------------------------------- + +Predicate Information (identified by operation id): +--------------------------------------------------- + + 3 - filter("VAL1"=1) + + +20 rows selected. + + + SUM(VAL2) +---------- + 49995000 + + +PLAN_TABLE_OUTPUT +------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ +SQL_ID 31pkfzpmx1b62, child number 0 +------------------------------------- +select /* TESTFG */ /*+ INDEX_FFS(t new1) */ sum(val2) from t1 t + +Plan hash value: 3724264953 + +--------------------------------------------------------------------------- +| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time | +--------------------------------------------------------------------------- +| 0 | SELECT STATEMENT | | | | 9 (100)| | +| 1 | SORT AGGREGATE | | 1 | 4 | | | +| 2 | TABLE ACCESS FULL| T1 | 9999 | 39996 | 9 (0)| 00:00:01 | +--------------------------------------------------------------------------- + + +14 rows selected. + + + COUNT(*) +---------- + 9998 + + +PLAN_TABLE_OUTPUT +------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ +SQL_ID czjk2xd0vn20k, child number 0 +------------------------------------- +select /* TESTFG */ count(*) from t2 where id < (select max(id) from t1) + +Plan hash value: 771265474 + +-------------------------------------------------------------------------------------------------- +| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time | Pstart| Pstop | +-------------------------------------------------------------------------------------------------- +| 0 | SELECT STATEMENT | | | | 25 (100)| | | | +| 1 | SORT AGGREGATE | | 1 | 5 | | | | | +| 2 | PARTITION RANGE ITERATOR| | 1000 | 5000 | 16 (0)| 00:00:01 | 1 | KEY | +|* 3 | TABLE ACCESS FULL | T2 | 1000 | 5000 | 16 (0)| 00:00:01 | 1 | KEY | +| 4 | SORT AGGREGATE | | 1 | 4 | | | | | +| 5 | TABLE ACCESS FULL | T1 | 9999 | 39996 | 9 (0)| 00:00:01 | | | +-------------------------------------------------------------------------------------------------- + +Predicate Information (identified by operation id): +--------------------------------------------------- + + 3 - filter("ID"<) + + +22 rows selected. + + + COUNT(*) +---------- + 49 + + +PLAN_TABLE_OUTPUT +------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ +SQL_ID ax2r0jyjs0hbb, child number 0 +------------------------------------- +select /* TESTFG */ /*+ USE_INVISIBLE_INDEXES */ count(*) from t1 where +val2<50 + +Plan hash value: 3724264953 + +--------------------------------------------------------------------------- +| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time | +--------------------------------------------------------------------------- +| 0 | SELECT STATEMENT | | | | 9 (100)| | +| 1 | SORT AGGREGATE | | 1 | 4 | | | +|* 2 | TABLE ACCESS FULL| T1 | 49 | 196 | 9 (0)| 00:00:01 | +--------------------------------------------------------------------------- + +Predicate Information (identified by operation id): +--------------------------------------------------- + + 2 - filter("VAL2"<50) + + +20 rows selected. + + + COUNT(*) +---------- + 9999 + + +PLAN_TABLE_OUTPUT +------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ +SQL_ID 7c65qbgku7can, child number 0 +------------------------------------- +select /* TESTFG */ count(*) from t2 partition (p2) + +Plan hash value: 2457353553 + +---------------------------------------------------------------------------------------- +| Id | Operation | Name | Rows | Cost (%CPU)| Time | Pstart| Pstop | +---------------------------------------------------------------------------------------- +| 0 | SELECT STATEMENT | | | 9 (100)| | | | +| 1 | SORT AGGREGATE | | 1 | | | | | +| 2 | PARTITION RANGE SINGLE| | 9999 | 9 (0)| 00:00:01 | 2 | 2 | +| 3 | TABLE ACCESS FULL | T2 | 9999 | 9 (0)| 00:00:01 | 2 | 2 | +---------------------------------------------------------------------------------------- + + +15 rows selected. + + + COUNT(*) +---------- + 9999 + + +PLAN_TABLE_OUTPUT +------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ +SQL_ID 221p0y74xg65x, child number 0 +------------------------------------- +select /* TESTFG */ count(*) from t2 partition (p1) + +Plan hash value: 2457353553 + +---------------------------------------------------------------------------------------- +| Id | Operation | Name | Rows | Cost (%CPU)| Time | Pstart| Pstop | +---------------------------------------------------------------------------------------- +| 0 | SELECT STATEMENT | | | 9 (100)| | | | +| 1 | SORT AGGREGATE | | 1 | | | | | +| 2 | PARTITION RANGE SINGLE| | 9999 | 9 (0)| 00:00:01 | 1 | 1 | +| 3 | TABLE ACCESS FULL | T2 | 9999 | 9 (0)| 00:00:01 | 1 | 1 | +---------------------------------------------------------------------------------------- + + +15 rows selected. + + +49 rows updated. + + +98 rows updated. + + +49 rows updated. + + +49 rows updated. + + +Commit complete. + + +SQL_ID SQL_TEXT CHILD_NUMBER IS_SHAREABLE OBJECT_STATUS INVALIDATIONS IS_ROLLING_INVALID IS_ROLLING_REFRESH_I DDL_NO_INVALIDATE +------------- ------------------------------------------------------------------------------------- ------------ -------------------- ------------------- ------------- -------------------- -------------------- -------------------- +31pkfzpmx1b62 select /* TESTFG */ /*+ INDEX_FFS(t new1) */ sum(val2) from t1 t 0 Y VALID 0 N N N +ax2r0jyjs0hbb select /* TESTFG */ /*+ USE_INVISIBLE_INDEXES */ count(*) from t1 where val2<50 0 Y VALID 0 N N N +cf016xd0knzrh select /* TESTFG */ count(*) from t1 where id = 1 0 Y VALID 0 N N N +gvd4z9ba14uh3 select /* TESTFG */ count(*) from t1 where val1 = 1 0 Y VALID 0 N N N +221p0y74xg65x select /* TESTFG */ count(*) from t2 partition (p1) 0 Y VALID 0 N N N +7c65qbgku7can select /* TESTFG */ count(*) from t2 partition (p2) 0 Y VALID 0 N N N +czjk2xd0vn20k select /* TESTFG */ count(*) from t2 where id < (select max(id) from t1) 0 Y VALID 0 N N N +1y9y6gg3r5sry select /* TESTFG */ count(*) from t2 where id = 1 0 Y VALID 0 N N N +dcvq5bcm8yqm9 select /* TESTFG */ count(*) from t2 where id = 1+150000 0 Y VALID 0 N N N +9jh4ms6ruztw2 select /* TESTFG */ count(*) from t2 where val1 = 1 0 Y VALID 0 N N N +bcsj7p128xh77 update /* TESTFG */ t1 set val1 = val1 + 1 where id < 50 0 Y VALID 0 N N N +bdhfwydh894qk update /* TESTFG */ t1 set val1 = val1 + 1 where val1 < 50 0 Y VALID 0 N N N +6a6m4fq5b9v7r update /* TESTFG */ t2 set val1 = val1 + 1 where id < 50 0 Y VALID 0 N N N +24qkp15shu1gp update /* TESTFG */ t2 set val1 = val1 + 1 where val1 < 50 0 Y VALID 0 N N N + +14 rows selected. + + +no rows selected + +SQL> -- +SQL> -- TRUNCATE NON-PARTITIONED VS PARTITIONED TABLE +SQL> -- +SQL> -- ## NOTE Accepted but might not implemented for non-partitioned table +SQL> truncate table t1 deferred invalidation; + +Table truncated. + +SQL> truncate table t2 deferred invalidation; + +Table truncated. + +SQL> set echo off +### Truncate partition is fine-grained, but truncate table is not + +SQL_ID SQL_TEXT CHILD_NUMBER IS_SHAREABLE OBJECT_STATUS INVALIDATIONS IS_ROLLING_INVALID IS_ROLLING_REFRESH_I DDL_NO_INVALIDATE +------------- ------------------------------------------------------------------------------------- ------------ -------------------- ------------------- ------------- -------------------- -------------------- -------------------- +31pkfzpmx1b62 select /* TESTFG */ /*+ INDEX_FFS(t new1) */ sum(val2) from t1 t 0 Y INVALID_UNAUTH 1 N N N +ax2r0jyjs0hbb select /* TESTFG */ /*+ USE_INVISIBLE_INDEXES */ count(*) from t1 where val2<50 0 Y INVALID_UNAUTH 1 N N N +cf016xd0knzrh select /* TESTFG */ count(*) from t1 where id = 1 0 Y INVALID_UNAUTH 1 N N N +gvd4z9ba14uh3 select /* TESTFG */ count(*) from t1 where val1 = 1 0 Y INVALID_UNAUTH 1 N N N +221p0y74xg65x select /* TESTFG */ count(*) from t2 partition (p1) 0 Y VALID 0 N Y N +7c65qbgku7can select /* TESTFG */ count(*) from t2 partition (p2) 0 Y VALID 0 N Y N +czjk2xd0vn20k select /* TESTFG */ count(*) from t2 where id < (select max(id) from t1) 0 Y INVALID_UNAUTH 1 N N N +1y9y6gg3r5sry select /* TESTFG */ count(*) from t2 where id = 1 0 Y VALID 0 N Y N +dcvq5bcm8yqm9 select /* TESTFG */ count(*) from t2 where id = 1+150000 0 Y VALID 0 N Y N +9jh4ms6ruztw2 select /* TESTFG */ count(*) from t2 where val1 = 1 0 Y VALID 0 N Y N +bcsj7p128xh77 update /* TESTFG */ t1 set val1 = val1 + 1 where id < 50 0 Y INVALID_UNAUTH 1 N N N +bdhfwydh894qk update /* TESTFG */ t1 set val1 = val1 + 1 where val1 < 50 0 Y INVALID_UNAUTH 1 N N N +6a6m4fq5b9v7r update /* TESTFG */ t2 set val1 = val1 + 1 where id < 50 0 Y VALID 0 N Y N +24qkp15shu1gp update /* TESTFG */ t2 set val1 = val1 + 1 where val1 < 50 0 Y VALID 0 N Y N + +14 rows selected. + + +no rows selected + + +Table dropped. + + +Table dropped. + + +Table created. + + +Table created. + + +9999 rows created. + + +9999 rows created. + + +9999 rows created. + + +Index created. + + +Index created. + + +PL/SQL procedure successfully completed. + + +PL/SQL procedure successfully completed. + +Get rid of indexes... +SQL> drop index t1i; + +Index dropped. + +SQL> drop index t2i; + +Index dropped. + +SQL> set echo off + +System altered. + + + COUNT(*) +---------- + 1 + + +PLAN_TABLE_OUTPUT +------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ +SQL_ID cf016xd0knzrh, child number 0 +------------------------------------- +select /* TESTFG */ count(*) from t1 where id = 1 + +Plan hash value: 3724264953 + +--------------------------------------------------------------------------- +| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time | +--------------------------------------------------------------------------- +| 0 | SELECT STATEMENT | | | | 9 (100)| | +| 1 | SORT AGGREGATE | | 1 | 4 | | | +|* 2 | TABLE ACCESS FULL| T1 | 1 | 4 | 9 (0)| 00:00:01 | +--------------------------------------------------------------------------- + +Predicate Information (identified by operation id): +--------------------------------------------------- + + 2 - filter("ID"=1) + + +19 rows selected. + + + COUNT(*) +---------- + 1 + + +PLAN_TABLE_OUTPUT +------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ +SQL_ID gvd4z9ba14uh3, child number 0 +------------------------------------- +select /* TESTFG */ count(*) from t1 where val1 = 1 + +Plan hash value: 3724264953 + +--------------------------------------------------------------------------- +| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time | +--------------------------------------------------------------------------- +| 0 | SELECT STATEMENT | | | | 9 (100)| | +| 1 | SORT AGGREGATE | | 1 | 4 | | | +|* 2 | TABLE ACCESS FULL| T1 | 1 | 4 | 9 (0)| 00:00:01 | +--------------------------------------------------------------------------- + +Predicate Information (identified by operation id): +--------------------------------------------------- + + 2 - filter("VAL1"=1) + + +19 rows selected. + + + COUNT(*) +---------- + 1 + + +PLAN_TABLE_OUTPUT +------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ +SQL_ID 1y9y6gg3r5sry, child number 0 +------------------------------------- +select /* TESTFG */ count(*) from t2 where id = 1 + +Plan hash value: 2457353553 + +------------------------------------------------------------------------------------------------ +| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time | Pstart| Pstop | +------------------------------------------------------------------------------------------------ +| 0 | SELECT STATEMENT | | | | 9 (100)| | | | +| 1 | SORT AGGREGATE | | 1 | 4 | | | | | +| 2 | PARTITION RANGE SINGLE| | 1 | 4 | 9 (0)| 00:00:01 | 1 | 1 | +|* 3 | TABLE ACCESS FULL | T2 | 1 | 4 | 9 (0)| 00:00:01 | 1 | 1 | +------------------------------------------------------------------------------------------------ + +Predicate Information (identified by operation id): +--------------------------------------------------- + + 3 - filter("ID"=1) + + +20 rows selected. + + + COUNT(*) +---------- + 0 + + +PLAN_TABLE_OUTPUT +------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ +SQL_ID dcvq5bcm8yqm9, child number 0 +------------------------------------- +select /* TESTFG */ count(*) from t2 where id = 1+150000 + +Plan hash value: 2457353553 + +------------------------------------------------------------------------------------------------ +| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time | Pstart| Pstop | +------------------------------------------------------------------------------------------------ +| 0 | SELECT STATEMENT | | | | 9 (100)| | | | +| 1 | SORT AGGREGATE | | 1 | 5 | | | | | +| 2 | PARTITION RANGE SINGLE| | 1 | 5 | 9 (0)| 00:00:01 | 2 | 2 | +|* 3 | TABLE ACCESS FULL | T2 | 1 | 5 | 9 (0)| 00:00:01 | 2 | 2 | +------------------------------------------------------------------------------------------------ + +Predicate Information (identified by operation id): +--------------------------------------------------- + + 3 - filter("ID"=150001) + + +20 rows selected. + + + COUNT(*) +---------- + 2 + + +PLAN_TABLE_OUTPUT +------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ +SQL_ID 9jh4ms6ruztw2, child number 0 +------------------------------------- +select /* TESTFG */ count(*) from t2 where val1 = 1 + +Plan hash value: 611317447 + +--------------------------------------------------------------------------------------------- +| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time | Pstart| Pstop | +--------------------------------------------------------------------------------------------- +| 0 | SELECT STATEMENT | | | | 16 (100)| | | | +| 1 | SORT AGGREGATE | | 1 | 4 | | | | | +| 2 | PARTITION RANGE ALL| | 2 | 8 | 16 (0)| 00:00:01 | 1 | 2 | +|* 3 | TABLE ACCESS FULL | T2 | 2 | 8 | 16 (0)| 00:00:01 | 1 | 2 | +--------------------------------------------------------------------------------------------- + +Predicate Information (identified by operation id): +--------------------------------------------------- + + 3 - filter("VAL1"=1) + + +20 rows selected. + + + SUM(VAL2) +---------- + 49995000 + + +PLAN_TABLE_OUTPUT +------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ +SQL_ID 31pkfzpmx1b62, child number 0 +------------------------------------- +select /* TESTFG */ /*+ INDEX_FFS(t new1) */ sum(val2) from t1 t + +Plan hash value: 3724264953 + +--------------------------------------------------------------------------- +| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time | +--------------------------------------------------------------------------- +| 0 | SELECT STATEMENT | | | | 9 (100)| | +| 1 | SORT AGGREGATE | | 1 | 4 | | | +| 2 | TABLE ACCESS FULL| T1 | 9999 | 39996 | 9 (0)| 00:00:01 | +--------------------------------------------------------------------------- + + +14 rows selected. + + + COUNT(*) +---------- + 9998 + + +PLAN_TABLE_OUTPUT +------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ +SQL_ID czjk2xd0vn20k, child number 0 +------------------------------------- +select /* TESTFG */ count(*) from t2 where id < (select max(id) from t1) + +Plan hash value: 771265474 + +-------------------------------------------------------------------------------------------------- +| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time | Pstart| Pstop | +-------------------------------------------------------------------------------------------------- +| 0 | SELECT STATEMENT | | | | 25 (100)| | | | +| 1 | SORT AGGREGATE | | 1 | 5 | | | | | +| 2 | PARTITION RANGE ITERATOR| | 1000 | 5000 | 16 (0)| 00:00:01 | 1 | KEY | +|* 3 | TABLE ACCESS FULL | T2 | 1000 | 5000 | 16 (0)| 00:00:01 | 1 | KEY | +| 4 | SORT AGGREGATE | | 1 | 4 | | | | | +| 5 | TABLE ACCESS FULL | T1 | 9999 | 39996 | 9 (0)| 00:00:01 | | | +-------------------------------------------------------------------------------------------------- + +Predicate Information (identified by operation id): +--------------------------------------------------- + + 3 - filter("ID"<) + + +22 rows selected. + + + COUNT(*) +---------- + 49 + + +PLAN_TABLE_OUTPUT +------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ +SQL_ID ax2r0jyjs0hbb, child number 0 +------------------------------------- +select /* TESTFG */ /*+ USE_INVISIBLE_INDEXES */ count(*) from t1 where +val2<50 + +Plan hash value: 3724264953 + +--------------------------------------------------------------------------- +| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time | +--------------------------------------------------------------------------- +| 0 | SELECT STATEMENT | | | | 9 (100)| | +| 1 | SORT AGGREGATE | | 1 | 4 | | | +|* 2 | TABLE ACCESS FULL| T1 | 49 | 196 | 9 (0)| 00:00:01 | +--------------------------------------------------------------------------- + +Predicate Information (identified by operation id): +--------------------------------------------------- + + 2 - filter("VAL2"<50) + + +20 rows selected. + + + COUNT(*) +---------- + 9999 + + +PLAN_TABLE_OUTPUT +------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ +SQL_ID 7c65qbgku7can, child number 0 +------------------------------------- +select /* TESTFG */ count(*) from t2 partition (p2) + +Plan hash value: 2457353553 + +---------------------------------------------------------------------------------------- +| Id | Operation | Name | Rows | Cost (%CPU)| Time | Pstart| Pstop | +---------------------------------------------------------------------------------------- +| 0 | SELECT STATEMENT | | | 9 (100)| | | | +| 1 | SORT AGGREGATE | | 1 | | | | | +| 2 | PARTITION RANGE SINGLE| | 9999 | 9 (0)| 00:00:01 | 2 | 2 | +| 3 | TABLE ACCESS FULL | T2 | 9999 | 9 (0)| 00:00:01 | 2 | 2 | +---------------------------------------------------------------------------------------- + + +15 rows selected. + + + COUNT(*) +---------- + 9999 + + +PLAN_TABLE_OUTPUT +------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ +SQL_ID 221p0y74xg65x, child number 0 +------------------------------------- +select /* TESTFG */ count(*) from t2 partition (p1) + +Plan hash value: 2457353553 + +---------------------------------------------------------------------------------------- +| Id | Operation | Name | Rows | Cost (%CPU)| Time | Pstart| Pstop | +---------------------------------------------------------------------------------------- +| 0 | SELECT STATEMENT | | | 9 (100)| | | | +| 1 | SORT AGGREGATE | | 1 | | | | | +| 2 | PARTITION RANGE SINGLE| | 9999 | 9 (0)| 00:00:01 | 1 | 1 | +| 3 | TABLE ACCESS FULL | T2 | 9999 | 9 (0)| 00:00:01 | 1 | 1 | +---------------------------------------------------------------------------------------- + + +15 rows selected. + + +49 rows updated. + + +98 rows updated. + + +49 rows updated. + + +49 rows updated. + + +Commit complete. + + +SQL_ID SQL_TEXT CHILD_NUMBER IS_SHAREABLE OBJECT_STATUS INVALIDATIONS IS_ROLLING_INVALID IS_ROLLING_REFRESH_I DDL_NO_INVALIDATE +------------- ------------------------------------------------------------------------------------- ------------ -------------------- ------------------- ------------- -------------------- -------------------- -------------------- +31pkfzpmx1b62 select /* TESTFG */ /*+ INDEX_FFS(t new1) */ sum(val2) from t1 t 0 Y VALID 0 N N N +ax2r0jyjs0hbb select /* TESTFG */ /*+ USE_INVISIBLE_INDEXES */ count(*) from t1 where val2<50 0 Y VALID 0 N N N +cf016xd0knzrh select /* TESTFG */ count(*) from t1 where id = 1 0 Y VALID 0 N N N +gvd4z9ba14uh3 select /* TESTFG */ count(*) from t1 where val1 = 1 0 Y VALID 0 N N N +221p0y74xg65x select /* TESTFG */ count(*) from t2 partition (p1) 0 Y VALID 0 N N N +7c65qbgku7can select /* TESTFG */ count(*) from t2 partition (p2) 0 Y VALID 0 N N N +czjk2xd0vn20k select /* TESTFG */ count(*) from t2 where id < (select max(id) from t1) 0 Y VALID 0 N N N +1y9y6gg3r5sry select /* TESTFG */ count(*) from t2 where id = 1 0 Y VALID 0 N N N +dcvq5bcm8yqm9 select /* TESTFG */ count(*) from t2 where id = 1+150000 0 Y VALID 0 N N N +9jh4ms6ruztw2 select /* TESTFG */ count(*) from t2 where val1 = 1 0 Y VALID 0 N N N +bcsj7p128xh77 update /* TESTFG */ t1 set val1 = val1 + 1 where id < 50 0 Y VALID 0 N N N +bdhfwydh894qk update /* TESTFG */ t1 set val1 = val1 + 1 where val1 < 50 0 Y VALID 0 N N N +6a6m4fq5b9v7r update /* TESTFG */ t2 set val1 = val1 + 1 where id < 50 0 Y VALID 0 N N N +24qkp15shu1gp update /* TESTFG */ t2 set val1 = val1 + 1 where val1 < 50 0 Y VALID 0 N N N + +14 rows selected. + + +no rows selected + +SQL> -- +SQL> -- ADD PARTITION +SQL> -- +SQL> alter table t2 add partition p3 values less than (300000) deferred invalidation; + +Table altered. + +SQL> set echo off + +SQL_ID SQL_TEXT CHILD_NUMBER IS_SHAREABLE OBJECT_STATUS INVALIDATIONS IS_ROLLING_INVALID IS_ROLLING_REFRESH_I DDL_NO_INVALIDATE +------------- ------------------------------------------------------------------------------------- ------------ -------------------- ------------------- ------------- -------------------- -------------------- -------------------- +31pkfzpmx1b62 select /* TESTFG */ /*+ INDEX_FFS(t new1) */ sum(val2) from t1 t 0 Y VALID 0 N N N +ax2r0jyjs0hbb select /* TESTFG */ /*+ USE_INVISIBLE_INDEXES */ count(*) from t1 where val2<50 0 Y VALID 0 N N N +cf016xd0knzrh select /* TESTFG */ count(*) from t1 where id = 1 0 Y VALID 0 N N N +gvd4z9ba14uh3 select /* TESTFG */ count(*) from t1 where val1 = 1 0 Y VALID 0 N N N +221p0y74xg65x select /* TESTFG */ count(*) from t2 partition (p1) 0 Y VALID 0 N Y N +7c65qbgku7can select /* TESTFG */ count(*) from t2 partition (p2) 0 Y VALID 0 N Y N +czjk2xd0vn20k select /* TESTFG */ count(*) from t2 where id < (select max(id) from t1) 0 Y VALID 0 N Y N +1y9y6gg3r5sry select /* TESTFG */ count(*) from t2 where id = 1 0 Y INVALID_UNAUTH 1 N N N +dcvq5bcm8yqm9 select /* TESTFG */ count(*) from t2 where id = 1+150000 0 Y INVALID_UNAUTH 1 N N N +9jh4ms6ruztw2 select /* TESTFG */ count(*) from t2 where val1 = 1 0 Y VALID 0 N Y N +bcsj7p128xh77 update /* TESTFG */ t1 set val1 = val1 + 1 where id < 50 0 Y VALID 0 N N N +bdhfwydh894qk update /* TESTFG */ t1 set val1 = val1 + 1 where val1 < 50 0 Y VALID 0 N N N +6a6m4fq5b9v7r update /* TESTFG */ t2 set val1 = val1 + 1 where id < 50 0 Y INVALID_UNAUTH 1 N N N +24qkp15shu1gp update /* TESTFG */ t2 set val1 = val1 + 1 where val1 < 50 0 Y INVALID_UNAUTH 1 N N N + +14 rows selected. + + +no rows selected + + +Table dropped. + + +Table dropped. + + +Table created. + + +Table created. + + +9999 rows created. + + +9999 rows created. + + +9999 rows created. + + +Index created. + + +Index created. + + +PL/SQL procedure successfully completed. + + +PL/SQL procedure successfully completed. + +Get rid of indexes... +SQL> drop index t1i; + +Index dropped. + +SQL> drop index t2i; + +Index dropped. + +SQL> alter table t2 add partition p3 values less than (300000); + +Table altered. + +SQL> set echo off + +System altered. + + + COUNT(*) +---------- + 1 + + +PLAN_TABLE_OUTPUT +------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ +SQL_ID cf016xd0knzrh, child number 0 +------------------------------------- +select /* TESTFG */ count(*) from t1 where id = 1 + +Plan hash value: 3724264953 + +--------------------------------------------------------------------------- +| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time | +--------------------------------------------------------------------------- +| 0 | SELECT STATEMENT | | | | 9 (100)| | +| 1 | SORT AGGREGATE | | 1 | 4 | | | +|* 2 | TABLE ACCESS FULL| T1 | 1 | 4 | 9 (0)| 00:00:01 | +--------------------------------------------------------------------------- + +Predicate Information (identified by operation id): +--------------------------------------------------- + + 2 - filter("ID"=1) + + +19 rows selected. + + + COUNT(*) +---------- + 1 + + +PLAN_TABLE_OUTPUT +------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ +SQL_ID gvd4z9ba14uh3, child number 0 +------------------------------------- +select /* TESTFG */ count(*) from t1 where val1 = 1 + +Plan hash value: 3724264953 + +--------------------------------------------------------------------------- +| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time | +--------------------------------------------------------------------------- +| 0 | SELECT STATEMENT | | | | 9 (100)| | +| 1 | SORT AGGREGATE | | 1 | 4 | | | +|* 2 | TABLE ACCESS FULL| T1 | 1 | 4 | 9 (0)| 00:00:01 | +--------------------------------------------------------------------------- + +Predicate Information (identified by operation id): +--------------------------------------------------- + + 2 - filter("VAL1"=1) + + +19 rows selected. + + + COUNT(*) +---------- + 1 + + +PLAN_TABLE_OUTPUT +------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ +SQL_ID 1y9y6gg3r5sry, child number 0 +------------------------------------- +select /* TESTFG */ count(*) from t2 where id = 1 + +Plan hash value: 2457353553 + +------------------------------------------------------------------------------------------------ +| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time | Pstart| Pstop | +------------------------------------------------------------------------------------------------ +| 0 | SELECT STATEMENT | | | | 8 (100)| | | | +| 1 | SORT AGGREGATE | | 1 | 4 | | | | | +| 2 | PARTITION RANGE SINGLE| | 1 | 4 | 8 (0)| 00:00:01 | 1 | 1 | +|* 3 | TABLE ACCESS FULL | T2 | 1 | 4 | 8 (0)| 00:00:01 | 1 | 1 | +------------------------------------------------------------------------------------------------ + +Predicate Information (identified by operation id): +--------------------------------------------------- + + 3 - filter("ID"=1) + + +20 rows selected. + + + COUNT(*) +---------- + 0 + + +PLAN_TABLE_OUTPUT +------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ +SQL_ID dcvq5bcm8yqm9, child number 0 +------------------------------------- +select /* TESTFG */ count(*) from t2 where id = 1+150000 + +Plan hash value: 2457353553 + +------------------------------------------------------------------------------------------------ +| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time | Pstart| Pstop | +------------------------------------------------------------------------------------------------ +| 0 | SELECT STATEMENT | | | | 9 (100)| | | | +| 1 | SORT AGGREGATE | | 1 | 5 | | | | | +| 2 | PARTITION RANGE SINGLE| | 1 | 5 | 9 (0)| 00:00:01 | 2 | 2 | +|* 3 | TABLE ACCESS FULL | T2 | 1 | 5 | 9 (0)| 00:00:01 | 2 | 2 | +------------------------------------------------------------------------------------------------ + +Predicate Information (identified by operation id): +--------------------------------------------------- + + 3 - filter("ID"=150001) + + +20 rows selected. + + + COUNT(*) +---------- + 2 + + +PLAN_TABLE_OUTPUT +------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ +SQL_ID 9jh4ms6ruztw2, child number 0 +------------------------------------- +select /* TESTFG */ count(*) from t2 where val1 = 1 + +Plan hash value: 611317447 + +--------------------------------------------------------------------------------------------- +| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time | Pstart| Pstop | +--------------------------------------------------------------------------------------------- +| 0 | SELECT STATEMENT | | | | 15 (100)| | | | +| 1 | SORT AGGREGATE | | 1 | 4 | | | | | +| 2 | PARTITION RANGE ALL| | 2 | 8 | 15 (0)| 00:00:01 | 1 | 3 | +|* 3 | TABLE ACCESS FULL | T2 | 2 | 8 | 15 (0)| 00:00:01 | 1 | 3 | +--------------------------------------------------------------------------------------------- + +Predicate Information (identified by operation id): +--------------------------------------------------- + + 3 - filter("VAL1"=1) + + +20 rows selected. + + + SUM(VAL2) +---------- + 49995000 + + +PLAN_TABLE_OUTPUT +------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ +SQL_ID 31pkfzpmx1b62, child number 0 +------------------------------------- +select /* TESTFG */ /*+ INDEX_FFS(t new1) */ sum(val2) from t1 t + +Plan hash value: 3724264953 + +--------------------------------------------------------------------------- +| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time | +--------------------------------------------------------------------------- +| 0 | SELECT STATEMENT | | | | 9 (100)| | +| 1 | SORT AGGREGATE | | 1 | 4 | | | +| 2 | TABLE ACCESS FULL| T1 | 9999 | 39996 | 9 (0)| 00:00:01 | +--------------------------------------------------------------------------- + + +14 rows selected. + + + COUNT(*) +---------- + 9998 + + +PLAN_TABLE_OUTPUT +------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ +SQL_ID czjk2xd0vn20k, child number 0 +------------------------------------- +select /* TESTFG */ count(*) from t2 where id < (select max(id) from t1) + +Plan hash value: 771265474 + +-------------------------------------------------------------------------------------------------- +| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time | Pstart| Pstop | +-------------------------------------------------------------------------------------------------- +| 0 | SELECT STATEMENT | | | | 25 (100)| | | | +| 1 | SORT AGGREGATE | | 1 | 5 | | | | | +| 2 | PARTITION RANGE ITERATOR| | 1000 | 5000 | 16 (0)| 00:00:01 | 1 | KEY | +|* 3 | TABLE ACCESS FULL | T2 | 1000 | 5000 | 16 (0)| 00:00:01 | 1 | KEY | +| 4 | SORT AGGREGATE | | 1 | 4 | | | | | +| 5 | TABLE ACCESS FULL | T1 | 9999 | 39996 | 9 (0)| 00:00:01 | | | +-------------------------------------------------------------------------------------------------- + +Predicate Information (identified by operation id): +--------------------------------------------------- + + 3 - filter("ID"<) + + +22 rows selected. + + + COUNT(*) +---------- + 49 + + +PLAN_TABLE_OUTPUT +------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ +SQL_ID ax2r0jyjs0hbb, child number 0 +------------------------------------- +select /* TESTFG */ /*+ USE_INVISIBLE_INDEXES */ count(*) from t1 where +val2<50 + +Plan hash value: 3724264953 + +--------------------------------------------------------------------------- +| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time | +--------------------------------------------------------------------------- +| 0 | SELECT STATEMENT | | | | 9 (100)| | +| 1 | SORT AGGREGATE | | 1 | 4 | | | +|* 2 | TABLE ACCESS FULL| T1 | 49 | 196 | 9 (0)| 00:00:01 | +--------------------------------------------------------------------------- + +Predicate Information (identified by operation id): +--------------------------------------------------- + + 2 - filter("VAL2"<50) + + +20 rows selected. + + + COUNT(*) +---------- + 9999 + + +PLAN_TABLE_OUTPUT +------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ +SQL_ID 7c65qbgku7can, child number 0 +------------------------------------- +select /* TESTFG */ count(*) from t2 partition (p2) + +Plan hash value: 2457353553 + +---------------------------------------------------------------------------------------- +| Id | Operation | Name | Rows | Cost (%CPU)| Time | Pstart| Pstop | +---------------------------------------------------------------------------------------- +| 0 | SELECT STATEMENT | | | 9 (100)| | | | +| 1 | SORT AGGREGATE | | 1 | | | | | +| 2 | PARTITION RANGE SINGLE| | 9999 | 9 (0)| 00:00:01 | 2 | 2 | +| 3 | TABLE ACCESS FULL | T2 | 9999 | 9 (0)| 00:00:01 | 2 | 2 | +---------------------------------------------------------------------------------------- + + +15 rows selected. + + + COUNT(*) +---------- + 9999 + + +PLAN_TABLE_OUTPUT +------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ +SQL_ID 221p0y74xg65x, child number 0 +------------------------------------- +select /* TESTFG */ count(*) from t2 partition (p1) + +Plan hash value: 2457353553 + +---------------------------------------------------------------------------------------- +| Id | Operation | Name | Rows | Cost (%CPU)| Time | Pstart| Pstop | +---------------------------------------------------------------------------------------- +| 0 | SELECT STATEMENT | | | 8 (100)| | | | +| 1 | SORT AGGREGATE | | 1 | | | | | +| 2 | PARTITION RANGE SINGLE| | 9999 | 8 (0)| 00:00:01 | 1 | 1 | +| 3 | TABLE ACCESS FULL | T2 | 9999 | 8 (0)| 00:00:01 | 1 | 1 | +---------------------------------------------------------------------------------------- + + +15 rows selected. + + +49 rows updated. + + +98 rows updated. + + +49 rows updated. + + +49 rows updated. + + +Commit complete. + + +SQL_ID SQL_TEXT CHILD_NUMBER IS_SHAREABLE OBJECT_STATUS INVALIDATIONS IS_ROLLING_INVALID IS_ROLLING_REFRESH_I DDL_NO_INVALIDATE +------------- ------------------------------------------------------------------------------------- ------------ -------------------- ------------------- ------------- -------------------- -------------------- -------------------- +31pkfzpmx1b62 select /* TESTFG */ /*+ INDEX_FFS(t new1) */ sum(val2) from t1 t 0 Y VALID 0 N N N +ax2r0jyjs0hbb select /* TESTFG */ /*+ USE_INVISIBLE_INDEXES */ count(*) from t1 where val2<50 0 Y VALID 0 N N N +cf016xd0knzrh select /* TESTFG */ count(*) from t1 where id = 1 0 Y VALID 0 N N N +gvd4z9ba14uh3 select /* TESTFG */ count(*) from t1 where val1 = 1 0 Y VALID 0 N N N +221p0y74xg65x select /* TESTFG */ count(*) from t2 partition (p1) 0 Y VALID 0 N N N +7c65qbgku7can select /* TESTFG */ count(*) from t2 partition (p2) 0 Y VALID 0 N N N +czjk2xd0vn20k select /* TESTFG */ count(*) from t2 where id < (select max(id) from t1) 0 Y VALID 0 N N N +1y9y6gg3r5sry select /* TESTFG */ count(*) from t2 where id = 1 0 Y VALID 0 N N N +dcvq5bcm8yqm9 select /* TESTFG */ count(*) from t2 where id = 1+150000 0 Y VALID 0 N N N +9jh4ms6ruztw2 select /* TESTFG */ count(*) from t2 where val1 = 1 0 Y VALID 0 N N N +bcsj7p128xh77 update /* TESTFG */ t1 set val1 = val1 + 1 where id < 50 0 Y VALID 0 N N N +bdhfwydh894qk update /* TESTFG */ t1 set val1 = val1 + 1 where val1 < 50 0 Y VALID 0 N N N +6a6m4fq5b9v7r update /* TESTFG */ t2 set val1 = val1 + 1 where id < 50 0 Y VALID 0 N N N +24qkp15shu1gp update /* TESTFG */ t2 set val1 = val1 + 1 where val1 < 50 0 Y VALID 0 N N N + +14 rows selected. + + +no rows selected + +SQL> -- +SQL> -- DROP PARTITION +SQL> -- +SQL> alter table t2 drop partition p3 deferred invalidation; + +Table altered. + +SQL> set echo off + +SQL_ID SQL_TEXT CHILD_NUMBER IS_SHAREABLE OBJECT_STATUS INVALIDATIONS IS_ROLLING_INVALID IS_ROLLING_REFRESH_I DDL_NO_INVALIDATE +------------- ------------------------------------------------------------------------------------- ------------ -------------------- ------------------- ------------- -------------------- -------------------- -------------------- +31pkfzpmx1b62 select /* TESTFG */ /*+ INDEX_FFS(t new1) */ sum(val2) from t1 t 0 Y VALID 0 N N N +ax2r0jyjs0hbb select /* TESTFG */ /*+ USE_INVISIBLE_INDEXES */ count(*) from t1 where val2<50 0 Y VALID 0 N N N +cf016xd0knzrh select /* TESTFG */ count(*) from t1 where id = 1 0 Y VALID 0 N N N +gvd4z9ba14uh3 select /* TESTFG */ count(*) from t1 where val1 = 1 0 Y VALID 0 N N N +221p0y74xg65x select /* TESTFG */ count(*) from t2 partition (p1) 0 Y INVALID_UNAUTH 1 N N N +7c65qbgku7can select /* TESTFG */ count(*) from t2 partition (p2) 0 Y INVALID_UNAUTH 1 N N N +czjk2xd0vn20k select /* TESTFG */ count(*) from t2 where id < (select max(id) from t1) 0 Y VALID 0 N Y N +1y9y6gg3r5sry select /* TESTFG */ count(*) from t2 where id = 1 0 Y INVALID_UNAUTH 1 N N N +dcvq5bcm8yqm9 select /* TESTFG */ count(*) from t2 where id = 1+150000 0 Y INVALID_UNAUTH 1 N N N +9jh4ms6ruztw2 select /* TESTFG */ count(*) from t2 where val1 = 1 0 Y VALID 0 N Y N +bcsj7p128xh77 update /* TESTFG */ t1 set val1 = val1 + 1 where id < 50 0 Y VALID 0 N N N +bdhfwydh894qk update /* TESTFG */ t1 set val1 = val1 + 1 where val1 < 50 0 Y VALID 0 N N N +6a6m4fq5b9v7r update /* TESTFG */ t2 set val1 = val1 + 1 where id < 50 0 Y INVALID_UNAUTH 1 N N N +24qkp15shu1gp update /* TESTFG */ t2 set val1 = val1 + 1 where val1 < 50 0 Y VALID 0 N Y N + +14 rows selected. + + +no rows selected + + +Table dropped. + + +Table dropped. + + +Table created. + + +Table created. + + +9999 rows created. + + +9999 rows created. + + +9999 rows created. + + +Index created. + + +Index created. + + +PL/SQL procedure successfully completed. + + +PL/SQL procedure successfully completed. + +Get rid of indexes... +SQL> drop index t1i; + +Index dropped. + +SQL> drop index t2i; + +Index dropped. + +SQL> alter table t2 add partition p3 values less than (300000); + +Table altered. + +SQL> set echo off + +System altered. + + + COUNT(*) +---------- + 1 + + +PLAN_TABLE_OUTPUT +------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ +SQL_ID cf016xd0knzrh, child number 0 +------------------------------------- +select /* TESTFG */ count(*) from t1 where id = 1 + +Plan hash value: 3724264953 + +--------------------------------------------------------------------------- +| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time | +--------------------------------------------------------------------------- +| 0 | SELECT STATEMENT | | | | 9 (100)| | +| 1 | SORT AGGREGATE | | 1 | 4 | | | +|* 2 | TABLE ACCESS FULL| T1 | 1 | 4 | 9 (0)| 00:00:01 | +--------------------------------------------------------------------------- + +Predicate Information (identified by operation id): +--------------------------------------------------- + + 2 - filter("ID"=1) + + +19 rows selected. + + + COUNT(*) +---------- + 1 + + +PLAN_TABLE_OUTPUT +------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ +SQL_ID gvd4z9ba14uh3, child number 0 +------------------------------------- +select /* TESTFG */ count(*) from t1 where val1 = 1 + +Plan hash value: 3724264953 + +--------------------------------------------------------------------------- +| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time | +--------------------------------------------------------------------------- +| 0 | SELECT STATEMENT | | | | 9 (100)| | +| 1 | SORT AGGREGATE | | 1 | 4 | | | +|* 2 | TABLE ACCESS FULL| T1 | 1 | 4 | 9 (0)| 00:00:01 | +--------------------------------------------------------------------------- + +Predicate Information (identified by operation id): +--------------------------------------------------- + + 2 - filter("VAL1"=1) + + +19 rows selected. + + + COUNT(*) +---------- + 1 + + +PLAN_TABLE_OUTPUT +------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ +SQL_ID 1y9y6gg3r5sry, child number 0 +------------------------------------- +select /* TESTFG */ count(*) from t2 where id = 1 + +Plan hash value: 2457353553 + +------------------------------------------------------------------------------------------------ +| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time | Pstart| Pstop | +------------------------------------------------------------------------------------------------ +| 0 | SELECT STATEMENT | | | | 9 (100)| | | | +| 1 | SORT AGGREGATE | | 1 | 4 | | | | | +| 2 | PARTITION RANGE SINGLE| | 1 | 4 | 9 (0)| 00:00:01 | 1 | 1 | +|* 3 | TABLE ACCESS FULL | T2 | 1 | 4 | 9 (0)| 00:00:01 | 1 | 1 | +------------------------------------------------------------------------------------------------ + +Predicate Information (identified by operation id): +--------------------------------------------------- + + 3 - filter("ID"=1) + + +20 rows selected. + + + COUNT(*) +---------- + 0 + + +PLAN_TABLE_OUTPUT +------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ +SQL_ID dcvq5bcm8yqm9, child number 0 +------------------------------------- +select /* TESTFG */ count(*) from t2 where id = 1+150000 + +Plan hash value: 2457353553 + +------------------------------------------------------------------------------------------------ +| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time | Pstart| Pstop | +------------------------------------------------------------------------------------------------ +| 0 | SELECT STATEMENT | | | | 9 (100)| | | | +| 1 | SORT AGGREGATE | | 1 | 5 | | | | | +| 2 | PARTITION RANGE SINGLE| | 1 | 5 | 9 (0)| 00:00:01 | 2 | 2 | +|* 3 | TABLE ACCESS FULL | T2 | 1 | 5 | 9 (0)| 00:00:01 | 2 | 2 | +------------------------------------------------------------------------------------------------ + +Predicate Information (identified by operation id): +--------------------------------------------------- + + 3 - filter("ID"=150001) + + +20 rows selected. + + + COUNT(*) +---------- + 2 + + +PLAN_TABLE_OUTPUT +------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ +SQL_ID 9jh4ms6ruztw2, child number 0 +------------------------------------- +select /* TESTFG */ count(*) from t2 where val1 = 1 + +Plan hash value: 611317447 + +--------------------------------------------------------------------------------------------- +| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time | Pstart| Pstop | +--------------------------------------------------------------------------------------------- +| 0 | SELECT STATEMENT | | | | 16 (100)| | | | +| 1 | SORT AGGREGATE | | 1 | 4 | | | | | +| 2 | PARTITION RANGE ALL| | 2 | 8 | 16 (0)| 00:00:01 | 1 | 3 | +|* 3 | TABLE ACCESS FULL | T2 | 2 | 8 | 16 (0)| 00:00:01 | 1 | 3 | +--------------------------------------------------------------------------------------------- + +Predicate Information (identified by operation id): +--------------------------------------------------- + + 3 - filter("VAL1"=1) + + +20 rows selected. + + + SUM(VAL2) +---------- + 49995000 + + +PLAN_TABLE_OUTPUT +------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ +SQL_ID 31pkfzpmx1b62, child number 0 +------------------------------------- +select /* TESTFG */ /*+ INDEX_FFS(t new1) */ sum(val2) from t1 t + +Plan hash value: 3724264953 + +--------------------------------------------------------------------------- +| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time | +--------------------------------------------------------------------------- +| 0 | SELECT STATEMENT | | | | 9 (100)| | +| 1 | SORT AGGREGATE | | 1 | 4 | | | +| 2 | TABLE ACCESS FULL| T1 | 9999 | 39996 | 9 (0)| 00:00:01 | +--------------------------------------------------------------------------- + + +14 rows selected. + + + COUNT(*) +---------- + 9998 + + +PLAN_TABLE_OUTPUT +------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ +SQL_ID czjk2xd0vn20k, child number 0 +------------------------------------- +select /* TESTFG */ count(*) from t2 where id < (select max(id) from t1) + +Plan hash value: 771265474 + +-------------------------------------------------------------------------------------------------- +| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time | Pstart| Pstop | +-------------------------------------------------------------------------------------------------- +| 0 | SELECT STATEMENT | | | | 25 (100)| | | | +| 1 | SORT AGGREGATE | | 1 | 5 | | | | | +| 2 | PARTITION RANGE ITERATOR| | 1000 | 5000 | 16 (0)| 00:00:01 | 1 | KEY | +|* 3 | TABLE ACCESS FULL | T2 | 1000 | 5000 | 16 (0)| 00:00:01 | 1 | KEY | +| 4 | SORT AGGREGATE | | 1 | 4 | | | | | +| 5 | TABLE ACCESS FULL | T1 | 9999 | 39996 | 9 (0)| 00:00:01 | | | +-------------------------------------------------------------------------------------------------- + +Predicate Information (identified by operation id): +--------------------------------------------------- + + 3 - filter("ID"<) + + +22 rows selected. + + + COUNT(*) +---------- + 49 + + +PLAN_TABLE_OUTPUT +------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ +SQL_ID ax2r0jyjs0hbb, child number 0 +------------------------------------- +select /* TESTFG */ /*+ USE_INVISIBLE_INDEXES */ count(*) from t1 where +val2<50 + +Plan hash value: 3724264953 + +--------------------------------------------------------------------------- +| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time | +--------------------------------------------------------------------------- +| 0 | SELECT STATEMENT | | | | 9 (100)| | +| 1 | SORT AGGREGATE | | 1 | 4 | | | +|* 2 | TABLE ACCESS FULL| T1 | 49 | 196 | 9 (0)| 00:00:01 | +--------------------------------------------------------------------------- + +Predicate Information (identified by operation id): +--------------------------------------------------- + + 2 - filter("VAL2"<50) + + +20 rows selected. + + + COUNT(*) +---------- + 9999 + + +PLAN_TABLE_OUTPUT +------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ +SQL_ID 7c65qbgku7can, child number 0 +------------------------------------- +select /* TESTFG */ count(*) from t2 partition (p2) + +Plan hash value: 2457353553 + +---------------------------------------------------------------------------------------- +| Id | Operation | Name | Rows | Cost (%CPU)| Time | Pstart| Pstop | +---------------------------------------------------------------------------------------- +| 0 | SELECT STATEMENT | | | 9 (100)| | | | +| 1 | SORT AGGREGATE | | 1 | | | | | +| 2 | PARTITION RANGE SINGLE| | 9999 | 9 (0)| 00:00:01 | 2 | 2 | +| 3 | TABLE ACCESS FULL | T2 | 9999 | 9 (0)| 00:00:01 | 2 | 2 | +---------------------------------------------------------------------------------------- + + +15 rows selected. + + + COUNT(*) +---------- + 9999 + + +PLAN_TABLE_OUTPUT +------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ +SQL_ID 221p0y74xg65x, child number 0 +------------------------------------- +select /* TESTFG */ count(*) from t2 partition (p1) + +Plan hash value: 2457353553 + +---------------------------------------------------------------------------------------- +| Id | Operation | Name | Rows | Cost (%CPU)| Time | Pstart| Pstop | +---------------------------------------------------------------------------------------- +| 0 | SELECT STATEMENT | | | 9 (100)| | | | +| 1 | SORT AGGREGATE | | 1 | | | | | +| 2 | PARTITION RANGE SINGLE| | 9999 | 9 (0)| 00:00:01 | 1 | 1 | +| 3 | TABLE ACCESS FULL | T2 | 9999 | 9 (0)| 00:00:01 | 1 | 1 | +---------------------------------------------------------------------------------------- + + +15 rows selected. + + +49 rows updated. + + +98 rows updated. + + +49 rows updated. + + +49 rows updated. + + +Commit complete. + + +SQL_ID SQL_TEXT CHILD_NUMBER IS_SHAREABLE OBJECT_STATUS INVALIDATIONS IS_ROLLING_INVALID IS_ROLLING_REFRESH_I DDL_NO_INVALIDATE +------------- ------------------------------------------------------------------------------------- ------------ -------------------- ------------------- ------------- -------------------- -------------------- -------------------- +31pkfzpmx1b62 select /* TESTFG */ /*+ INDEX_FFS(t new1) */ sum(val2) from t1 t 0 Y VALID 0 N N N +ax2r0jyjs0hbb select /* TESTFG */ /*+ USE_INVISIBLE_INDEXES */ count(*) from t1 where val2<50 0 Y VALID 0 N N N +cf016xd0knzrh select /* TESTFG */ count(*) from t1 where id = 1 0 Y VALID 0 N N N +gvd4z9ba14uh3 select /* TESTFG */ count(*) from t1 where val1 = 1 0 Y VALID 0 N N N +221p0y74xg65x select /* TESTFG */ count(*) from t2 partition (p1) 0 Y VALID 0 N N N +7c65qbgku7can select /* TESTFG */ count(*) from t2 partition (p2) 0 Y VALID 0 N N N +czjk2xd0vn20k select /* TESTFG */ count(*) from t2 where id < (select max(id) from t1) 0 Y VALID 0 N N N +1y9y6gg3r5sry select /* TESTFG */ count(*) from t2 where id = 1 0 Y VALID 0 N N N +dcvq5bcm8yqm9 select /* TESTFG */ count(*) from t2 where id = 1+150000 0 Y VALID 0 N N N +9jh4ms6ruztw2 select /* TESTFG */ count(*) from t2 where val1 = 1 0 Y VALID 0 N N N +bcsj7p128xh77 update /* TESTFG */ t1 set val1 = val1 + 1 where id < 50 0 Y VALID 0 N N N +bdhfwydh894qk update /* TESTFG */ t1 set val1 = val1 + 1 where val1 < 50 0 Y VALID 0 N N N +6a6m4fq5b9v7r update /* TESTFG */ t2 set val1 = val1 + 1 where id < 50 0 Y VALID 0 N N N +24qkp15shu1gp update /* TESTFG */ t2 set val1 = val1 + 1 where val1 < 50 0 Y VALID 0 N N N + +14 rows selected. + + +no rows selected + +SQL> -- +SQL> -- SPLIT PARTITION +SQL> -- +SQL> alter table t2 split partition p1 at (50000) into (partition p1,partition p1a) deferred invalidation; + +Table altered. + +SQL> set echo off + +SQL_ID SQL_TEXT CHILD_NUMBER IS_SHAREABLE OBJECT_STATUS INVALIDATIONS IS_ROLLING_INVALID IS_ROLLING_REFRESH_I DDL_NO_INVALIDATE +------------- ------------------------------------------------------------------------------------- ------------ -------------------- ------------------- ------------- -------------------- -------------------- -------------------- +31pkfzpmx1b62 select /* TESTFG */ /*+ INDEX_FFS(t new1) */ sum(val2) from t1 t 0 Y VALID 0 N N N +ax2r0jyjs0hbb select /* TESTFG */ /*+ USE_INVISIBLE_INDEXES */ count(*) from t1 where val2<50 0 Y VALID 0 N N N +cf016xd0knzrh select /* TESTFG */ count(*) from t1 where id = 1 0 Y VALID 0 N N N +gvd4z9ba14uh3 select /* TESTFG */ count(*) from t1 where val1 = 1 0 Y VALID 0 N N N +221p0y74xg65x select /* TESTFG */ count(*) from t2 partition (p1) 0 Y INVALID_UNAUTH 1 N N N +7c65qbgku7can select /* TESTFG */ count(*) from t2 partition (p2) 0 Y INVALID_UNAUTH 1 N N N +czjk2xd0vn20k select /* TESTFG */ count(*) from t2 where id < (select max(id) from t1) 0 Y VALID 0 N Y N +1y9y6gg3r5sry select /* TESTFG */ count(*) from t2 where id = 1 0 Y INVALID_UNAUTH 1 N N N +dcvq5bcm8yqm9 select /* TESTFG */ count(*) from t2 where id = 1+150000 0 Y INVALID_UNAUTH 1 N N N +9jh4ms6ruztw2 select /* TESTFG */ count(*) from t2 where val1 = 1 0 Y VALID 0 N Y N +bcsj7p128xh77 update /* TESTFG */ t1 set val1 = val1 + 1 where id < 50 0 Y VALID 0 N N N +bdhfwydh894qk update /* TESTFG */ t1 set val1 = val1 + 1 where val1 < 50 0 Y VALID 0 N N N +6a6m4fq5b9v7r update /* TESTFG */ t2 set val1 = val1 + 1 where id < 50 0 Y INVALID_UNAUTH 1 N N N +24qkp15shu1gp update /* TESTFG */ t2 set val1 = val1 + 1 where val1 < 50 0 Y INVALID_UNAUTH 1 N N N + +14 rows selected. + + +no rows selected + + +Table dropped. + + +Table dropped. + + +Table created. + + +Table created. + + +9999 rows created. + + +9999 rows created. + + +9999 rows created. + + +Index created. + + +Index created. + + +PL/SQL procedure successfully completed. + + +PL/SQL procedure successfully completed. + +Get rid of indexes... +SQL> drop index t1i; + +Index dropped. + +SQL> drop index t2i; + +Index dropped. + +SQL> alter table t2 add partition p3 values less than (300000); + +Table altered. + +SQL> set echo off + +System altered. + + + COUNT(*) +---------- + 1 + + +PLAN_TABLE_OUTPUT +------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ +SQL_ID cf016xd0knzrh, child number 0 +------------------------------------- +select /* TESTFG */ count(*) from t1 where id = 1 + +Plan hash value: 3724264953 + +--------------------------------------------------------------------------- +| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time | +--------------------------------------------------------------------------- +| 0 | SELECT STATEMENT | | | | 9 (100)| | +| 1 | SORT AGGREGATE | | 1 | 4 | | | +|* 2 | TABLE ACCESS FULL| T1 | 1 | 4 | 9 (0)| 00:00:01 | +--------------------------------------------------------------------------- + +Predicate Information (identified by operation id): +--------------------------------------------------- + + 2 - filter("ID"=1) + + +19 rows selected. + + + COUNT(*) +---------- + 1 + + +PLAN_TABLE_OUTPUT +------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ +SQL_ID gvd4z9ba14uh3, child number 0 +------------------------------------- +select /* TESTFG */ count(*) from t1 where val1 = 1 + +Plan hash value: 3724264953 + +--------------------------------------------------------------------------- +| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time | +--------------------------------------------------------------------------- +| 0 | SELECT STATEMENT | | | | 9 (100)| | +| 1 | SORT AGGREGATE | | 1 | 4 | | | +|* 2 | TABLE ACCESS FULL| T1 | 1 | 4 | 9 (0)| 00:00:01 | +--------------------------------------------------------------------------- + +Predicate Information (identified by operation id): +--------------------------------------------------- + + 2 - filter("VAL1"=1) + + +19 rows selected. + + + COUNT(*) +---------- + 1 + + +PLAN_TABLE_OUTPUT +------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ +SQL_ID 1y9y6gg3r5sry, child number 0 +------------------------------------- +select /* TESTFG */ count(*) from t2 where id = 1 + +Plan hash value: 2457353553 + +------------------------------------------------------------------------------------------------ +| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time | Pstart| Pstop | +------------------------------------------------------------------------------------------------ +| 0 | SELECT STATEMENT | | | | 9 (100)| | | | +| 1 | SORT AGGREGATE | | 1 | 4 | | | | | +| 2 | PARTITION RANGE SINGLE| | 1 | 4 | 9 (0)| 00:00:01 | 1 | 1 | +|* 3 | TABLE ACCESS FULL | T2 | 1 | 4 | 9 (0)| 00:00:01 | 1 | 1 | +------------------------------------------------------------------------------------------------ + +Predicate Information (identified by operation id): +--------------------------------------------------- + + 3 - filter("ID"=1) + + +20 rows selected. + + + COUNT(*) +---------- + 0 + + +PLAN_TABLE_OUTPUT +------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ +SQL_ID dcvq5bcm8yqm9, child number 0 +------------------------------------- +select /* TESTFG */ count(*) from t2 where id = 1+150000 + +Plan hash value: 2457353553 + +------------------------------------------------------------------------------------------------ +| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time | Pstart| Pstop | +------------------------------------------------------------------------------------------------ +| 0 | SELECT STATEMENT | | | | 9 (100)| | | | +| 1 | SORT AGGREGATE | | 1 | 5 | | | | | +| 2 | PARTITION RANGE SINGLE| | 1 | 5 | 9 (0)| 00:00:01 | 2 | 2 | +|* 3 | TABLE ACCESS FULL | T2 | 1 | 5 | 9 (0)| 00:00:01 | 2 | 2 | +------------------------------------------------------------------------------------------------ + +Predicate Information (identified by operation id): +--------------------------------------------------- + + 3 - filter("ID"=150001) + + +20 rows selected. + + + COUNT(*) +---------- + 2 + + +PLAN_TABLE_OUTPUT +------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ +SQL_ID 9jh4ms6ruztw2, child number 0 +------------------------------------- +select /* TESTFG */ count(*) from t2 where val1 = 1 + +Plan hash value: 611317447 + +--------------------------------------------------------------------------------------------- +| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time | Pstart| Pstop | +--------------------------------------------------------------------------------------------- +| 0 | SELECT STATEMENT | | | | 16 (100)| | | | +| 1 | SORT AGGREGATE | | 1 | 4 | | | | | +| 2 | PARTITION RANGE ALL| | 2 | 8 | 16 (0)| 00:00:01 | 1 | 3 | +|* 3 | TABLE ACCESS FULL | T2 | 2 | 8 | 16 (0)| 00:00:01 | 1 | 3 | +--------------------------------------------------------------------------------------------- + +Predicate Information (identified by operation id): +--------------------------------------------------- + + 3 - filter("VAL1"=1) + + +20 rows selected. + + + SUM(VAL2) +---------- + 49995000 + + +PLAN_TABLE_OUTPUT +------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ +SQL_ID 31pkfzpmx1b62, child number 0 +------------------------------------- +select /* TESTFG */ /*+ INDEX_FFS(t new1) */ sum(val2) from t1 t + +Plan hash value: 3724264953 + +--------------------------------------------------------------------------- +| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time | +--------------------------------------------------------------------------- +| 0 | SELECT STATEMENT | | | | 9 (100)| | +| 1 | SORT AGGREGATE | | 1 | 4 | | | +| 2 | TABLE ACCESS FULL| T1 | 9999 | 39996 | 9 (0)| 00:00:01 | +--------------------------------------------------------------------------- + + +14 rows selected. + + + COUNT(*) +---------- + 9998 + + +PLAN_TABLE_OUTPUT +------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ +SQL_ID czjk2xd0vn20k, child number 0 +------------------------------------- +select /* TESTFG */ count(*) from t2 where id < (select max(id) from t1) + +Plan hash value: 771265474 + +-------------------------------------------------------------------------------------------------- +| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time | Pstart| Pstop | +-------------------------------------------------------------------------------------------------- +| 0 | SELECT STATEMENT | | | | 25 (100)| | | | +| 1 | SORT AGGREGATE | | 1 | 5 | | | | | +| 2 | PARTITION RANGE ITERATOR| | 1000 | 5000 | 16 (0)| 00:00:01 | 1 | KEY | +|* 3 | TABLE ACCESS FULL | T2 | 1000 | 5000 | 16 (0)| 00:00:01 | 1 | KEY | +| 4 | SORT AGGREGATE | | 1 | 4 | | | | | +| 5 | TABLE ACCESS FULL | T1 | 9999 | 39996 | 9 (0)| 00:00:01 | | | +-------------------------------------------------------------------------------------------------- + +Predicate Information (identified by operation id): +--------------------------------------------------- + + 3 - filter("ID"<) + + +22 rows selected. + + + COUNT(*) +---------- + 49 + + +PLAN_TABLE_OUTPUT +------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ +SQL_ID ax2r0jyjs0hbb, child number 0 +------------------------------------- +select /* TESTFG */ /*+ USE_INVISIBLE_INDEXES */ count(*) from t1 where +val2<50 + +Plan hash value: 3724264953 + +--------------------------------------------------------------------------- +| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time | +--------------------------------------------------------------------------- +| 0 | SELECT STATEMENT | | | | 9 (100)| | +| 1 | SORT AGGREGATE | | 1 | 4 | | | +|* 2 | TABLE ACCESS FULL| T1 | 49 | 196 | 9 (0)| 00:00:01 | +--------------------------------------------------------------------------- + +Predicate Information (identified by operation id): +--------------------------------------------------- + + 2 - filter("VAL2"<50) + + +20 rows selected. + + + COUNT(*) +---------- + 9999 + + +PLAN_TABLE_OUTPUT +------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ +SQL_ID 7c65qbgku7can, child number 0 +------------------------------------- +select /* TESTFG */ count(*) from t2 partition (p2) + +Plan hash value: 2457353553 + +---------------------------------------------------------------------------------------- +| Id | Operation | Name | Rows | Cost (%CPU)| Time | Pstart| Pstop | +---------------------------------------------------------------------------------------- +| 0 | SELECT STATEMENT | | | 9 (100)| | | | +| 1 | SORT AGGREGATE | | 1 | | | | | +| 2 | PARTITION RANGE SINGLE| | 9999 | 9 (0)| 00:00:01 | 2 | 2 | +| 3 | TABLE ACCESS FULL | T2 | 9999 | 9 (0)| 00:00:01 | 2 | 2 | +---------------------------------------------------------------------------------------- + + +15 rows selected. + + + COUNT(*) +---------- + 9999 + + +PLAN_TABLE_OUTPUT +------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ +SQL_ID 221p0y74xg65x, child number 0 +------------------------------------- +select /* TESTFG */ count(*) from t2 partition (p1) + +Plan hash value: 2457353553 + +---------------------------------------------------------------------------------------- +| Id | Operation | Name | Rows | Cost (%CPU)| Time | Pstart| Pstop | +---------------------------------------------------------------------------------------- +| 0 | SELECT STATEMENT | | | 9 (100)| | | | +| 1 | SORT AGGREGATE | | 1 | | | | | +| 2 | PARTITION RANGE SINGLE| | 9999 | 9 (0)| 00:00:01 | 1 | 1 | +| 3 | TABLE ACCESS FULL | T2 | 9999 | 9 (0)| 00:00:01 | 1 | 1 | +---------------------------------------------------------------------------------------- + + +15 rows selected. + + +49 rows updated. + + +98 rows updated. + + +49 rows updated. + + +49 rows updated. + + +Commit complete. + + +SQL_ID SQL_TEXT CHILD_NUMBER IS_SHAREABLE OBJECT_STATUS INVALIDATIONS IS_ROLLING_INVALID IS_ROLLING_REFRESH_I DDL_NO_INVALIDATE +------------- ------------------------------------------------------------------------------------- ------------ -------------------- ------------------- ------------- -------------------- -------------------- -------------------- +31pkfzpmx1b62 select /* TESTFG */ /*+ INDEX_FFS(t new1) */ sum(val2) from t1 t 0 Y VALID 0 N N N +ax2r0jyjs0hbb select /* TESTFG */ /*+ USE_INVISIBLE_INDEXES */ count(*) from t1 where val2<50 0 Y VALID 0 N N N +cf016xd0knzrh select /* TESTFG */ count(*) from t1 where id = 1 0 Y VALID 0 N N N +gvd4z9ba14uh3 select /* TESTFG */ count(*) from t1 where val1 = 1 0 Y VALID 0 N N N +221p0y74xg65x select /* TESTFG */ count(*) from t2 partition (p1) 0 Y VALID 0 N N N +7c65qbgku7can select /* TESTFG */ count(*) from t2 partition (p2) 0 Y VALID 0 N N N +czjk2xd0vn20k select /* TESTFG */ count(*) from t2 where id < (select max(id) from t1) 0 Y VALID 0 N N N +1y9y6gg3r5sry select /* TESTFG */ count(*) from t2 where id = 1 0 Y VALID 0 N N N +dcvq5bcm8yqm9 select /* TESTFG */ count(*) from t2 where id = 1+150000 0 Y VALID 0 N N N +9jh4ms6ruztw2 select /* TESTFG */ count(*) from t2 where val1 = 1 0 Y VALID 0 N N N +bcsj7p128xh77 update /* TESTFG */ t1 set val1 = val1 + 1 where id < 50 0 Y VALID 0 N N N +bdhfwydh894qk update /* TESTFG */ t1 set val1 = val1 + 1 where val1 < 50 0 Y VALID 0 N N N +6a6m4fq5b9v7r update /* TESTFG */ t2 set val1 = val1 + 1 where id < 50 0 Y VALID 0 N N N +24qkp15shu1gp update /* TESTFG */ t2 set val1 = val1 + 1 where val1 < 50 0 Y VALID 0 N N N + +14 rows selected. + + +no rows selected + +SQL> -- +SQL> -- MERGE PARTITION +SQL> -- Note: hash-ADD, COALESCE should behave in same way - not tested here +SQL> -- +SQL> alter table t2 merge partitions p2 to p3 into partition px deferred invalidation; + +Table altered. + +SQL> set echo off + +SQL_ID SQL_TEXT CHILD_NUMBER IS_SHAREABLE OBJECT_STATUS INVALIDATIONS IS_ROLLING_INVALID IS_ROLLING_REFRESH_I DDL_NO_INVALIDATE +------------- ------------------------------------------------------------------------------------- ------------ -------------------- ------------------- ------------- -------------------- -------------------- -------------------- +31pkfzpmx1b62 select /* TESTFG */ /*+ INDEX_FFS(t new1) */ sum(val2) from t1 t 0 Y VALID 0 N N N +ax2r0jyjs0hbb select /* TESTFG */ /*+ USE_INVISIBLE_INDEXES */ count(*) from t1 where val2<50 0 Y VALID 0 N N N +cf016xd0knzrh select /* TESTFG */ count(*) from t1 where id = 1 0 Y VALID 0 N N N +gvd4z9ba14uh3 select /* TESTFG */ count(*) from t1 where val1 = 1 0 Y VALID 0 N N N +221p0y74xg65x select /* TESTFG */ count(*) from t2 partition (p1) 0 Y INVALID_UNAUTH 1 N N N +7c65qbgku7can select /* TESTFG */ count(*) from t2 partition (p2) 0 Y INVALID_UNAUTH 1 N N N +czjk2xd0vn20k select /* TESTFG */ count(*) from t2 where id < (select max(id) from t1) 0 Y VALID 0 N Y N +1y9y6gg3r5sry select /* TESTFG */ count(*) from t2 where id = 1 0 Y INVALID_UNAUTH 1 N N N +dcvq5bcm8yqm9 select /* TESTFG */ count(*) from t2 where id = 1+150000 0 Y INVALID_UNAUTH 1 N N N +9jh4ms6ruztw2 select /* TESTFG */ count(*) from t2 where val1 = 1 0 Y VALID 0 N Y N +bcsj7p128xh77 update /* TESTFG */ t1 set val1 = val1 + 1 where id < 50 0 Y VALID 0 N N N +bdhfwydh894qk update /* TESTFG */ t1 set val1 = val1 + 1 where val1 < 50 0 Y VALID 0 N N N +6a6m4fq5b9v7r update /* TESTFG */ t2 set val1 = val1 + 1 where id < 50 0 Y INVALID_UNAUTH 1 N N N +24qkp15shu1gp update /* TESTFG */ t2 set val1 = val1 + 1 where val1 < 50 0 Y INVALID_UNAUTH 1 N N N + +14 rows selected. + + +no rows selected + + +Table dropped. + + +Table dropped. + + +Table created. + + +Table created. + + +9999 rows created. + + +9999 rows created. + + +9999 rows created. + + +Index created. + + +Index created. + + +PL/SQL procedure successfully completed. + + +PL/SQL procedure successfully completed. + +Get rid of indexes... +SQL> drop index t1i; + +Index dropped. + +SQL> drop index t2i; + +Index dropped. + +SQL> alter table t2 add partition p3 values less than (300000); + +Table altered. + +SQL> set echo off + +System altered. + + + COUNT(*) +---------- + 1 + + +PLAN_TABLE_OUTPUT +------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ +SQL_ID cf016xd0knzrh, child number 0 +------------------------------------- +select /* TESTFG */ count(*) from t1 where id = 1 + +Plan hash value: 3724264953 + +--------------------------------------------------------------------------- +| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time | +--------------------------------------------------------------------------- +| 0 | SELECT STATEMENT | | | | 9 (100)| | +| 1 | SORT AGGREGATE | | 1 | 4 | | | +|* 2 | TABLE ACCESS FULL| T1 | 1 | 4 | 9 (0)| 00:00:01 | +--------------------------------------------------------------------------- + +Predicate Information (identified by operation id): +--------------------------------------------------- + + 2 - filter("ID"=1) + + +19 rows selected. + + + COUNT(*) +---------- + 1 + + +PLAN_TABLE_OUTPUT +------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ +SQL_ID gvd4z9ba14uh3, child number 0 +------------------------------------- +select /* TESTFG */ count(*) from t1 where val1 = 1 + +Plan hash value: 3724264953 + +--------------------------------------------------------------------------- +| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time | +--------------------------------------------------------------------------- +| 0 | SELECT STATEMENT | | | | 9 (100)| | +| 1 | SORT AGGREGATE | | 1 | 4 | | | +|* 2 | TABLE ACCESS FULL| T1 | 1 | 4 | 9 (0)| 00:00:01 | +--------------------------------------------------------------------------- + +Predicate Information (identified by operation id): +--------------------------------------------------- + + 2 - filter("VAL1"=1) + + +19 rows selected. + + + COUNT(*) +---------- + 1 + + +PLAN_TABLE_OUTPUT +------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ +SQL_ID 1y9y6gg3r5sry, child number 0 +------------------------------------- +select /* TESTFG */ count(*) from t2 where id = 1 + +Plan hash value: 2457353553 + +------------------------------------------------------------------------------------------------ +| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time | Pstart| Pstop | +------------------------------------------------------------------------------------------------ +| 0 | SELECT STATEMENT | | | | 9 (100)| | | | +| 1 | SORT AGGREGATE | | 1 | 4 | | | | | +| 2 | PARTITION RANGE SINGLE| | 1 | 4 | 9 (0)| 00:00:01 | 1 | 1 | +|* 3 | TABLE ACCESS FULL | T2 | 1 | 4 | 9 (0)| 00:00:01 | 1 | 1 | +------------------------------------------------------------------------------------------------ + +Predicate Information (identified by operation id): +--------------------------------------------------- + + 3 - filter("ID"=1) + + +20 rows selected. + + + COUNT(*) +---------- + 0 + + +PLAN_TABLE_OUTPUT +------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ +SQL_ID dcvq5bcm8yqm9, child number 0 +------------------------------------- +select /* TESTFG */ count(*) from t2 where id = 1+150000 + +Plan hash value: 2457353553 + +------------------------------------------------------------------------------------------------ +| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time | Pstart| Pstop | +------------------------------------------------------------------------------------------------ +| 0 | SELECT STATEMENT | | | | 9 (100)| | | | +| 1 | SORT AGGREGATE | | 1 | 5 | | | | | +| 2 | PARTITION RANGE SINGLE| | 1 | 5 | 9 (0)| 00:00:01 | 2 | 2 | +|* 3 | TABLE ACCESS FULL | T2 | 1 | 5 | 9 (0)| 00:00:01 | 2 | 2 | +------------------------------------------------------------------------------------------------ + +Predicate Information (identified by operation id): +--------------------------------------------------- + + 3 - filter("ID"=150001) + + +20 rows selected. + + + COUNT(*) +---------- + 2 + + +PLAN_TABLE_OUTPUT +------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ +SQL_ID 9jh4ms6ruztw2, child number 0 +------------------------------------- +select /* TESTFG */ count(*) from t2 where val1 = 1 + +Plan hash value: 611317447 + +--------------------------------------------------------------------------------------------- +| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time | Pstart| Pstop | +--------------------------------------------------------------------------------------------- +| 0 | SELECT STATEMENT | | | | 16 (100)| | | | +| 1 | SORT AGGREGATE | | 1 | 4 | | | | | +| 2 | PARTITION RANGE ALL| | 2 | 8 | 16 (0)| 00:00:01 | 1 | 3 | +|* 3 | TABLE ACCESS FULL | T2 | 2 | 8 | 16 (0)| 00:00:01 | 1 | 3 | +--------------------------------------------------------------------------------------------- + +Predicate Information (identified by operation id): +--------------------------------------------------- + + 3 - filter("VAL1"=1) + + +20 rows selected. + + + SUM(VAL2) +---------- + 49995000 + + +PLAN_TABLE_OUTPUT +------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ +SQL_ID 31pkfzpmx1b62, child number 0 +------------------------------------- +select /* TESTFG */ /*+ INDEX_FFS(t new1) */ sum(val2) from t1 t + +Plan hash value: 3724264953 + +--------------------------------------------------------------------------- +| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time | +--------------------------------------------------------------------------- +| 0 | SELECT STATEMENT | | | | 9 (100)| | +| 1 | SORT AGGREGATE | | 1 | 4 | | | +| 2 | TABLE ACCESS FULL| T1 | 9999 | 39996 | 9 (0)| 00:00:01 | +--------------------------------------------------------------------------- + + +14 rows selected. + + + COUNT(*) +---------- + 9998 + + +PLAN_TABLE_OUTPUT +------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ +SQL_ID czjk2xd0vn20k, child number 0 +------------------------------------- +select /* TESTFG */ count(*) from t2 where id < (select max(id) from t1) + +Plan hash value: 771265474 + +-------------------------------------------------------------------------------------------------- +| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time | Pstart| Pstop | +-------------------------------------------------------------------------------------------------- +| 0 | SELECT STATEMENT | | | | 25 (100)| | | | +| 1 | SORT AGGREGATE | | 1 | 5 | | | | | +| 2 | PARTITION RANGE ITERATOR| | 1000 | 5000 | 16 (0)| 00:00:01 | 1 | KEY | +|* 3 | TABLE ACCESS FULL | T2 | 1000 | 5000 | 16 (0)| 00:00:01 | 1 | KEY | +| 4 | SORT AGGREGATE | | 1 | 4 | | | | | +| 5 | TABLE ACCESS FULL | T1 | 9999 | 39996 | 9 (0)| 00:00:01 | | | +-------------------------------------------------------------------------------------------------- + +Predicate Information (identified by operation id): +--------------------------------------------------- + + 3 - filter("ID"<) + + +22 rows selected. + + + COUNT(*) +---------- + 49 + + +PLAN_TABLE_OUTPUT +------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ +SQL_ID ax2r0jyjs0hbb, child number 0 +------------------------------------- +select /* TESTFG */ /*+ USE_INVISIBLE_INDEXES */ count(*) from t1 where +val2<50 + +Plan hash value: 3724264953 + +--------------------------------------------------------------------------- +| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time | +--------------------------------------------------------------------------- +| 0 | SELECT STATEMENT | | | | 9 (100)| | +| 1 | SORT AGGREGATE | | 1 | 4 | | | +|* 2 | TABLE ACCESS FULL| T1 | 49 | 196 | 9 (0)| 00:00:01 | +--------------------------------------------------------------------------- + +Predicate Information (identified by operation id): +--------------------------------------------------- + + 2 - filter("VAL2"<50) + + +20 rows selected. + + + COUNT(*) +---------- + 9999 + + +PLAN_TABLE_OUTPUT +------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ +SQL_ID 7c65qbgku7can, child number 0 +------------------------------------- +select /* TESTFG */ count(*) from t2 partition (p2) + +Plan hash value: 2457353553 + +---------------------------------------------------------------------------------------- +| Id | Operation | Name | Rows | Cost (%CPU)| Time | Pstart| Pstop | +---------------------------------------------------------------------------------------- +| 0 | SELECT STATEMENT | | | 9 (100)| | | | +| 1 | SORT AGGREGATE | | 1 | | | | | +| 2 | PARTITION RANGE SINGLE| | 9999 | 9 (0)| 00:00:01 | 2 | 2 | +| 3 | TABLE ACCESS FULL | T2 | 9999 | 9 (0)| 00:00:01 | 2 | 2 | +---------------------------------------------------------------------------------------- + + +15 rows selected. + + + COUNT(*) +---------- + 9999 + + +PLAN_TABLE_OUTPUT +------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ +SQL_ID 221p0y74xg65x, child number 0 +------------------------------------- +select /* TESTFG */ count(*) from t2 partition (p1) + +Plan hash value: 2457353553 + +---------------------------------------------------------------------------------------- +| Id | Operation | Name | Rows | Cost (%CPU)| Time | Pstart| Pstop | +---------------------------------------------------------------------------------------- +| 0 | SELECT STATEMENT | | | 9 (100)| | | | +| 1 | SORT AGGREGATE | | 1 | | | | | +| 2 | PARTITION RANGE SINGLE| | 9999 | 9 (0)| 00:00:01 | 1 | 1 | +| 3 | TABLE ACCESS FULL | T2 | 9999 | 9 (0)| 00:00:01 | 1 | 1 | +---------------------------------------------------------------------------------------- + + +15 rows selected. + + +49 rows updated. + + +98 rows updated. + + +49 rows updated. + + +49 rows updated. + + +Commit complete. + + +SQL_ID SQL_TEXT CHILD_NUMBER IS_SHAREABLE OBJECT_STATUS INVALIDATIONS IS_ROLLING_INVALID IS_ROLLING_REFRESH_I DDL_NO_INVALIDATE +------------- ------------------------------------------------------------------------------------- ------------ -------------------- ------------------- ------------- -------------------- -------------------- -------------------- +31pkfzpmx1b62 select /* TESTFG */ /*+ INDEX_FFS(t new1) */ sum(val2) from t1 t 0 Y VALID 0 N N N +ax2r0jyjs0hbb select /* TESTFG */ /*+ USE_INVISIBLE_INDEXES */ count(*) from t1 where val2<50 0 Y VALID 0 N N N +cf016xd0knzrh select /* TESTFG */ count(*) from t1 where id = 1 0 Y VALID 0 N N N +gvd4z9ba14uh3 select /* TESTFG */ count(*) from t1 where val1 = 1 0 Y VALID 0 N N N +221p0y74xg65x select /* TESTFG */ count(*) from t2 partition (p1) 0 Y VALID 0 N N N +7c65qbgku7can select /* TESTFG */ count(*) from t2 partition (p2) 0 Y VALID 0 N N N +czjk2xd0vn20k select /* TESTFG */ count(*) from t2 where id < (select max(id) from t1) 0 Y VALID 0 N N N +1y9y6gg3r5sry select /* TESTFG */ count(*) from t2 where id = 1 0 Y VALID 0 N N N +dcvq5bcm8yqm9 select /* TESTFG */ count(*) from t2 where id = 1+150000 0 Y VALID 0 N N N +9jh4ms6ruztw2 select /* TESTFG */ count(*) from t2 where val1 = 1 0 Y VALID 0 N N N +bcsj7p128xh77 update /* TESTFG */ t1 set val1 = val1 + 1 where id < 50 0 Y VALID 0 N N N +bdhfwydh894qk update /* TESTFG */ t1 set val1 = val1 + 1 where val1 < 50 0 Y VALID 0 N N N +6a6m4fq5b9v7r update /* TESTFG */ t2 set val1 = val1 + 1 where id < 50 0 Y VALID 0 N N N +24qkp15shu1gp update /* TESTFG */ t2 set val1 = val1 + 1 where val1 < 50 0 Y VALID 0 N N N + +14 rows selected. + + +no rows selected + +SQL> -- +SQL> -- SHRINK +SQL> -- +SQL> -- Probably fails... +SQL> alter table t2 shrink space deferred invalidation; +alter table t2 shrink space deferred invalidation + * +ERROR at line 1: +ORA-10630: Illegal syntax specified with SHRINK clause + + +SQL> set echo off + +SQL_ID SQL_TEXT CHILD_NUMBER IS_SHAREABLE OBJECT_STATUS INVALIDATIONS IS_ROLLING_INVALID IS_ROLLING_REFRESH_I DDL_NO_INVALIDATE +------------- ------------------------------------------------------------------------------------- ------------ -------------------- ------------------- ------------- -------------------- -------------------- -------------------- +31pkfzpmx1b62 select /* TESTFG */ /*+ INDEX_FFS(t new1) */ sum(val2) from t1 t 0 Y VALID 0 N N N +ax2r0jyjs0hbb select /* TESTFG */ /*+ USE_INVISIBLE_INDEXES */ count(*) from t1 where val2<50 0 Y VALID 0 N N N +cf016xd0knzrh select /* TESTFG */ count(*) from t1 where id = 1 0 Y VALID 0 N N N +gvd4z9ba14uh3 select /* TESTFG */ count(*) from t1 where val1 = 1 0 Y VALID 0 N N N +221p0y74xg65x select /* TESTFG */ count(*) from t2 partition (p1) 0 Y VALID 0 N N N +7c65qbgku7can select /* TESTFG */ count(*) from t2 partition (p2) 0 Y VALID 0 N N N +czjk2xd0vn20k select /* TESTFG */ count(*) from t2 where id < (select max(id) from t1) 0 Y VALID 0 N N N +1y9y6gg3r5sry select /* TESTFG */ count(*) from t2 where id = 1 0 Y VALID 0 N N N +dcvq5bcm8yqm9 select /* TESTFG */ count(*) from t2 where id = 1+150000 0 Y VALID 0 N N N +9jh4ms6ruztw2 select /* TESTFG */ count(*) from t2 where val1 = 1 0 Y VALID 0 N N N +bcsj7p128xh77 update /* TESTFG */ t1 set val1 = val1 + 1 where id < 50 0 Y VALID 0 N N N +bdhfwydh894qk update /* TESTFG */ t1 set val1 = val1 + 1 where val1 < 50 0 Y VALID 0 N N N +6a6m4fq5b9v7r update /* TESTFG */ t2 set val1 = val1 + 1 where id < 50 0 Y VALID 0 N N N +24qkp15shu1gp update /* TESTFG */ t2 set val1 = val1 + 1 where val1 < 50 0 Y VALID 0 N N N + +14 rows selected. + + +no rows selected + + +Table dropped. + + +Table dropped. + + +Table created. + + +Table created. + + +9999 rows created. + + +9999 rows created. + + +9999 rows created. + + +Index created. + + +Index created. + + +PL/SQL procedure successfully completed. + + +PL/SQL procedure successfully completed. + +Get rid of indexes... +SQL> drop index t1i; + +Index dropped. + +SQL> drop index t2i; + +Index dropped. + +SQL> set echo off + +System altered. + + + COUNT(*) +---------- + 1 + + +PLAN_TABLE_OUTPUT +------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ +SQL_ID cf016xd0knzrh, child number 0 +------------------------------------- +select /* TESTFG */ count(*) from t1 where id = 1 + +Plan hash value: 3724264953 + +--------------------------------------------------------------------------- +| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time | +--------------------------------------------------------------------------- +| 0 | SELECT STATEMENT | | | | 9 (100)| | +| 1 | SORT AGGREGATE | | 1 | 4 | | | +|* 2 | TABLE ACCESS FULL| T1 | 1 | 4 | 9 (0)| 00:00:01 | +--------------------------------------------------------------------------- + +Predicate Information (identified by operation id): +--------------------------------------------------- + + 2 - filter("ID"=1) + + +19 rows selected. + + + COUNT(*) +---------- + 1 + + +PLAN_TABLE_OUTPUT +------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ +SQL_ID gvd4z9ba14uh3, child number 0 +------------------------------------- +select /* TESTFG */ count(*) from t1 where val1 = 1 + +Plan hash value: 3724264953 + +--------------------------------------------------------------------------- +| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time | +--------------------------------------------------------------------------- +| 0 | SELECT STATEMENT | | | | 9 (100)| | +| 1 | SORT AGGREGATE | | 1 | 4 | | | +|* 2 | TABLE ACCESS FULL| T1 | 1 | 4 | 9 (0)| 00:00:01 | +--------------------------------------------------------------------------- + +Predicate Information (identified by operation id): +--------------------------------------------------- + + 2 - filter("VAL1"=1) + + +19 rows selected. + + + COUNT(*) +---------- + 1 + + +PLAN_TABLE_OUTPUT +------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ +SQL_ID 1y9y6gg3r5sry, child number 0 +------------------------------------- +select /* TESTFG */ count(*) from t2 where id = 1 + +Plan hash value: 2457353553 + +------------------------------------------------------------------------------------------------ +| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time | Pstart| Pstop | +------------------------------------------------------------------------------------------------ +| 0 | SELECT STATEMENT | | | | 9 (100)| | | | +| 1 | SORT AGGREGATE | | 1 | 4 | | | | | +| 2 | PARTITION RANGE SINGLE| | 1 | 4 | 9 (0)| 00:00:01 | 1 | 1 | +|* 3 | TABLE ACCESS FULL | T2 | 1 | 4 | 9 (0)| 00:00:01 | 1 | 1 | +------------------------------------------------------------------------------------------------ + +Predicate Information (identified by operation id): +--------------------------------------------------- + + 3 - filter("ID"=1) + + +20 rows selected. + + + COUNT(*) +---------- + 0 + + +PLAN_TABLE_OUTPUT +------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ +SQL_ID dcvq5bcm8yqm9, child number 0 +------------------------------------- +select /* TESTFG */ count(*) from t2 where id = 1+150000 + +Plan hash value: 2457353553 + +------------------------------------------------------------------------------------------------ +| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time | Pstart| Pstop | +------------------------------------------------------------------------------------------------ +| 0 | SELECT STATEMENT | | | | 9 (100)| | | | +| 1 | SORT AGGREGATE | | 1 | 5 | | | | | +| 2 | PARTITION RANGE SINGLE| | 1 | 5 | 9 (0)| 00:00:01 | 2 | 2 | +|* 3 | TABLE ACCESS FULL | T2 | 1 | 5 | 9 (0)| 00:00:01 | 2 | 2 | +------------------------------------------------------------------------------------------------ + +Predicate Information (identified by operation id): +--------------------------------------------------- + + 3 - filter("ID"=150001) + + +20 rows selected. + + + COUNT(*) +---------- + 2 + + +PLAN_TABLE_OUTPUT +------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ +SQL_ID 9jh4ms6ruztw2, child number 0 +------------------------------------- +select /* TESTFG */ count(*) from t2 where val1 = 1 + +Plan hash value: 611317447 + +--------------------------------------------------------------------------------------------- +| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time | Pstart| Pstop | +--------------------------------------------------------------------------------------------- +| 0 | SELECT STATEMENT | | | | 16 (100)| | | | +| 1 | SORT AGGREGATE | | 1 | 4 | | | | | +| 2 | PARTITION RANGE ALL| | 2 | 8 | 16 (0)| 00:00:01 | 1 | 2 | +|* 3 | TABLE ACCESS FULL | T2 | 2 | 8 | 16 (0)| 00:00:01 | 1 | 2 | +--------------------------------------------------------------------------------------------- + +Predicate Information (identified by operation id): +--------------------------------------------------- + + 3 - filter("VAL1"=1) + + +20 rows selected. + + + SUM(VAL2) +---------- + 49995000 + + +PLAN_TABLE_OUTPUT +------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ +SQL_ID 31pkfzpmx1b62, child number 0 +------------------------------------- +select /* TESTFG */ /*+ INDEX_FFS(t new1) */ sum(val2) from t1 t + +Plan hash value: 3724264953 + +--------------------------------------------------------------------------- +| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time | +--------------------------------------------------------------------------- +| 0 | SELECT STATEMENT | | | | 9 (100)| | +| 1 | SORT AGGREGATE | | 1 | 4 | | | +| 2 | TABLE ACCESS FULL| T1 | 9999 | 39996 | 9 (0)| 00:00:01 | +--------------------------------------------------------------------------- + + +14 rows selected. + + + COUNT(*) +---------- + 9998 + + +PLAN_TABLE_OUTPUT +------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ +SQL_ID czjk2xd0vn20k, child number 0 +------------------------------------- +select /* TESTFG */ count(*) from t2 where id < (select max(id) from t1) + +Plan hash value: 771265474 + +-------------------------------------------------------------------------------------------------- +| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time | Pstart| Pstop | +-------------------------------------------------------------------------------------------------- +| 0 | SELECT STATEMENT | | | | 25 (100)| | | | +| 1 | SORT AGGREGATE | | 1 | 5 | | | | | +| 2 | PARTITION RANGE ITERATOR| | 1000 | 5000 | 16 (0)| 00:00:01 | 1 | KEY | +|* 3 | TABLE ACCESS FULL | T2 | 1000 | 5000 | 16 (0)| 00:00:01 | 1 | KEY | +| 4 | SORT AGGREGATE | | 1 | 4 | | | | | +| 5 | TABLE ACCESS FULL | T1 | 9999 | 39996 | 9 (0)| 00:00:01 | | | +-------------------------------------------------------------------------------------------------- + +Predicate Information (identified by operation id): +--------------------------------------------------- + + 3 - filter("ID"<) + + +22 rows selected. + + + COUNT(*) +---------- + 49 + + +PLAN_TABLE_OUTPUT +------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ +SQL_ID ax2r0jyjs0hbb, child number 0 +------------------------------------- +select /* TESTFG */ /*+ USE_INVISIBLE_INDEXES */ count(*) from t1 where +val2<50 + +Plan hash value: 3724264953 + +--------------------------------------------------------------------------- +| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time | +--------------------------------------------------------------------------- +| 0 | SELECT STATEMENT | | | | 9 (100)| | +| 1 | SORT AGGREGATE | | 1 | 4 | | | +|* 2 | TABLE ACCESS FULL| T1 | 49 | 196 | 9 (0)| 00:00:01 | +--------------------------------------------------------------------------- + +Predicate Information (identified by operation id): +--------------------------------------------------- + + 2 - filter("VAL2"<50) + + +20 rows selected. + + + COUNT(*) +---------- + 9999 + + +PLAN_TABLE_OUTPUT +------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ +SQL_ID 7c65qbgku7can, child number 0 +------------------------------------- +select /* TESTFG */ count(*) from t2 partition (p2) + +Plan hash value: 2457353553 + +---------------------------------------------------------------------------------------- +| Id | Operation | Name | Rows | Cost (%CPU)| Time | Pstart| Pstop | +---------------------------------------------------------------------------------------- +| 0 | SELECT STATEMENT | | | 9 (100)| | | | +| 1 | SORT AGGREGATE | | 1 | | | | | +| 2 | PARTITION RANGE SINGLE| | 9999 | 9 (0)| 00:00:01 | 2 | 2 | +| 3 | TABLE ACCESS FULL | T2 | 9999 | 9 (0)| 00:00:01 | 2 | 2 | +---------------------------------------------------------------------------------------- + + +15 rows selected. + + + COUNT(*) +---------- + 9999 + + +PLAN_TABLE_OUTPUT +------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ +SQL_ID 221p0y74xg65x, child number 0 +------------------------------------- +select /* TESTFG */ count(*) from t2 partition (p1) + +Plan hash value: 2457353553 + +---------------------------------------------------------------------------------------- +| Id | Operation | Name | Rows | Cost (%CPU)| Time | Pstart| Pstop | +---------------------------------------------------------------------------------------- +| 0 | SELECT STATEMENT | | | 9 (100)| | | | +| 1 | SORT AGGREGATE | | 1 | | | | | +| 2 | PARTITION RANGE SINGLE| | 9999 | 9 (0)| 00:00:01 | 1 | 1 | +| 3 | TABLE ACCESS FULL | T2 | 9999 | 9 (0)| 00:00:01 | 1 | 1 | +---------------------------------------------------------------------------------------- + + +15 rows selected. + + +49 rows updated. + + +98 rows updated. + + +49 rows updated. + + +49 rows updated. + + +Commit complete. + + +SQL_ID SQL_TEXT CHILD_NUMBER IS_SHAREABLE OBJECT_STATUS INVALIDATIONS IS_ROLLING_INVALID IS_ROLLING_REFRESH_I DDL_NO_INVALIDATE +------------- ------------------------------------------------------------------------------------- ------------ -------------------- ------------------- ------------- -------------------- -------------------- -------------------- +31pkfzpmx1b62 select /* TESTFG */ /*+ INDEX_FFS(t new1) */ sum(val2) from t1 t 0 Y VALID 0 N N N +ax2r0jyjs0hbb select /* TESTFG */ /*+ USE_INVISIBLE_INDEXES */ count(*) from t1 where val2<50 0 Y VALID 0 N N N +cf016xd0knzrh select /* TESTFG */ count(*) from t1 where id = 1 0 Y VALID 0 N N N +gvd4z9ba14uh3 select /* TESTFG */ count(*) from t1 where val1 = 1 0 Y VALID 0 N N N +221p0y74xg65x select /* TESTFG */ count(*) from t2 partition (p1) 0 Y VALID 0 N N N +7c65qbgku7can select /* TESTFG */ count(*) from t2 partition (p2) 0 Y VALID 0 N N N +czjk2xd0vn20k select /* TESTFG */ count(*) from t2 where id < (select max(id) from t1) 0 Y VALID 0 N N N +1y9y6gg3r5sry select /* TESTFG */ count(*) from t2 where id = 1 0 Y VALID 0 N N N +dcvq5bcm8yqm9 select /* TESTFG */ count(*) from t2 where id = 1+150000 0 Y VALID 0 N N N +9jh4ms6ruztw2 select /* TESTFG */ count(*) from t2 where val1 = 1 0 Y VALID 0 N N N +bcsj7p128xh77 update /* TESTFG */ t1 set val1 = val1 + 1 where id < 50 0 Y VALID 0 N N N +bdhfwydh894qk update /* TESTFG */ t1 set val1 = val1 + 1 where val1 < 50 0 Y VALID 0 N N N +6a6m4fq5b9v7r update /* TESTFG */ t2 set val1 = val1 + 1 where id < 50 0 Y VALID 0 N N N +24qkp15shu1gp update /* TESTFG */ t2 set val1 = val1 + 1 where val1 < 50 0 Y VALID 0 N N N + +14 rows selected. + + +no rows selected + +SQL> -- +SQL> -- ADD CONSTRAINT +SQL> -- +SQL> -- ## NOTE Accepted but might not be implemeted. +SQL> alter table t1 add constraint mypk1 primary key (id) deferred invalidation; + +Table altered. + +SQL> alter table t2 add constraint mypk2 primary key (id) deferred invalidation; + +Table altered. + +SQL> set echo off + +SQL_ID SQL_TEXT CHILD_NUMBER IS_SHAREABLE OBJECT_STATUS INVALIDATIONS IS_ROLLING_INVALID IS_ROLLING_REFRESH_I DDL_NO_INVALIDATE +------------- ------------------------------------------------------------------------------------- ------------ -------------------- ------------------- ------------- -------------------- -------------------- -------------------- +31pkfzpmx1b62 select /* TESTFG */ /*+ INDEX_FFS(t new1) */ sum(val2) from t1 t 0 Y INVALID_UNAUTH 1 N N N +ax2r0jyjs0hbb select /* TESTFG */ /*+ USE_INVISIBLE_INDEXES */ count(*) from t1 where val2<50 0 Y INVALID_UNAUTH 1 N N N +cf016xd0knzrh select /* TESTFG */ count(*) from t1 where id = 1 0 Y INVALID_UNAUTH 1 N N N +gvd4z9ba14uh3 select /* TESTFG */ count(*) from t1 where val1 = 1 0 Y INVALID_UNAUTH 1 N N N +221p0y74xg65x select /* TESTFG */ count(*) from t2 partition (p1) 0 Y INVALID_UNAUTH 1 N N N +7c65qbgku7can select /* TESTFG */ count(*) from t2 partition (p2) 0 Y INVALID_UNAUTH 1 N N N +czjk2xd0vn20k select /* TESTFG */ count(*) from t2 where id < (select max(id) from t1) 0 Y INVALID_UNAUTH 1 N N N +1y9y6gg3r5sry select /* TESTFG */ count(*) from t2 where id = 1 0 Y INVALID_UNAUTH 1 N N N +dcvq5bcm8yqm9 select /* TESTFG */ count(*) from t2 where id = 1+150000 0 Y INVALID_UNAUTH 1 N N N +9jh4ms6ruztw2 select /* TESTFG */ count(*) from t2 where val1 = 1 0 Y INVALID_UNAUTH 1 N N N +bcsj7p128xh77 update /* TESTFG */ t1 set val1 = val1 + 1 where id < 50 0 Y INVALID_UNAUTH 1 N N N +bdhfwydh894qk update /* TESTFG */ t1 set val1 = val1 + 1 where val1 < 50 0 Y INVALID_UNAUTH 1 N N N +6a6m4fq5b9v7r update /* TESTFG */ t2 set val1 = val1 + 1 where id < 50 0 Y INVALID_UNAUTH 1 N N N +24qkp15shu1gp update /* TESTFG */ t2 set val1 = val1 + 1 where val1 < 50 0 Y INVALID_UNAUTH 1 N N N + +14 rows selected. + + +no rows selected + +SQL> -- ## NOTE Accepted but not not be implemeted. +SQL> alter table t1 drop constraint mypk1 deferred invalidation; + +Table altered. + +SQL> +SQL> set echo off + +Table dropped. + + +Table dropped. + + +Table created. + + +Table created. + + +9999 rows created. + + +9999 rows created. + + +9999 rows created. + + +Index created. + + +Index created. + + +PL/SQL procedure successfully completed. + + +PL/SQL procedure successfully completed. + +rename +SQL> drop index t1i; + +Index dropped. + +SQL> drop index t2i; + +Index dropped. + +SQL> set echo off + +System altered. + + + COUNT(*) +---------- + 1 + + +PLAN_TABLE_OUTPUT +------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ +SQL_ID cf016xd0knzrh, child number 0 +------------------------------------- +select /* TESTFG */ count(*) from t1 where id = 1 + +Plan hash value: 3724264953 + +--------------------------------------------------------------------------- +| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time | +--------------------------------------------------------------------------- +| 0 | SELECT STATEMENT | | | | 9 (100)| | +| 1 | SORT AGGREGATE | | 1 | 4 | | | +|* 2 | TABLE ACCESS FULL| T1 | 1 | 4 | 9 (0)| 00:00:01 | +--------------------------------------------------------------------------- + +Predicate Information (identified by operation id): +--------------------------------------------------- + + 2 - filter("ID"=1) + + +19 rows selected. + + + COUNT(*) +---------- + 1 + + +PLAN_TABLE_OUTPUT +------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ +SQL_ID gvd4z9ba14uh3, child number 0 +------------------------------------- +select /* TESTFG */ count(*) from t1 where val1 = 1 + +Plan hash value: 3724264953 + +--------------------------------------------------------------------------- +| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time | +--------------------------------------------------------------------------- +| 0 | SELECT STATEMENT | | | | 9 (100)| | +| 1 | SORT AGGREGATE | | 1 | 4 | | | +|* 2 | TABLE ACCESS FULL| T1 | 1 | 4 | 9 (0)| 00:00:01 | +--------------------------------------------------------------------------- + +Predicate Information (identified by operation id): +--------------------------------------------------- + + 2 - filter("VAL1"=1) + + +19 rows selected. + + + COUNT(*) +---------- + 1 + + +PLAN_TABLE_OUTPUT +------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ +SQL_ID 1y9y6gg3r5sry, child number 0 +------------------------------------- +select /* TESTFG */ count(*) from t2 where id = 1 + +Plan hash value: 2457353553 + +------------------------------------------------------------------------------------------------ +| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time | Pstart| Pstop | +------------------------------------------------------------------------------------------------ +| 0 | SELECT STATEMENT | | | | 8 (100)| | | | +| 1 | SORT AGGREGATE | | 1 | 4 | | | | | +| 2 | PARTITION RANGE SINGLE| | 1 | 4 | 8 (0)| 00:00:01 | 1 | 1 | +|* 3 | TABLE ACCESS FULL | T2 | 1 | 4 | 8 (0)| 00:00:01 | 1 | 1 | +------------------------------------------------------------------------------------------------ + +Predicate Information (identified by operation id): +--------------------------------------------------- + + 3 - filter("ID"=1) + + +20 rows selected. + + + COUNT(*) +---------- + 0 + + +PLAN_TABLE_OUTPUT +------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ +SQL_ID dcvq5bcm8yqm9, child number 0 +------------------------------------- +select /* TESTFG */ count(*) from t2 where id = 1+150000 + +Plan hash value: 2457353553 + +------------------------------------------------------------------------------------------------ +| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time | Pstart| Pstop | +------------------------------------------------------------------------------------------------ +| 0 | SELECT STATEMENT | | | | 9 (100)| | | | +| 1 | SORT AGGREGATE | | 1 | 5 | | | | | +| 2 | PARTITION RANGE SINGLE| | 1 | 5 | 9 (0)| 00:00:01 | 2 | 2 | +|* 3 | TABLE ACCESS FULL | T2 | 1 | 5 | 9 (0)| 00:00:01 | 2 | 2 | +------------------------------------------------------------------------------------------------ + +Predicate Information (identified by operation id): +--------------------------------------------------- + + 3 - filter("ID"=150001) + + +20 rows selected. + + + COUNT(*) +---------- + 2 + + +PLAN_TABLE_OUTPUT +------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ +SQL_ID 9jh4ms6ruztw2, child number 0 +------------------------------------- +select /* TESTFG */ count(*) from t2 where val1 = 1 + +Plan hash value: 611317447 + +--------------------------------------------------------------------------------------------- +| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time | Pstart| Pstop | +--------------------------------------------------------------------------------------------- +| 0 | SELECT STATEMENT | | | | 15 (100)| | | | +| 1 | SORT AGGREGATE | | 1 | 4 | | | | | +| 2 | PARTITION RANGE ALL| | 2 | 8 | 15 (0)| 00:00:01 | 1 | 2 | +|* 3 | TABLE ACCESS FULL | T2 | 2 | 8 | 15 (0)| 00:00:01 | 1 | 2 | +--------------------------------------------------------------------------------------------- + +Predicate Information (identified by operation id): +--------------------------------------------------- + + 3 - filter("VAL1"=1) + + +20 rows selected. + + + SUM(VAL2) +---------- + 49995000 + + +PLAN_TABLE_OUTPUT +------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ +SQL_ID 31pkfzpmx1b62, child number 0 +------------------------------------- +select /* TESTFG */ /*+ INDEX_FFS(t new1) */ sum(val2) from t1 t + +Plan hash value: 3724264953 + +--------------------------------------------------------------------------- +| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time | +--------------------------------------------------------------------------- +| 0 | SELECT STATEMENT | | | | 9 (100)| | +| 1 | SORT AGGREGATE | | 1 | 4 | | | +| 2 | TABLE ACCESS FULL| T1 | 9999 | 39996 | 9 (0)| 00:00:01 | +--------------------------------------------------------------------------- + + +14 rows selected. + + + COUNT(*) +---------- + 9998 + + +PLAN_TABLE_OUTPUT +------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ +SQL_ID czjk2xd0vn20k, child number 0 +------------------------------------- +select /* TESTFG */ count(*) from t2 where id < (select max(id) from t1) + +Plan hash value: 771265474 + +-------------------------------------------------------------------------------------------------- +| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time | Pstart| Pstop | +-------------------------------------------------------------------------------------------------- +| 0 | SELECT STATEMENT | | | | 24 (100)| | | | +| 1 | SORT AGGREGATE | | 1 | 5 | | | | | +| 2 | PARTITION RANGE ITERATOR| | 1000 | 5000 | 15 (0)| 00:00:01 | 1 | KEY | +|* 3 | TABLE ACCESS FULL | T2 | 1000 | 5000 | 15 (0)| 00:00:01 | 1 | KEY | +| 4 | SORT AGGREGATE | | 1 | 4 | | | | | +| 5 | TABLE ACCESS FULL | T1 | 9999 | 39996 | 9 (0)| 00:00:01 | | | +-------------------------------------------------------------------------------------------------- + +Predicate Information (identified by operation id): +--------------------------------------------------- + + 3 - filter("ID"<) + + +22 rows selected. + + + COUNT(*) +---------- + 49 + + +PLAN_TABLE_OUTPUT +------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ +SQL_ID ax2r0jyjs0hbb, child number 0 +------------------------------------- +select /* TESTFG */ /*+ USE_INVISIBLE_INDEXES */ count(*) from t1 where +val2<50 + +Plan hash value: 3724264953 + +--------------------------------------------------------------------------- +| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time | +--------------------------------------------------------------------------- +| 0 | SELECT STATEMENT | | | | 9 (100)| | +| 1 | SORT AGGREGATE | | 1 | 4 | | | +|* 2 | TABLE ACCESS FULL| T1 | 49 | 196 | 9 (0)| 00:00:01 | +--------------------------------------------------------------------------- + +Predicate Information (identified by operation id): +--------------------------------------------------- + + 2 - filter("VAL2"<50) + + +20 rows selected. + + + COUNT(*) +---------- + 9999 + + +PLAN_TABLE_OUTPUT +------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ +SQL_ID 7c65qbgku7can, child number 0 +------------------------------------- +select /* TESTFG */ count(*) from t2 partition (p2) + +Plan hash value: 2457353553 + +---------------------------------------------------------------------------------------- +| Id | Operation | Name | Rows | Cost (%CPU)| Time | Pstart| Pstop | +---------------------------------------------------------------------------------------- +| 0 | SELECT STATEMENT | | | 9 (100)| | | | +| 1 | SORT AGGREGATE | | 1 | | | | | +| 2 | PARTITION RANGE SINGLE| | 9999 | 9 (0)| 00:00:01 | 2 | 2 | +| 3 | TABLE ACCESS FULL | T2 | 9999 | 9 (0)| 00:00:01 | 2 | 2 | +---------------------------------------------------------------------------------------- + + +15 rows selected. + + + COUNT(*) +---------- + 9999 + + +PLAN_TABLE_OUTPUT +------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ +SQL_ID 221p0y74xg65x, child number 0 +------------------------------------- +select /* TESTFG */ count(*) from t2 partition (p1) + +Plan hash value: 2457353553 + +---------------------------------------------------------------------------------------- +| Id | Operation | Name | Rows | Cost (%CPU)| Time | Pstart| Pstop | +---------------------------------------------------------------------------------------- +| 0 | SELECT STATEMENT | | | 8 (100)| | | | +| 1 | SORT AGGREGATE | | 1 | | | | | +| 2 | PARTITION RANGE SINGLE| | 9999 | 8 (0)| 00:00:01 | 1 | 1 | +| 3 | TABLE ACCESS FULL | T2 | 9999 | 8 (0)| 00:00:01 | 1 | 1 | +---------------------------------------------------------------------------------------- + + +15 rows selected. + + +49 rows updated. + + +98 rows updated. + + +49 rows updated. + + +49 rows updated. + + +Commit complete. + + +SQL_ID SQL_TEXT CHILD_NUMBER IS_SHAREABLE OBJECT_STATUS INVALIDATIONS IS_ROLLING_INVALID IS_ROLLING_REFRESH_I DDL_NO_INVALIDATE +------------- ------------------------------------------------------------------------------------- ------------ -------------------- ------------------- ------------- -------------------- -------------------- -------------------- +31pkfzpmx1b62 select /* TESTFG */ /*+ INDEX_FFS(t new1) */ sum(val2) from t1 t 0 Y VALID 0 N N N +ax2r0jyjs0hbb select /* TESTFG */ /*+ USE_INVISIBLE_INDEXES */ count(*) from t1 where val2<50 0 Y VALID 0 N N N +cf016xd0knzrh select /* TESTFG */ count(*) from t1 where id = 1 0 Y VALID 0 N N N +gvd4z9ba14uh3 select /* TESTFG */ count(*) from t1 where val1 = 1 0 Y VALID 0 N N N +221p0y74xg65x select /* TESTFG */ count(*) from t2 partition (p1) 0 Y VALID 0 N N N +7c65qbgku7can select /* TESTFG */ count(*) from t2 partition (p2) 0 Y VALID 0 N N N +czjk2xd0vn20k select /* TESTFG */ count(*) from t2 where id < (select max(id) from t1) 0 Y VALID 0 N N N +1y9y6gg3r5sry select /* TESTFG */ count(*) from t2 where id = 1 0 Y VALID 0 N N N +dcvq5bcm8yqm9 select /* TESTFG */ count(*) from t2 where id = 1+150000 0 Y VALID 0 N N N +9jh4ms6ruztw2 select /* TESTFG */ count(*) from t2 where val1 = 1 0 Y VALID 0 N N N +bcsj7p128xh77 update /* TESTFG */ t1 set val1 = val1 + 1 where id < 50 0 Y VALID 0 N N N +bdhfwydh894qk update /* TESTFG */ t1 set val1 = val1 + 1 where val1 < 50 0 Y VALID 0 N N N +6a6m4fq5b9v7r update /* TESTFG */ t2 set val1 = val1 + 1 where id < 50 0 Y VALID 0 N N N +24qkp15shu1gp update /* TESTFG */ t2 set val1 = val1 + 1 where val1 < 50 0 Y VALID 0 N N N + +14 rows selected. + + +no rows selected + +SQL> alter table t2 rename partition p2 to p2x deferred invalidation; +alter table t2 rename partition p2 to p2x deferred invalidation + * +ERROR at line 1: +ORA-14048: a partition maintenance operation may not be combined with other operations + + +SQL> set echo off + +SQL_ID SQL_TEXT CHILD_NUMBER IS_SHAREABLE OBJECT_STATUS INVALIDATIONS IS_ROLLING_INVALID IS_ROLLING_REFRESH_I DDL_NO_INVALIDATE +------------- ------------------------------------------------------------------------------------- ------------ -------------------- ------------------- ------------- -------------------- -------------------- -------------------- +31pkfzpmx1b62 select /* TESTFG */ /*+ INDEX_FFS(t new1) */ sum(val2) from t1 t 0 Y VALID 0 N N N +ax2r0jyjs0hbb select /* TESTFG */ /*+ USE_INVISIBLE_INDEXES */ count(*) from t1 where val2<50 0 Y VALID 0 N N N +cf016xd0knzrh select /* TESTFG */ count(*) from t1 where id = 1 0 Y VALID 0 N N N +gvd4z9ba14uh3 select /* TESTFG */ count(*) from t1 where val1 = 1 0 Y VALID 0 N N N +221p0y74xg65x select /* TESTFG */ count(*) from t2 partition (p1) 0 Y VALID 0 N N N +7c65qbgku7can select /* TESTFG */ count(*) from t2 partition (p2) 0 Y VALID 0 N N N +czjk2xd0vn20k select /* TESTFG */ count(*) from t2 where id < (select max(id) from t1) 0 Y VALID 0 N N N +1y9y6gg3r5sry select /* TESTFG */ count(*) from t2 where id = 1 0 Y VALID 0 N N N +dcvq5bcm8yqm9 select /* TESTFG */ count(*) from t2 where id = 1+150000 0 Y VALID 0 N N N +9jh4ms6ruztw2 select /* TESTFG */ count(*) from t2 where val1 = 1 0 Y VALID 0 N N N +bcsj7p128xh77 update /* TESTFG */ t1 set val1 = val1 + 1 where id < 50 0 Y VALID 0 N N N +bdhfwydh894qk update /* TESTFG */ t1 set val1 = val1 + 1 where val1 < 50 0 Y VALID 0 N N N +6a6m4fq5b9v7r update /* TESTFG */ t2 set val1 = val1 + 1 where id < 50 0 Y VALID 0 N N N +24qkp15shu1gp update /* TESTFG */ t2 set val1 = val1 + 1 where val1 < 50 0 Y VALID 0 N N N + +14 rows selected. + + +no rows selected + +SQL> +SQL> @tab +SQL> drop table t1; + +Table dropped. + +SQL> drop table t2; + +Table dropped. + +SQL> +SQL> create table t1 (id number(10) not null, val1 number(10) not null, val2 number(10) not null); + +Table created. + +SQL> +SQL> create table t2 (id number(10) not null, val1 number(10) not null, val2 number(10) not null) + 2 partition by range (id) ( + 3 partition p1 values less than (100000) + 4 , partition p2 values less than (200000) + 5 ) + 6 / + +Table created. + +SQL> +SQL> insert into t1 select rownum,rownum,rownum from ( + 2 select 1 + 3 from dual connect by rownum < 10000); + +9999 rows created. + +SQL> +SQL> insert into t2 select rownum,rownum,rownum from ( + 2 select 1 + 3 from dual connect by rownum < 10000); + +9999 rows created. + +SQL> +SQL> insert into t2 select rownum+100000,rownum,rownum from ( + 2 select 1 + 3 from dual connect by rownum < 10000); + +9999 rows created. + +SQL> +SQL> +SQL> create index t1i on t1 (id); + +Index created. + +SQL> create index t2i on t2 (id) local ( + 2 partition p1i, + 3 partition p2i); + +Index created. + +SQL> +SQL> exec dbms_stats.gather_table_stats(ownname=>user,tabname=>'t1'); + +PL/SQL procedure successfully completed. + +SQL> exec dbms_stats.gather_table_stats(ownname=>user,tabname=>'t2'); + +PL/SQL procedure successfully completed. + +SQL> prompt rename +rename +SQL> set echo on +SQL> drop index t1i; + +Index dropped. + +SQL> drop index t2i; + +Index dropped. + +SQL> set echo off + +System altered. + + + COUNT(*) +---------- + 1 + + +PLAN_TABLE_OUTPUT +------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ +SQL_ID cf016xd0knzrh, child number 0 +------------------------------------- +select /* TESTFG */ count(*) from t1 where id = 1 + +Plan hash value: 3724264953 + +--------------------------------------------------------------------------- +| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time | +--------------------------------------------------------------------------- +| 0 | SELECT STATEMENT | | | | 9 (100)| | +| 1 | SORT AGGREGATE | | 1 | 4 | | | +|* 2 | TABLE ACCESS FULL| T1 | 1 | 4 | 9 (0)| 00:00:01 | +--------------------------------------------------------------------------- + +Predicate Information (identified by operation id): +--------------------------------------------------- + + 2 - filter("ID"=1) + + +19 rows selected. + + + COUNT(*) +---------- + 1 + + +PLAN_TABLE_OUTPUT +------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ +SQL_ID gvd4z9ba14uh3, child number 0 +------------------------------------- +select /* TESTFG */ count(*) from t1 where val1 = 1 + +Plan hash value: 3724264953 + +--------------------------------------------------------------------------- +| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time | +--------------------------------------------------------------------------- +| 0 | SELECT STATEMENT | | | | 9 (100)| | +| 1 | SORT AGGREGATE | | 1 | 4 | | | +|* 2 | TABLE ACCESS FULL| T1 | 1 | 4 | 9 (0)| 00:00:01 | +--------------------------------------------------------------------------- + +Predicate Information (identified by operation id): +--------------------------------------------------- + + 2 - filter("VAL1"=1) + + +19 rows selected. + + + COUNT(*) +---------- + 1 + + +PLAN_TABLE_OUTPUT +------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ +SQL_ID 1y9y6gg3r5sry, child number 0 +------------------------------------- +select /* TESTFG */ count(*) from t2 where id = 1 + +Plan hash value: 2457353553 + +------------------------------------------------------------------------------------------------ +| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time | Pstart| Pstop | +------------------------------------------------------------------------------------------------ +| 0 | SELECT STATEMENT | | | | 9 (100)| | | | +| 1 | SORT AGGREGATE | | 1 | 4 | | | | | +| 2 | PARTITION RANGE SINGLE| | 1 | 4 | 9 (0)| 00:00:01 | 1 | 1 | +|* 3 | TABLE ACCESS FULL | T2 | 1 | 4 | 9 (0)| 00:00:01 | 1 | 1 | +------------------------------------------------------------------------------------------------ + +Predicate Information (identified by operation id): +--------------------------------------------------- + + 3 - filter("ID"=1) + + +20 rows selected. + + + COUNT(*) +---------- + 0 + + +PLAN_TABLE_OUTPUT +------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ +SQL_ID dcvq5bcm8yqm9, child number 0 +------------------------------------- +select /* TESTFG */ count(*) from t2 where id = 1+150000 + +Plan hash value: 2457353553 + +------------------------------------------------------------------------------------------------ +| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time | Pstart| Pstop | +------------------------------------------------------------------------------------------------ +| 0 | SELECT STATEMENT | | | | 9 (100)| | | | +| 1 | SORT AGGREGATE | | 1 | 5 | | | | | +| 2 | PARTITION RANGE SINGLE| | 1 | 5 | 9 (0)| 00:00:01 | 2 | 2 | +|* 3 | TABLE ACCESS FULL | T2 | 1 | 5 | 9 (0)| 00:00:01 | 2 | 2 | +------------------------------------------------------------------------------------------------ + +Predicate Information (identified by operation id): +--------------------------------------------------- + + 3 - filter("ID"=150001) + + +20 rows selected. + + + COUNT(*) +---------- + 2 + + +PLAN_TABLE_OUTPUT +------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ +SQL_ID 9jh4ms6ruztw2, child number 0 +------------------------------------- +select /* TESTFG */ count(*) from t2 where val1 = 1 + +Plan hash value: 611317447 + +--------------------------------------------------------------------------------------------- +| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time | Pstart| Pstop | +--------------------------------------------------------------------------------------------- +| 0 | SELECT STATEMENT | | | | 16 (100)| | | | +| 1 | SORT AGGREGATE | | 1 | 4 | | | | | +| 2 | PARTITION RANGE ALL| | 2 | 8 | 16 (0)| 00:00:01 | 1 | 2 | +|* 3 | TABLE ACCESS FULL | T2 | 2 | 8 | 16 (0)| 00:00:01 | 1 | 2 | +--------------------------------------------------------------------------------------------- + +Predicate Information (identified by operation id): +--------------------------------------------------- + + 3 - filter("VAL1"=1) + + +20 rows selected. + + + SUM(VAL2) +---------- + 49995000 + + +PLAN_TABLE_OUTPUT +------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ +SQL_ID 31pkfzpmx1b62, child number 0 +------------------------------------- +select /* TESTFG */ /*+ INDEX_FFS(t new1) */ sum(val2) from t1 t + +Plan hash value: 3724264953 + +--------------------------------------------------------------------------- +| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time | +--------------------------------------------------------------------------- +| 0 | SELECT STATEMENT | | | | 9 (100)| | +| 1 | SORT AGGREGATE | | 1 | 4 | | | +| 2 | TABLE ACCESS FULL| T1 | 9999 | 39996 | 9 (0)| 00:00:01 | +--------------------------------------------------------------------------- + + +14 rows selected. + + + COUNT(*) +---------- + 9998 + + +PLAN_TABLE_OUTPUT +------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ +SQL_ID czjk2xd0vn20k, child number 0 +------------------------------------- +select /* TESTFG */ count(*) from t2 where id < (select max(id) from t1) + +Plan hash value: 771265474 + +-------------------------------------------------------------------------------------------------- +| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time | Pstart| Pstop | +-------------------------------------------------------------------------------------------------- +| 0 | SELECT STATEMENT | | | | 25 (100)| | | | +| 1 | SORT AGGREGATE | | 1 | 5 | | | | | +| 2 | PARTITION RANGE ITERATOR| | 1000 | 5000 | 16 (0)| 00:00:01 | 1 | KEY | +|* 3 | TABLE ACCESS FULL | T2 | 1000 | 5000 | 16 (0)| 00:00:01 | 1 | KEY | +| 4 | SORT AGGREGATE | | 1 | 4 | | | | | +| 5 | TABLE ACCESS FULL | T1 | 9999 | 39996 | 9 (0)| 00:00:01 | | | +-------------------------------------------------------------------------------------------------- + +Predicate Information (identified by operation id): +--------------------------------------------------- + + 3 - filter("ID"<) + + +22 rows selected. + + + COUNT(*) +---------- + 49 + + +PLAN_TABLE_OUTPUT +------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ +SQL_ID ax2r0jyjs0hbb, child number 0 +------------------------------------- +select /* TESTFG */ /*+ USE_INVISIBLE_INDEXES */ count(*) from t1 where +val2<50 + +Plan hash value: 3724264953 + +--------------------------------------------------------------------------- +| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time | +--------------------------------------------------------------------------- +| 0 | SELECT STATEMENT | | | | 9 (100)| | +| 1 | SORT AGGREGATE | | 1 | 4 | | | +|* 2 | TABLE ACCESS FULL| T1 | 49 | 196 | 9 (0)| 00:00:01 | +--------------------------------------------------------------------------- + +Predicate Information (identified by operation id): +--------------------------------------------------- + + 2 - filter("VAL2"<50) + + +20 rows selected. + + + COUNT(*) +---------- + 9999 + + +PLAN_TABLE_OUTPUT +------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ +SQL_ID 7c65qbgku7can, child number 0 +------------------------------------- +select /* TESTFG */ count(*) from t2 partition (p2) + +Plan hash value: 2457353553 + +---------------------------------------------------------------------------------------- +| Id | Operation | Name | Rows | Cost (%CPU)| Time | Pstart| Pstop | +---------------------------------------------------------------------------------------- +| 0 | SELECT STATEMENT | | | 9 (100)| | | | +| 1 | SORT AGGREGATE | | 1 | | | | | +| 2 | PARTITION RANGE SINGLE| | 9999 | 9 (0)| 00:00:01 | 2 | 2 | +| 3 | TABLE ACCESS FULL | T2 | 9999 | 9 (0)| 00:00:01 | 2 | 2 | +---------------------------------------------------------------------------------------- + + +15 rows selected. + + + COUNT(*) +---------- + 9999 + + +PLAN_TABLE_OUTPUT +------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ +SQL_ID 221p0y74xg65x, child number 0 +------------------------------------- +select /* TESTFG */ count(*) from t2 partition (p1) + +Plan hash value: 2457353553 + +---------------------------------------------------------------------------------------- +| Id | Operation | Name | Rows | Cost (%CPU)| Time | Pstart| Pstop | +---------------------------------------------------------------------------------------- +| 0 | SELECT STATEMENT | | | 9 (100)| | | | +| 1 | SORT AGGREGATE | | 1 | | | | | +| 2 | PARTITION RANGE SINGLE| | 9999 | 9 (0)| 00:00:01 | 1 | 1 | +| 3 | TABLE ACCESS FULL | T2 | 9999 | 9 (0)| 00:00:01 | 1 | 1 | +---------------------------------------------------------------------------------------- + + +15 rows selected. + + +49 rows updated. + + +98 rows updated. + + +49 rows updated. + + +49 rows updated. + + +Commit complete. + + +SQL_ID SQL_TEXT CHILD_NUMBER IS_SHAREABLE OBJECT_STATUS INVALIDATIONS IS_ROLLING_INVALID IS_ROLLING_REFRESH_I DDL_NO_INVALIDATE +------------- ------------------------------------------------------------------------------------- ------------ -------------------- ------------------- ------------- -------------------- -------------------- -------------------- +31pkfzpmx1b62 select /* TESTFG */ /*+ INDEX_FFS(t new1) */ sum(val2) from t1 t 0 Y VALID 0 N N N +ax2r0jyjs0hbb select /* TESTFG */ /*+ USE_INVISIBLE_INDEXES */ count(*) from t1 where val2<50 0 Y VALID 0 N N N +cf016xd0knzrh select /* TESTFG */ count(*) from t1 where id = 1 0 Y VALID 0 N N N +gvd4z9ba14uh3 select /* TESTFG */ count(*) from t1 where val1 = 1 0 Y VALID 0 N N N +221p0y74xg65x select /* TESTFG */ count(*) from t2 partition (p1) 0 Y VALID 0 N N N +7c65qbgku7can select /* TESTFG */ count(*) from t2 partition (p2) 0 Y VALID 0 N N N +czjk2xd0vn20k select /* TESTFG */ count(*) from t2 where id < (select max(id) from t1) 0 Y VALID 0 N N N +1y9y6gg3r5sry select /* TESTFG */ count(*) from t2 where id = 1 0 Y VALID 0 N N N +dcvq5bcm8yqm9 select /* TESTFG */ count(*) from t2 where id = 1+150000 0 Y VALID 0 N N N +9jh4ms6ruztw2 select /* TESTFG */ count(*) from t2 where val1 = 1 0 Y VALID 0 N N N +bcsj7p128xh77 update /* TESTFG */ t1 set val1 = val1 + 1 where id < 50 0 Y VALID 0 N N N +bdhfwydh894qk update /* TESTFG */ t1 set val1 = val1 + 1 where val1 < 50 0 Y VALID 0 N N N +6a6m4fq5b9v7r update /* TESTFG */ t2 set val1 = val1 + 1 where id < 50 0 Y VALID 0 N N N +24qkp15shu1gp update /* TESTFG */ t2 set val1 = val1 + 1 where val1 < 50 0 Y VALID 0 N N N + +14 rows selected. + + +no rows selected + +SQL> alter table t2 modify partition p2 read only deferred invalidation; + +Table altered. + +SQL> set echo off + +SQL_ID SQL_TEXT CHILD_NUMBER IS_SHAREABLE OBJECT_STATUS INVALIDATIONS IS_ROLLING_INVALID IS_ROLLING_REFRESH_I DDL_NO_INVALIDATE +------------- ------------------------------------------------------------------------------------- ------------ -------------------- ------------------- ------------- -------------------- -------------------- -------------------- +31pkfzpmx1b62 select /* TESTFG */ /*+ INDEX_FFS(t new1) */ sum(val2) from t1 t 0 Y VALID 0 N N N +ax2r0jyjs0hbb select /* TESTFG */ /*+ USE_INVISIBLE_INDEXES */ count(*) from t1 where val2<50 0 Y VALID 0 N N N +cf016xd0knzrh select /* TESTFG */ count(*) from t1 where id = 1 0 Y VALID 0 N N N +gvd4z9ba14uh3 select /* TESTFG */ count(*) from t1 where val1 = 1 0 Y VALID 0 N N N +221p0y74xg65x select /* TESTFG */ count(*) from t2 partition (p1) 0 Y VALID 0 N N Y +7c65qbgku7can select /* TESTFG */ count(*) from t2 partition (p2) 0 Y VALID 0 N N Y +czjk2xd0vn20k select /* TESTFG */ count(*) from t2 where id < (select max(id) from t1) 0 Y VALID 0 N N Y +1y9y6gg3r5sry select /* TESTFG */ count(*) from t2 where id = 1 0 Y VALID 0 N N Y +dcvq5bcm8yqm9 select /* TESTFG */ count(*) from t2 where id = 1+150000 0 Y VALID 0 N N Y +9jh4ms6ruztw2 select /* TESTFG */ count(*) from t2 where val1 = 1 0 Y VALID 0 N N Y +bcsj7p128xh77 update /* TESTFG */ t1 set val1 = val1 + 1 where id < 50 0 Y VALID 0 N N N +bdhfwydh894qk update /* TESTFG */ t1 set val1 = val1 + 1 where val1 < 50 0 Y VALID 0 N N N +6a6m4fq5b9v7r update /* TESTFG */ t2 set val1 = val1 + 1 where id < 50 0 Y VALID 0 N Y N +24qkp15shu1gp update /* TESTFG */ t2 set val1 = val1 + 1 where val1 < 50 0 Y VALID 0 N Y N + +14 rows selected. + + +no rows selected + +SQL> +SQL> @tab +SQL> drop table t1; + +Table dropped. + +SQL> drop table t2; + +Table dropped. + +SQL> +SQL> create table t1 (id number(10) not null, val1 number(10) not null, val2 number(10) not null); + +Table created. + +SQL> +SQL> create table t2 (id number(10) not null, val1 number(10) not null, val2 number(10) not null) + 2 partition by range (id) ( + 3 partition p1 values less than (100000) + 4 , partition p2 values less than (200000) + 5 ) + 6 / + +Table created. + +SQL> +SQL> insert into t1 select rownum,rownum,rownum from ( + 2 select 1 + 3 from dual connect by rownum < 10000); + +9999 rows created. + +SQL> +SQL> insert into t2 select rownum,rownum,rownum from ( + 2 select 1 + 3 from dual connect by rownum < 10000); + +9999 rows created. + +SQL> +SQL> insert into t2 select rownum+100000,rownum,rownum from ( + 2 select 1 + 3 from dual connect by rownum < 10000); + +9999 rows created. + +SQL> +SQL> +SQL> create index t1i on t1 (id); + +Index created. + +SQL> create index t2i on t2 (id) local ( + 2 partition p1i, + 3 partition p2i); + +Index created. + +SQL> +SQL> exec dbms_stats.gather_table_stats(ownname=>user,tabname=>'t1'); + +PL/SQL procedure successfully completed. + +SQL> exec dbms_stats.gather_table_stats(ownname=>user,tabname=>'t2'); + +PL/SQL procedure successfully completed. + +SQL> prompt rename +rename +SQL> set echo on +SQL> drop index t1i; + +Index dropped. + +SQL> drop index t2i; + +Index dropped. + +SQL> set echo off + +System altered. + + + COUNT(*) +---------- + 1 + + +PLAN_TABLE_OUTPUT +------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ +SQL_ID cf016xd0knzrh, child number 0 +------------------------------------- +select /* TESTFG */ count(*) from t1 where id = 1 + +Plan hash value: 3724264953 + +--------------------------------------------------------------------------- +| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time | +--------------------------------------------------------------------------- +| 0 | SELECT STATEMENT | | | | 9 (100)| | +| 1 | SORT AGGREGATE | | 1 | 4 | | | +|* 2 | TABLE ACCESS FULL| T1 | 1 | 4 | 9 (0)| 00:00:01 | +--------------------------------------------------------------------------- + +Predicate Information (identified by operation id): +--------------------------------------------------- + + 2 - filter("ID"=1) + + +19 rows selected. + + + COUNT(*) +---------- + 1 + + +PLAN_TABLE_OUTPUT +------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ +SQL_ID gvd4z9ba14uh3, child number 0 +------------------------------------- +select /* TESTFG */ count(*) from t1 where val1 = 1 + +Plan hash value: 3724264953 + +--------------------------------------------------------------------------- +| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time | +--------------------------------------------------------------------------- +| 0 | SELECT STATEMENT | | | | 9 (100)| | +| 1 | SORT AGGREGATE | | 1 | 4 | | | +|* 2 | TABLE ACCESS FULL| T1 | 1 | 4 | 9 (0)| 00:00:01 | +--------------------------------------------------------------------------- + +Predicate Information (identified by operation id): +--------------------------------------------------- + + 2 - filter("VAL1"=1) + + +19 rows selected. + + + COUNT(*) +---------- + 1 + + +PLAN_TABLE_OUTPUT +------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ +SQL_ID 1y9y6gg3r5sry, child number 0 +------------------------------------- +select /* TESTFG */ count(*) from t2 where id = 1 + +Plan hash value: 2457353553 + +------------------------------------------------------------------------------------------------ +| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time | Pstart| Pstop | +------------------------------------------------------------------------------------------------ +| 0 | SELECT STATEMENT | | | | 9 (100)| | | | +| 1 | SORT AGGREGATE | | 1 | 4 | | | | | +| 2 | PARTITION RANGE SINGLE| | 1 | 4 | 9 (0)| 00:00:01 | 1 | 1 | +|* 3 | TABLE ACCESS FULL | T2 | 1 | 4 | 9 (0)| 00:00:01 | 1 | 1 | +------------------------------------------------------------------------------------------------ + +Predicate Information (identified by operation id): +--------------------------------------------------- + + 3 - filter("ID"=1) + + +20 rows selected. + + + COUNT(*) +---------- + 0 + + +PLAN_TABLE_OUTPUT +------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ +SQL_ID dcvq5bcm8yqm9, child number 0 +------------------------------------- +select /* TESTFG */ count(*) from t2 where id = 1+150000 + +Plan hash value: 2457353553 + +------------------------------------------------------------------------------------------------ +| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time | Pstart| Pstop | +------------------------------------------------------------------------------------------------ +| 0 | SELECT STATEMENT | | | | 9 (100)| | | | +| 1 | SORT AGGREGATE | | 1 | 5 | | | | | +| 2 | PARTITION RANGE SINGLE| | 1 | 5 | 9 (0)| 00:00:01 | 2 | 2 | +|* 3 | TABLE ACCESS FULL | T2 | 1 | 5 | 9 (0)| 00:00:01 | 2 | 2 | +------------------------------------------------------------------------------------------------ + +Predicate Information (identified by operation id): +--------------------------------------------------- + + 3 - filter("ID"=150001) + + +20 rows selected. + + + COUNT(*) +---------- + 2 + + +PLAN_TABLE_OUTPUT +------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ +SQL_ID 9jh4ms6ruztw2, child number 0 +------------------------------------- +select /* TESTFG */ count(*) from t2 where val1 = 1 + +Plan hash value: 611317447 + +--------------------------------------------------------------------------------------------- +| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time | Pstart| Pstop | +--------------------------------------------------------------------------------------------- +| 0 | SELECT STATEMENT | | | | 16 (100)| | | | +| 1 | SORT AGGREGATE | | 1 | 4 | | | | | +| 2 | PARTITION RANGE ALL| | 2 | 8 | 16 (0)| 00:00:01 | 1 | 2 | +|* 3 | TABLE ACCESS FULL | T2 | 2 | 8 | 16 (0)| 00:00:01 | 1 | 2 | +--------------------------------------------------------------------------------------------- + +Predicate Information (identified by operation id): +--------------------------------------------------- + + 3 - filter("VAL1"=1) + + +20 rows selected. + + + SUM(VAL2) +---------- + 49995000 + + +PLAN_TABLE_OUTPUT +------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ +SQL_ID 31pkfzpmx1b62, child number 0 +------------------------------------- +select /* TESTFG */ /*+ INDEX_FFS(t new1) */ sum(val2) from t1 t + +Plan hash value: 3724264953 + +--------------------------------------------------------------------------- +| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time | +--------------------------------------------------------------------------- +| 0 | SELECT STATEMENT | | | | 9 (100)| | +| 1 | SORT AGGREGATE | | 1 | 4 | | | +| 2 | TABLE ACCESS FULL| T1 | 9999 | 39996 | 9 (0)| 00:00:01 | +--------------------------------------------------------------------------- + + +14 rows selected. + + + COUNT(*) +---------- + 9998 + + +PLAN_TABLE_OUTPUT +------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ +SQL_ID czjk2xd0vn20k, child number 0 +------------------------------------- +select /* TESTFG */ count(*) from t2 where id < (select max(id) from t1) + +Plan hash value: 771265474 + +-------------------------------------------------------------------------------------------------- +| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time | Pstart| Pstop | +-------------------------------------------------------------------------------------------------- +| 0 | SELECT STATEMENT | | | | 25 (100)| | | | +| 1 | SORT AGGREGATE | | 1 | 5 | | | | | +| 2 | PARTITION RANGE ITERATOR| | 1000 | 5000 | 16 (0)| 00:00:01 | 1 | KEY | +|* 3 | TABLE ACCESS FULL | T2 | 1000 | 5000 | 16 (0)| 00:00:01 | 1 | KEY | +| 4 | SORT AGGREGATE | | 1 | 4 | | | | | +| 5 | TABLE ACCESS FULL | T1 | 9999 | 39996 | 9 (0)| 00:00:01 | | | +-------------------------------------------------------------------------------------------------- + +Predicate Information (identified by operation id): +--------------------------------------------------- + + 3 - filter("ID"<) + + +22 rows selected. + + + COUNT(*) +---------- + 49 + + +PLAN_TABLE_OUTPUT +------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ +SQL_ID ax2r0jyjs0hbb, child number 0 +------------------------------------- +select /* TESTFG */ /*+ USE_INVISIBLE_INDEXES */ count(*) from t1 where +val2<50 + +Plan hash value: 3724264953 + +--------------------------------------------------------------------------- +| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time | +--------------------------------------------------------------------------- +| 0 | SELECT STATEMENT | | | | 9 (100)| | +| 1 | SORT AGGREGATE | | 1 | 4 | | | +|* 2 | TABLE ACCESS FULL| T1 | 49 | 196 | 9 (0)| 00:00:01 | +--------------------------------------------------------------------------- + +Predicate Information (identified by operation id): +--------------------------------------------------- + + 2 - filter("VAL2"<50) + + +20 rows selected. + + + COUNT(*) +---------- + 9999 + + +PLAN_TABLE_OUTPUT +------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ +SQL_ID 7c65qbgku7can, child number 0 +------------------------------------- +select /* TESTFG */ count(*) from t2 partition (p2) + +Plan hash value: 2457353553 + +---------------------------------------------------------------------------------------- +| Id | Operation | Name | Rows | Cost (%CPU)| Time | Pstart| Pstop | +---------------------------------------------------------------------------------------- +| 0 | SELECT STATEMENT | | | 9 (100)| | | | +| 1 | SORT AGGREGATE | | 1 | | | | | +| 2 | PARTITION RANGE SINGLE| | 9999 | 9 (0)| 00:00:01 | 2 | 2 | +| 3 | TABLE ACCESS FULL | T2 | 9999 | 9 (0)| 00:00:01 | 2 | 2 | +---------------------------------------------------------------------------------------- + + +15 rows selected. + + + COUNT(*) +---------- + 9999 + + +PLAN_TABLE_OUTPUT +------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ +SQL_ID 221p0y74xg65x, child number 0 +------------------------------------- +select /* TESTFG */ count(*) from t2 partition (p1) + +Plan hash value: 2457353553 + +---------------------------------------------------------------------------------------- +| Id | Operation | Name | Rows | Cost (%CPU)| Time | Pstart| Pstop | +---------------------------------------------------------------------------------------- +| 0 | SELECT STATEMENT | | | 9 (100)| | | | +| 1 | SORT AGGREGATE | | 1 | | | | | +| 2 | PARTITION RANGE SINGLE| | 9999 | 9 (0)| 00:00:01 | 1 | 1 | +| 3 | TABLE ACCESS FULL | T2 | 9999 | 9 (0)| 00:00:01 | 1 | 1 | +---------------------------------------------------------------------------------------- + + +15 rows selected. + + +49 rows updated. + + +98 rows updated. + + +49 rows updated. + + +49 rows updated. + + +Commit complete. + + +SQL_ID SQL_TEXT CHILD_NUMBER IS_SHAREABLE OBJECT_STATUS INVALIDATIONS IS_ROLLING_INVALID IS_ROLLING_REFRESH_I DDL_NO_INVALIDATE +------------- ------------------------------------------------------------------------------------- ------------ -------------------- ------------------- ------------- -------------------- -------------------- -------------------- +31pkfzpmx1b62 select /* TESTFG */ /*+ INDEX_FFS(t new1) */ sum(val2) from t1 t 0 Y VALID 0 N N N +ax2r0jyjs0hbb select /* TESTFG */ /*+ USE_INVISIBLE_INDEXES */ count(*) from t1 where val2<50 0 Y VALID 0 N N N +cf016xd0knzrh select /* TESTFG */ count(*) from t1 where id = 1 0 Y VALID 0 N N N +gvd4z9ba14uh3 select /* TESTFG */ count(*) from t1 where val1 = 1 0 Y VALID 0 N N N +221p0y74xg65x select /* TESTFG */ count(*) from t2 partition (p1) 0 Y VALID 0 N N N +7c65qbgku7can select /* TESTFG */ count(*) from t2 partition (p2) 0 Y VALID 0 N N N +czjk2xd0vn20k select /* TESTFG */ count(*) from t2 where id < (select max(id) from t1) 0 Y VALID 0 N N N +1y9y6gg3r5sry select /* TESTFG */ count(*) from t2 where id = 1 0 Y VALID 0 N N N +dcvq5bcm8yqm9 select /* TESTFG */ count(*) from t2 where id = 1+150000 0 Y VALID 0 N N N +9jh4ms6ruztw2 select /* TESTFG */ count(*) from t2 where val1 = 1 0 Y VALID 0 N N N +bcsj7p128xh77 update /* TESTFG */ t1 set val1 = val1 + 1 where id < 50 0 Y VALID 0 N N N +bdhfwydh894qk update /* TESTFG */ t1 set val1 = val1 + 1 where val1 < 50 0 Y VALID 0 N N N +6a6m4fq5b9v7r update /* TESTFG */ t2 set val1 = val1 + 1 where id < 50 0 Y VALID 0 N N N +24qkp15shu1gp update /* TESTFG */ t2 set val1 = val1 + 1 where val1 < 50 0 Y VALID 0 N N N + +14 rows selected. + + +no rows selected + +SQL> alter table t1 parallel 4 deferred invalidation; + +Table altered. + +SQL> alter table t2 parallel 4 deferred invalidation; + +Table altered. + +SQL> set echo off + +SQL_ID SQL_TEXT CHILD_NUMBER IS_SHAREABLE OBJECT_STATUS INVALIDATIONS IS_ROLLING_INVALID IS_ROLLING_REFRESH_I DDL_NO_INVALIDATE +------------- ------------------------------------------------------------------------------------- ------------ -------------------- ------------------- ------------- -------------------- -------------------- -------------------- +31pkfzpmx1b62 select /* TESTFG */ /*+ INDEX_FFS(t new1) */ sum(val2) from t1 t 0 Y VALID 0 Y N N +ax2r0jyjs0hbb select /* TESTFG */ /*+ USE_INVISIBLE_INDEXES */ count(*) from t1 where val2<50 0 Y VALID 0 Y N N +cf016xd0knzrh select /* TESTFG */ count(*) from t1 where id = 1 0 Y VALID 0 Y N N +gvd4z9ba14uh3 select /* TESTFG */ count(*) from t1 where val1 = 1 0 Y VALID 0 Y N N +221p0y74xg65x select /* TESTFG */ count(*) from t2 partition (p1) 0 Y VALID 0 Y N N +7c65qbgku7can select /* TESTFG */ count(*) from t2 partition (p2) 0 Y VALID 0 Y N N +czjk2xd0vn20k select /* TESTFG */ count(*) from t2 where id < (select max(id) from t1) 0 Y VALID 0 Y N N +1y9y6gg3r5sry select /* TESTFG */ count(*) from t2 where id = 1 0 Y VALID 0 Y N N +dcvq5bcm8yqm9 select /* TESTFG */ count(*) from t2 where id = 1+150000 0 Y VALID 0 Y N N +9jh4ms6ruztw2 select /* TESTFG */ count(*) from t2 where val1 = 1 0 Y VALID 0 Y N N +bcsj7p128xh77 update /* TESTFG */ t1 set val1 = val1 + 1 where id < 50 0 Y VALID 0 Y N N +bdhfwydh894qk update /* TESTFG */ t1 set val1 = val1 + 1 where val1 < 50 0 Y VALID 0 Y N N +6a6m4fq5b9v7r update /* TESTFG */ t2 set val1 = val1 + 1 where id < 50 0 Y VALID 0 Y N N +24qkp15shu1gp update /* TESTFG */ t2 set val1 = val1 + 1 where val1 < 50 0 Y VALID 0 Y N N + +14 rows selected. + + +no rows selected + +SQL> +SQL> @tab +SQL> drop table t1; + +Table dropped. + +SQL> drop table t2; + +Table dropped. + +SQL> +SQL> create table t1 (id number(10) not null, val1 number(10) not null, val2 number(10) not null); + +Table created. + +SQL> +SQL> create table t2 (id number(10) not null, val1 number(10) not null, val2 number(10) not null) + 2 partition by range (id) ( + 3 partition p1 values less than (100000) + 4 , partition p2 values less than (200000) + 5 ) + 6 / + +Table created. + +SQL> +SQL> insert into t1 select rownum,rownum,rownum from ( + 2 select 1 + 3 from dual connect by rownum < 10000); + +9999 rows created. + +SQL> +SQL> insert into t2 select rownum,rownum,rownum from ( + 2 select 1 + 3 from dual connect by rownum < 10000); + +9999 rows created. + +SQL> +SQL> insert into t2 select rownum+100000,rownum,rownum from ( + 2 select 1 + 3 from dual connect by rownum < 10000); + +9999 rows created. + +SQL> +SQL> +SQL> create index t1i on t1 (id); + +Index created. + +SQL> create index t2i on t2 (id) local ( + 2 partition p1i, + 3 partition p2i); + +Index created. + +SQL> +SQL> exec dbms_stats.gather_table_stats(ownname=>user,tabname=>'t1'); + +PL/SQL procedure successfully completed. + +SQL> exec dbms_stats.gather_table_stats(ownname=>user,tabname=>'t2'); + +PL/SQL procedure successfully completed. + +SQL> prompt rename +rename +SQL> set echo on +SQL> drop index t1i; + +Index dropped. + +SQL> drop index t2i; + +Index dropped. + +SQL> set echo off + +System altered. + + + COUNT(*) +---------- + 1 + + +PLAN_TABLE_OUTPUT +------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ +SQL_ID cf016xd0knzrh, child number 0 +------------------------------------- +select /* TESTFG */ count(*) from t1 where id = 1 + +Plan hash value: 3724264953 + +--------------------------------------------------------------------------- +| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time | +--------------------------------------------------------------------------- +| 0 | SELECT STATEMENT | | | | 9 (100)| | +| 1 | SORT AGGREGATE | | 1 | 4 | | | +|* 2 | TABLE ACCESS FULL| T1 | 1 | 4 | 9 (0)| 00:00:01 | +--------------------------------------------------------------------------- + +Predicate Information (identified by operation id): +--------------------------------------------------- + + 2 - filter("ID"=1) + + +19 rows selected. + + + COUNT(*) +---------- + 1 + + +PLAN_TABLE_OUTPUT +------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ +SQL_ID gvd4z9ba14uh3, child number 0 +------------------------------------- +select /* TESTFG */ count(*) from t1 where val1 = 1 + +Plan hash value: 3724264953 + +--------------------------------------------------------------------------- +| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time | +--------------------------------------------------------------------------- +| 0 | SELECT STATEMENT | | | | 9 (100)| | +| 1 | SORT AGGREGATE | | 1 | 4 | | | +|* 2 | TABLE ACCESS FULL| T1 | 1 | 4 | 9 (0)| 00:00:01 | +--------------------------------------------------------------------------- + +Predicate Information (identified by operation id): +--------------------------------------------------- + + 2 - filter("VAL1"=1) + + +19 rows selected. + + + COUNT(*) +---------- + 1 + + +PLAN_TABLE_OUTPUT +------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ +SQL_ID 1y9y6gg3r5sry, child number 0 +------------------------------------- +select /* TESTFG */ count(*) from t2 where id = 1 + +Plan hash value: 2457353553 + +------------------------------------------------------------------------------------------------ +| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time | Pstart| Pstop | +------------------------------------------------------------------------------------------------ +| 0 | SELECT STATEMENT | | | | 9 (100)| | | | +| 1 | SORT AGGREGATE | | 1 | 4 | | | | | +| 2 | PARTITION RANGE SINGLE| | 1 | 4 | 9 (0)| 00:00:01 | 1 | 1 | +|* 3 | TABLE ACCESS FULL | T2 | 1 | 4 | 9 (0)| 00:00:01 | 1 | 1 | +------------------------------------------------------------------------------------------------ + +Predicate Information (identified by operation id): +--------------------------------------------------- + + 3 - filter("ID"=1) + + +20 rows selected. + + + COUNT(*) +---------- + 0 + + +PLAN_TABLE_OUTPUT +------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ +SQL_ID dcvq5bcm8yqm9, child number 0 +------------------------------------- +select /* TESTFG */ count(*) from t2 where id = 1+150000 + +Plan hash value: 2457353553 + +------------------------------------------------------------------------------------------------ +| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time | Pstart| Pstop | +------------------------------------------------------------------------------------------------ +| 0 | SELECT STATEMENT | | | | 9 (100)| | | | +| 1 | SORT AGGREGATE | | 1 | 5 | | | | | +| 2 | PARTITION RANGE SINGLE| | 1 | 5 | 9 (0)| 00:00:01 | 2 | 2 | +|* 3 | TABLE ACCESS FULL | T2 | 1 | 5 | 9 (0)| 00:00:01 | 2 | 2 | +------------------------------------------------------------------------------------------------ + +Predicate Information (identified by operation id): +--------------------------------------------------- + + 3 - filter("ID"=150001) + + +20 rows selected. + + + COUNT(*) +---------- + 2 + + +PLAN_TABLE_OUTPUT +------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ +SQL_ID 9jh4ms6ruztw2, child number 0 +------------------------------------- +select /* TESTFG */ count(*) from t2 where val1 = 1 + +Plan hash value: 611317447 + +--------------------------------------------------------------------------------------------- +| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time | Pstart| Pstop | +--------------------------------------------------------------------------------------------- +| 0 | SELECT STATEMENT | | | | 16 (100)| | | | +| 1 | SORT AGGREGATE | | 1 | 4 | | | | | +| 2 | PARTITION RANGE ALL| | 2 | 8 | 16 (0)| 00:00:01 | 1 | 2 | +|* 3 | TABLE ACCESS FULL | T2 | 2 | 8 | 16 (0)| 00:00:01 | 1 | 2 | +--------------------------------------------------------------------------------------------- + +Predicate Information (identified by operation id): +--------------------------------------------------- + + 3 - filter("VAL1"=1) + + +20 rows selected. + + + SUM(VAL2) +---------- + 49995000 + + +PLAN_TABLE_OUTPUT +------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ +SQL_ID 31pkfzpmx1b62, child number 0 +------------------------------------- +select /* TESTFG */ /*+ INDEX_FFS(t new1) */ sum(val2) from t1 t + +Plan hash value: 3724264953 + +--------------------------------------------------------------------------- +| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time | +--------------------------------------------------------------------------- +| 0 | SELECT STATEMENT | | | | 9 (100)| | +| 1 | SORT AGGREGATE | | 1 | 4 | | | +| 2 | TABLE ACCESS FULL| T1 | 9999 | 39996 | 9 (0)| 00:00:01 | +--------------------------------------------------------------------------- + + +14 rows selected. + + + COUNT(*) +---------- + 9998 + + +PLAN_TABLE_OUTPUT +------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ +SQL_ID czjk2xd0vn20k, child number 0 +------------------------------------- +select /* TESTFG */ count(*) from t2 where id < (select max(id) from t1) + +Plan hash value: 771265474 + +-------------------------------------------------------------------------------------------------- +| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time | Pstart| Pstop | +-------------------------------------------------------------------------------------------------- +| 0 | SELECT STATEMENT | | | | 25 (100)| | | | +| 1 | SORT AGGREGATE | | 1 | 5 | | | | | +| 2 | PARTITION RANGE ITERATOR| | 1000 | 5000 | 16 (0)| 00:00:01 | 1 | KEY | +|* 3 | TABLE ACCESS FULL | T2 | 1000 | 5000 | 16 (0)| 00:00:01 | 1 | KEY | +| 4 | SORT AGGREGATE | | 1 | 4 | | | | | +| 5 | TABLE ACCESS FULL | T1 | 9999 | 39996 | 9 (0)| 00:00:01 | | | +-------------------------------------------------------------------------------------------------- + +Predicate Information (identified by operation id): +--------------------------------------------------- + + 3 - filter("ID"<) + + +22 rows selected. + + + COUNT(*) +---------- + 49 + + +PLAN_TABLE_OUTPUT +------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ +SQL_ID ax2r0jyjs0hbb, child number 0 +------------------------------------- +select /* TESTFG */ /*+ USE_INVISIBLE_INDEXES */ count(*) from t1 where +val2<50 + +Plan hash value: 3724264953 + +--------------------------------------------------------------------------- +| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time | +--------------------------------------------------------------------------- +| 0 | SELECT STATEMENT | | | | 9 (100)| | +| 1 | SORT AGGREGATE | | 1 | 4 | | | +|* 2 | TABLE ACCESS FULL| T1 | 49 | 196 | 9 (0)| 00:00:01 | +--------------------------------------------------------------------------- + +Predicate Information (identified by operation id): +--------------------------------------------------- + + 2 - filter("VAL2"<50) + + +20 rows selected. + + + COUNT(*) +---------- + 9999 + + +PLAN_TABLE_OUTPUT +------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ +SQL_ID 7c65qbgku7can, child number 0 +------------------------------------- +select /* TESTFG */ count(*) from t2 partition (p2) + +Plan hash value: 2457353553 + +---------------------------------------------------------------------------------------- +| Id | Operation | Name | Rows | Cost (%CPU)| Time | Pstart| Pstop | +---------------------------------------------------------------------------------------- +| 0 | SELECT STATEMENT | | | 9 (100)| | | | +| 1 | SORT AGGREGATE | | 1 | | | | | +| 2 | PARTITION RANGE SINGLE| | 9999 | 9 (0)| 00:00:01 | 2 | 2 | +| 3 | TABLE ACCESS FULL | T2 | 9999 | 9 (0)| 00:00:01 | 2 | 2 | +---------------------------------------------------------------------------------------- + + +15 rows selected. + + + COUNT(*) +---------- + 9999 + + +PLAN_TABLE_OUTPUT +------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ +SQL_ID 221p0y74xg65x, child number 0 +------------------------------------- +select /* TESTFG */ count(*) from t2 partition (p1) + +Plan hash value: 2457353553 + +---------------------------------------------------------------------------------------- +| Id | Operation | Name | Rows | Cost (%CPU)| Time | Pstart| Pstop | +---------------------------------------------------------------------------------------- +| 0 | SELECT STATEMENT | | | 9 (100)| | | | +| 1 | SORT AGGREGATE | | 1 | | | | | +| 2 | PARTITION RANGE SINGLE| | 9999 | 9 (0)| 00:00:01 | 1 | 1 | +| 3 | TABLE ACCESS FULL | T2 | 9999 | 9 (0)| 00:00:01 | 1 | 1 | +---------------------------------------------------------------------------------------- + + +15 rows selected. + + +49 rows updated. + + +98 rows updated. + + +49 rows updated. + + +49 rows updated. + + +Commit complete. + + +SQL_ID SQL_TEXT CHILD_NUMBER IS_SHAREABLE OBJECT_STATUS INVALIDATIONS IS_ROLLING_INVALID IS_ROLLING_REFRESH_I DDL_NO_INVALIDATE +------------- ------------------------------------------------------------------------------------- ------------ -------------------- ------------------- ------------- -------------------- -------------------- -------------------- +31pkfzpmx1b62 select /* TESTFG */ /*+ INDEX_FFS(t new1) */ sum(val2) from t1 t 0 Y VALID 0 N N N +ax2r0jyjs0hbb select /* TESTFG */ /*+ USE_INVISIBLE_INDEXES */ count(*) from t1 where val2<50 0 Y VALID 0 N N N +cf016xd0knzrh select /* TESTFG */ count(*) from t1 where id = 1 0 Y VALID 0 N N N +gvd4z9ba14uh3 select /* TESTFG */ count(*) from t1 where val1 = 1 0 Y VALID 0 N N N +221p0y74xg65x select /* TESTFG */ count(*) from t2 partition (p1) 0 Y VALID 0 N N N +7c65qbgku7can select /* TESTFG */ count(*) from t2 partition (p2) 0 Y VALID 0 N N N +czjk2xd0vn20k select /* TESTFG */ count(*) from t2 where id < (select max(id) from t1) 0 Y VALID 0 N N N +1y9y6gg3r5sry select /* TESTFG */ count(*) from t2 where id = 1 0 Y VALID 0 N N N +dcvq5bcm8yqm9 select /* TESTFG */ count(*) from t2 where id = 1+150000 0 Y VALID 0 N N N +9jh4ms6ruztw2 select /* TESTFG */ count(*) from t2 where val1 = 1 0 Y VALID 0 N N N +bcsj7p128xh77 update /* TESTFG */ t1 set val1 = val1 + 1 where id < 50 0 Y VALID 0 N N N +bdhfwydh894qk update /* TESTFG */ t1 set val1 = val1 + 1 where val1 < 50 0 Y VALID 0 N N N +6a6m4fq5b9v7r update /* TESTFG */ t2 set val1 = val1 + 1 where id < 50 0 Y VALID 0 N N N +24qkp15shu1gp update /* TESTFG */ t2 set val1 = val1 + 1 where val1 < 50 0 Y VALID 0 N N N + +14 rows selected. + + +no rows selected + +SQL> alter table t1 read only deferred invalidation; + +Table altered. + +SQL> alter table t2 read only deferred invalidation; + +Table altered. + +SQL> set echo off + +SQL_ID SQL_TEXT CHILD_NUMBER IS_SHAREABLE OBJECT_STATUS INVALIDATIONS IS_ROLLING_INVALID IS_ROLLING_REFRESH_I DDL_NO_INVALIDATE +------------- ------------------------------------------------------------------------------------- ------------ -------------------- ------------------- ------------- -------------------- -------------------- -------------------- +31pkfzpmx1b62 select /* TESTFG */ /*+ INDEX_FFS(t new1) */ sum(val2) from t1 t 0 Y VALID 0 N N Y +ax2r0jyjs0hbb select /* TESTFG */ /*+ USE_INVISIBLE_INDEXES */ count(*) from t1 where val2<50 0 Y VALID 0 N N Y +cf016xd0knzrh select /* TESTFG */ count(*) from t1 where id = 1 0 Y VALID 0 N N Y +gvd4z9ba14uh3 select /* TESTFG */ count(*) from t1 where val1 = 1 0 Y VALID 0 N N Y +221p0y74xg65x select /* TESTFG */ count(*) from t2 partition (p1) 0 Y VALID 0 N N Y +7c65qbgku7can select /* TESTFG */ count(*) from t2 partition (p2) 0 Y VALID 0 N N Y +czjk2xd0vn20k select /* TESTFG */ count(*) from t2 where id < (select max(id) from t1) 0 Y VALID 0 N N Y +1y9y6gg3r5sry select /* TESTFG */ count(*) from t2 where id = 1 0 Y VALID 0 N N Y +dcvq5bcm8yqm9 select /* TESTFG */ count(*) from t2 where id = 1+150000 0 Y VALID 0 N N Y +9jh4ms6ruztw2 select /* TESTFG */ count(*) from t2 where val1 = 1 0 Y VALID 0 N N Y +bcsj7p128xh77 update /* TESTFG */ t1 set val1 = val1 + 1 where id < 50 0 Y INVALID_UNAUTH 1 N N N +bdhfwydh894qk update /* TESTFG */ t1 set val1 = val1 + 1 where val1 < 50 0 Y INVALID_UNAUTH 1 N N N +6a6m4fq5b9v7r update /* TESTFG */ t2 set val1 = val1 + 1 where id < 50 0 Y VALID 0 N Y N +24qkp15shu1gp update /* TESTFG */ t2 set val1 = val1 + 1 where val1 < 50 0 Y VALID 0 N Y N + +14 rows selected. + + +no rows selected + +SQL> +SQL> @tab +SQL> drop table t1; + +Table dropped. + +SQL> drop table t2; + +Table dropped. + +SQL> +SQL> create table t1 (id number(10) not null, val1 number(10) not null, val2 number(10) not null); + +Table created. + +SQL> +SQL> create table t2 (id number(10) not null, val1 number(10) not null, val2 number(10) not null) + 2 partition by range (id) ( + 3 partition p1 values less than (100000) + 4 , partition p2 values less than (200000) + 5 ) + 6 / + +Table created. + +SQL> +SQL> insert into t1 select rownum,rownum,rownum from ( + 2 select 1 + 3 from dual connect by rownum < 10000); + +9999 rows created. + +SQL> +SQL> insert into t2 select rownum,rownum,rownum from ( + 2 select 1 + 3 from dual connect by rownum < 10000); + +9999 rows created. + +SQL> +SQL> insert into t2 select rownum+100000,rownum,rownum from ( + 2 select 1 + 3 from dual connect by rownum < 10000); + +9999 rows created. + +SQL> +SQL> +SQL> create index t1i on t1 (id); + +Index created. + +SQL> create index t2i on t2 (id) local ( + 2 partition p1i, + 3 partition p2i); + +Index created. + +SQL> +SQL> exec dbms_stats.gather_table_stats(ownname=>user,tabname=>'t1'); + +PL/SQL procedure successfully completed. + +SQL> exec dbms_stats.gather_table_stats(ownname=>user,tabname=>'t2'); + +PL/SQL procedure successfully completed. + +SQL> prompt rename +rename +SQL> set echo on +SQL> drop index t1i; + +Index dropped. + +SQL> drop index t2i; + +Index dropped. + +SQL> set echo off + +System altered. + + + COUNT(*) +---------- + 1 + + +PLAN_TABLE_OUTPUT +------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ +SQL_ID cf016xd0knzrh, child number 0 +------------------------------------- +select /* TESTFG */ count(*) from t1 where id = 1 + +Plan hash value: 3724264953 + +--------------------------------------------------------------------------- +| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time | +--------------------------------------------------------------------------- +| 0 | SELECT STATEMENT | | | | 9 (100)| | +| 1 | SORT AGGREGATE | | 1 | 4 | | | +|* 2 | TABLE ACCESS FULL| T1 | 1 | 4 | 9 (0)| 00:00:01 | +--------------------------------------------------------------------------- + +Predicate Information (identified by operation id): +--------------------------------------------------- + + 2 - filter("ID"=1) + + +19 rows selected. + + + COUNT(*) +---------- + 1 + + +PLAN_TABLE_OUTPUT +------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ +SQL_ID gvd4z9ba14uh3, child number 0 +------------------------------------- +select /* TESTFG */ count(*) from t1 where val1 = 1 + +Plan hash value: 3724264953 + +--------------------------------------------------------------------------- +| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time | +--------------------------------------------------------------------------- +| 0 | SELECT STATEMENT | | | | 9 (100)| | +| 1 | SORT AGGREGATE | | 1 | 4 | | | +|* 2 | TABLE ACCESS FULL| T1 | 1 | 4 | 9 (0)| 00:00:01 | +--------------------------------------------------------------------------- + +Predicate Information (identified by operation id): +--------------------------------------------------- + + 2 - filter("VAL1"=1) + + +19 rows selected. + + + COUNT(*) +---------- + 1 + + +PLAN_TABLE_OUTPUT +------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ +SQL_ID 1y9y6gg3r5sry, child number 0 +------------------------------------- +select /* TESTFG */ count(*) from t2 where id = 1 + +Plan hash value: 2457353553 + +------------------------------------------------------------------------------------------------ +| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time | Pstart| Pstop | +------------------------------------------------------------------------------------------------ +| 0 | SELECT STATEMENT | | | | 9 (100)| | | | +| 1 | SORT AGGREGATE | | 1 | 4 | | | | | +| 2 | PARTITION RANGE SINGLE| | 1 | 4 | 9 (0)| 00:00:01 | 1 | 1 | +|* 3 | TABLE ACCESS FULL | T2 | 1 | 4 | 9 (0)| 00:00:01 | 1 | 1 | +------------------------------------------------------------------------------------------------ + +Predicate Information (identified by operation id): +--------------------------------------------------- + + 3 - filter("ID"=1) + + +20 rows selected. + + + COUNT(*) +---------- + 0 + + +PLAN_TABLE_OUTPUT +------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ +SQL_ID dcvq5bcm8yqm9, child number 0 +------------------------------------- +select /* TESTFG */ count(*) from t2 where id = 1+150000 + +Plan hash value: 2457353553 + +------------------------------------------------------------------------------------------------ +| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time | Pstart| Pstop | +------------------------------------------------------------------------------------------------ +| 0 | SELECT STATEMENT | | | | 9 (100)| | | | +| 1 | SORT AGGREGATE | | 1 | 5 | | | | | +| 2 | PARTITION RANGE SINGLE| | 1 | 5 | 9 (0)| 00:00:01 | 2 | 2 | +|* 3 | TABLE ACCESS FULL | T2 | 1 | 5 | 9 (0)| 00:00:01 | 2 | 2 | +------------------------------------------------------------------------------------------------ + +Predicate Information (identified by operation id): +--------------------------------------------------- + + 3 - filter("ID"=150001) + + +20 rows selected. + + + COUNT(*) +---------- + 2 + + +PLAN_TABLE_OUTPUT +------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ +SQL_ID 9jh4ms6ruztw2, child number 0 +------------------------------------- +select /* TESTFG */ count(*) from t2 where val1 = 1 + +Plan hash value: 611317447 + +--------------------------------------------------------------------------------------------- +| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time | Pstart| Pstop | +--------------------------------------------------------------------------------------------- +| 0 | SELECT STATEMENT | | | | 16 (100)| | | | +| 1 | SORT AGGREGATE | | 1 | 4 | | | | | +| 2 | PARTITION RANGE ALL| | 2 | 8 | 16 (0)| 00:00:01 | 1 | 2 | +|* 3 | TABLE ACCESS FULL | T2 | 2 | 8 | 16 (0)| 00:00:01 | 1 | 2 | +--------------------------------------------------------------------------------------------- + +Predicate Information (identified by operation id): +--------------------------------------------------- + + 3 - filter("VAL1"=1) + + +20 rows selected. + + + SUM(VAL2) +---------- + 49995000 + + +PLAN_TABLE_OUTPUT +------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ +SQL_ID 31pkfzpmx1b62, child number 0 +------------------------------------- +select /* TESTFG */ /*+ INDEX_FFS(t new1) */ sum(val2) from t1 t + +Plan hash value: 3724264953 + +--------------------------------------------------------------------------- +| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time | +--------------------------------------------------------------------------- +| 0 | SELECT STATEMENT | | | | 9 (100)| | +| 1 | SORT AGGREGATE | | 1 | 4 | | | +| 2 | TABLE ACCESS FULL| T1 | 9999 | 39996 | 9 (0)| 00:00:01 | +--------------------------------------------------------------------------- + + +14 rows selected. + + + COUNT(*) +---------- + 9998 + + +PLAN_TABLE_OUTPUT +------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ +SQL_ID czjk2xd0vn20k, child number 0 +------------------------------------- +select /* TESTFG */ count(*) from t2 where id < (select max(id) from t1) + +Plan hash value: 771265474 + +-------------------------------------------------------------------------------------------------- +| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time | Pstart| Pstop | +-------------------------------------------------------------------------------------------------- +| 0 | SELECT STATEMENT | | | | 25 (100)| | | | +| 1 | SORT AGGREGATE | | 1 | 5 | | | | | +| 2 | PARTITION RANGE ITERATOR| | 1000 | 5000 | 16 (0)| 00:00:01 | 1 | KEY | +|* 3 | TABLE ACCESS FULL | T2 | 1000 | 5000 | 16 (0)| 00:00:01 | 1 | KEY | +| 4 | SORT AGGREGATE | | 1 | 4 | | | | | +| 5 | TABLE ACCESS FULL | T1 | 9999 | 39996 | 9 (0)| 00:00:01 | | | +-------------------------------------------------------------------------------------------------- + +Predicate Information (identified by operation id): +--------------------------------------------------- + + 3 - filter("ID"<) + + +22 rows selected. + + + COUNT(*) +---------- + 49 + + +PLAN_TABLE_OUTPUT +------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ +SQL_ID ax2r0jyjs0hbb, child number 0 +------------------------------------- +select /* TESTFG */ /*+ USE_INVISIBLE_INDEXES */ count(*) from t1 where +val2<50 + +Plan hash value: 3724264953 + +--------------------------------------------------------------------------- +| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time | +--------------------------------------------------------------------------- +| 0 | SELECT STATEMENT | | | | 9 (100)| | +| 1 | SORT AGGREGATE | | 1 | 4 | | | +|* 2 | TABLE ACCESS FULL| T1 | 49 | 196 | 9 (0)| 00:00:01 | +--------------------------------------------------------------------------- + +Predicate Information (identified by operation id): +--------------------------------------------------- + + 2 - filter("VAL2"<50) + + +20 rows selected. + + + COUNT(*) +---------- + 9999 + + +PLAN_TABLE_OUTPUT +------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ +SQL_ID 7c65qbgku7can, child number 0 +------------------------------------- +select /* TESTFG */ count(*) from t2 partition (p2) + +Plan hash value: 2457353553 + +---------------------------------------------------------------------------------------- +| Id | Operation | Name | Rows | Cost (%CPU)| Time | Pstart| Pstop | +---------------------------------------------------------------------------------------- +| 0 | SELECT STATEMENT | | | 9 (100)| | | | +| 1 | SORT AGGREGATE | | 1 | | | | | +| 2 | PARTITION RANGE SINGLE| | 9999 | 9 (0)| 00:00:01 | 2 | 2 | +| 3 | TABLE ACCESS FULL | T2 | 9999 | 9 (0)| 00:00:01 | 2 | 2 | +---------------------------------------------------------------------------------------- + + +15 rows selected. + + + COUNT(*) +---------- + 9999 + + +PLAN_TABLE_OUTPUT +------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ +SQL_ID 221p0y74xg65x, child number 0 +------------------------------------- +select /* TESTFG */ count(*) from t2 partition (p1) + +Plan hash value: 2457353553 + +---------------------------------------------------------------------------------------- +| Id | Operation | Name | Rows | Cost (%CPU)| Time | Pstart| Pstop | +---------------------------------------------------------------------------------------- +| 0 | SELECT STATEMENT | | | 9 (100)| | | | +| 1 | SORT AGGREGATE | | 1 | | | | | +| 2 | PARTITION RANGE SINGLE| | 9999 | 9 (0)| 00:00:01 | 1 | 1 | +| 3 | TABLE ACCESS FULL | T2 | 9999 | 9 (0)| 00:00:01 | 1 | 1 | +---------------------------------------------------------------------------------------- + + +15 rows selected. + + +49 rows updated. + + +98 rows updated. + + +49 rows updated. + + +49 rows updated. + + +Commit complete. + + +SQL_ID SQL_TEXT CHILD_NUMBER IS_SHAREABLE OBJECT_STATUS INVALIDATIONS IS_ROLLING_INVALID IS_ROLLING_REFRESH_I DDL_NO_INVALIDATE +------------- ------------------------------------------------------------------------------------- ------------ -------------------- ------------------- ------------- -------------------- -------------------- -------------------- +31pkfzpmx1b62 select /* TESTFG */ /*+ INDEX_FFS(t new1) */ sum(val2) from t1 t 0 Y VALID 0 N N N +ax2r0jyjs0hbb select /* TESTFG */ /*+ USE_INVISIBLE_INDEXES */ count(*) from t1 where val2<50 0 Y VALID 0 N N N +cf016xd0knzrh select /* TESTFG */ count(*) from t1 where id = 1 0 Y VALID 0 N N N +gvd4z9ba14uh3 select /* TESTFG */ count(*) from t1 where val1 = 1 0 Y VALID 0 N N N +221p0y74xg65x select /* TESTFG */ count(*) from t2 partition (p1) 0 Y VALID 0 N N N +7c65qbgku7can select /* TESTFG */ count(*) from t2 partition (p2) 0 Y VALID 0 N N N +czjk2xd0vn20k select /* TESTFG */ count(*) from t2 where id < (select max(id) from t1) 0 Y VALID 0 N N N +1y9y6gg3r5sry select /* TESTFG */ count(*) from t2 where id = 1 0 Y VALID 0 N N N +dcvq5bcm8yqm9 select /* TESTFG */ count(*) from t2 where id = 1+150000 0 Y VALID 0 N N N +9jh4ms6ruztw2 select /* TESTFG */ count(*) from t2 where val1 = 1 0 Y VALID 0 N N N +bcsj7p128xh77 update /* TESTFG */ t1 set val1 = val1 + 1 where id < 50 0 Y VALID 0 N N N +bdhfwydh894qk update /* TESTFG */ t1 set val1 = val1 + 1 where val1 < 50 0 Y VALID 0 N N N +6a6m4fq5b9v7r update /* TESTFG */ t2 set val1 = val1 + 1 where id < 50 0 Y VALID 0 N N N +24qkp15shu1gp update /* TESTFG */ t2 set val1 = val1 + 1 where val1 < 50 0 Y VALID 0 N N N + +14 rows selected. + + +no rows selected + +SQL> alter table t2 modify default attributes tablespace system deferred invalidation; + +Table altered. + +SQL> set echo off + +SQL_ID SQL_TEXT CHILD_NUMBER IS_SHAREABLE OBJECT_STATUS INVALIDATIONS IS_ROLLING_INVALID IS_ROLLING_REFRESH_I DDL_NO_INVALIDATE +------------- ------------------------------------------------------------------------------------- ------------ -------------------- ------------------- ------------- -------------------- -------------------- -------------------- +31pkfzpmx1b62 select /* TESTFG */ /*+ INDEX_FFS(t new1) */ sum(val2) from t1 t 0 Y VALID 0 N N N +ax2r0jyjs0hbb select /* TESTFG */ /*+ USE_INVISIBLE_INDEXES */ count(*) from t1 where val2<50 0 Y VALID 0 N N N +cf016xd0knzrh select /* TESTFG */ count(*) from t1 where id = 1 0 Y VALID 0 N N N +gvd4z9ba14uh3 select /* TESTFG */ count(*) from t1 where val1 = 1 0 Y VALID 0 N N N +221p0y74xg65x select /* TESTFG */ count(*) from t2 partition (p1) 0 Y VALID 0 N N Y +7c65qbgku7can select /* TESTFG */ count(*) from t2 partition (p2) 0 Y VALID 0 N N Y +czjk2xd0vn20k select /* TESTFG */ count(*) from t2 where id < (select max(id) from t1) 0 Y VALID 0 N N Y +1y9y6gg3r5sry select /* TESTFG */ count(*) from t2 where id = 1 0 Y VALID 0 N N Y +dcvq5bcm8yqm9 select /* TESTFG */ count(*) from t2 where id = 1+150000 0 Y VALID 0 N N Y +9jh4ms6ruztw2 select /* TESTFG */ count(*) from t2 where val1 = 1 0 Y VALID 0 N N Y +bcsj7p128xh77 update /* TESTFG */ t1 set val1 = val1 + 1 where id < 50 0 Y VALID 0 N N N +bdhfwydh894qk update /* TESTFG */ t1 set val1 = val1 + 1 where val1 < 50 0 Y VALID 0 N N N +6a6m4fq5b9v7r update /* TESTFG */ t2 set val1 = val1 + 1 where id < 50 0 Y VALID 0 N N Y +24qkp15shu1gp update /* TESTFG */ t2 set val1 = val1 + 1 where val1 < 50 0 Y VALID 0 N N Y + +14 rows selected. + + +no rows selected + +SQL> +SQL> +SQL> +SQL> +SQL> +SQL> diff --git a/optimizer/fine_grained/tests.sql b/optimizer/fine_grained/tests.sql new file mode 100644 index 00000000..86110db2 --- /dev/null +++ b/optimizer/fine_grained/tests.sql @@ -0,0 +1,339 @@ +set tab on +set trim on +@tab +@q +@sql +set echo on +-- +-- CREATE INDEX (visible) +-- +create index new1 on t1 (val2) deferred invalidation; +create index new2 on t2 (val2) local deferred invalidation; +set echo off +@sql + +pause Press + +@tab +@q +@sql +set echo on +-- +-- CREATE INDEX (invisible) +-- +create index new1 on t1 (val2) invisible deferred invalidation; +create index new2 on t2 (val2) invisible local deferred invalidation; +set echo off +@sql + +pause Press + +@tab +@q +@sql +set echo on +-- +-- DROP INDEX +-- +drop index t1i deferred invalidation; +drop index t2i deferred invalidation; +set echo off +@sql + +pause Press + +@tab +@q +@sql +set echo on +-- +-- INDEX UNUSABLE +-- +alter index t1i unusable deferred invalidation; +alter index t2i modify partition p1i unusable deferred invalidation; + +alter session set CURSOR_INVALIDATION = 'deferred'; +alter index t2i modify partition p1i unusable; +alter session set CURSOR_INVALIDATION = 'immediate'; + +set echo off +@sql + +pause Press + +@tab +@q +@sql +set echo on +-- +-- INDEX REBUILD +-- +alter index t1i rebuild deferred invalidation; +alter index t2i rebuild partition p1i deferred invalidation; +set echo off +@sql + + +@tab +prompt Get rid of indexes... +set echo on +drop index t1i; +drop index t2i; +set echo off +@q +@sql +set echo on +-- +-- TRUNCATE TABLE/PARTITION +-- +-- ## NOTE Accepted but might not implemented because T1 is not partitioned... +truncate table t1 deferred invalidation; +alter table t2 truncate partition p1 deferred invalidation; +set echo off +prompt ### Truncate partition is fine-grained, but truncate table is not +@sql + + + +@tab +prompt Get rid of indexes... +set echo on +drop index t1i; +drop index t2i; +set echo off +@q +@sql +set echo on +-- +-- MOVE TABLE/PARTITION +-- +-- ## NOTE Accepted but might not implemented... +alter table t1 move deferred invalidation; +alter table t2 move partition p1 deferred invalidation; +set echo off +prompt ### Truncate partition is fine-grained, but truncate table is not +@sql + + +@tab +prompt Get rid of indexes... +set echo on +drop index t1i; +drop index t2i; +set echo off +@q +@sql +set echo on +-- +-- MOVE TABLE/PARTITION +-- +-- ## NOTE Accepted but might not be implemented... +alter table t1 move deferred invalidation; +alter table t2 move deferred invalidation; +set echo off +@sql + + + +@tab +prompt Get rid of indexes... +set echo on +drop index t1i; +drop index t2i; +set echo off +@q +@sql +set echo on +-- +-- TRUNCATE NON-PARTITIONED VS PARTITIONED TABLE +-- +-- ## NOTE Accepted but might not implemented for non-partitioned table +truncate table t1 deferred invalidation; +truncate table t2 deferred invalidation; +set echo off +prompt ### Truncate partition is fine-grained, but truncate table is not +@sql + +@tab +prompt Get rid of indexes... +set echo on +drop index t1i; +drop index t2i; +set echo off +@q +@sql +set echo on +-- +-- ADD PARTITION +-- +alter table t2 add partition p3 values less than (300000) deferred invalidation; +set echo off +@sql + + +@tab +prompt Get rid of indexes... +set echo on +drop index t1i; +drop index t2i; +alter table t2 add partition p3 values less than (300000); +set echo off +@q +@sql +set echo on +-- +-- DROP PARTITION +-- +alter table t2 drop partition p3 deferred invalidation; +set echo off +@sql + + +@tab +prompt Get rid of indexes... +set echo on +drop index t1i; +drop index t2i; +alter table t2 add partition p3 values less than (300000); +set echo off +@q +@sql +set echo on +-- +-- SPLIT PARTITION +-- +alter table t2 split partition p1 at (50000) into (partition p1,partition p1a) deferred invalidation; +set echo off +@sql + +@tab +prompt Get rid of indexes... +set echo on +drop index t1i; +drop index t2i; +alter table t2 add partition p3 values less than (300000); +set echo off +@q +@sql +set echo on +-- +-- MERGE PARTITION +-- Note: hash-ADD, COALESCE should behave in same way - not tested here +-- +alter table t2 merge partitions p2 to p3 into partition px deferred invalidation; +set echo off +@sql + +@tab +prompt Get rid of indexes... +set echo on +drop index t1i; +drop index t2i; +alter table t2 add partition p3 values less than (300000); +set echo off +@q +@sql +set echo on +-- +-- SHRINK +-- +-- Probably fails... +alter table t2 shrink space deferred invalidation; +set echo off +@sql + + +@tab +prompt Get rid of indexes... +set echo on +drop index t1i; +drop index t2i; +set echo off +@q +@sql +set echo on +-- +-- ADD CONSTRAINT +-- +-- ## NOTE Accepted but might not be implemeted. +alter table t1 add constraint mypk1 primary key (id) deferred invalidation; +alter table t2 add constraint mypk2 primary key (id) deferred invalidation; +set echo off +@sql +set echo on +-- ## NOTE Accepted but not not be implemeted. +alter table t1 drop constraint mypk1 deferred invalidation; + +set echo off + +@tab +prompt rename +set echo on +drop index t1i; +drop index t2i; +set echo off +@q +@sql +set echo on +alter table t2 rename partition p2 to p2x deferred invalidation; +set echo off +@sql +set echo on + +@tab +prompt rename +set echo on +drop index t1i; +drop index t2i; +set echo off +@q +@sql +set echo on +alter table t2 modify partition p2 read only deferred invalidation; +set echo off +@sql +set echo on + +@tab +prompt rename +set echo on +drop index t1i; +drop index t2i; +set echo off +@q +@sql +set echo on +alter table t1 parallel 4 deferred invalidation; +alter table t2 parallel 4 deferred invalidation; +set echo off +@sql +set echo on + +@tab +prompt rename +set echo on +drop index t1i; +drop index t2i; +set echo off +@q +@sql +set echo on +alter table t1 read only deferred invalidation; +alter table t2 read only deferred invalidation; +set echo off +@sql +set echo on + +@tab +prompt rename +set echo on +drop index t1i; +drop index t2i; +set echo off +@q +@sql +set echo on +alter table t2 modify default attributes tablespace system deferred invalidation; +set echo off +@sql +set echo on From 699046ab442943a637e71d3ddd2a160a59ae5cab Mon Sep 17 00:00:00 2001 From: nigelbayliss Date: Tue, 19 Jun 2018 12:38:08 +0100 Subject: [PATCH 02/16] fg readme --- optimizer/fine_grained/README.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/optimizer/fine_grained/README.md b/optimizer/fine_grained/README.md index 4580c4a3..ccc29f17 100644 --- a/optimizer/fine_grained/README.md +++ b/optimizer/fine_grained/README.md @@ -8,6 +8,8 @@ They are in quite a raw state because I originally wrote the examples for my own The example here was run on Oracle Database 12c Release 2. +The tests are not intended to be 'full coverage' - there may be other cases that work. + The test case drops tables T1 and T2. ### DISCLAIMER From eff9e8884bbc413cd358e056623b1ed5c10332f0 Mon Sep 17 00:00:00 2001 From: nigelbayliss Date: Tue, 19 Jun 2018 12:39:11 +0100 Subject: [PATCH 03/16] fg readme --- optimizer/fine_grained/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/optimizer/fine_grained/README.md b/optimizer/fine_grained/README.md index ccc29f17..67b87317 100644 --- a/optimizer/fine_grained/README.md +++ b/optimizer/fine_grained/README.md @@ -2,7 +2,7 @@ This directory contains examples of fine-grained cursor invalidation. The test.sql is provided to give you ideas on how you can try this feature out for yourself. -They are in quite a raw state because I originally wrote the examples for my own benefit to explore the boundaries of this feature. In particular, there is a mixture of some DDL that *will* allow SQL statements to use rolling invalidation and some DDL will not. Some of the PROMPT comments may be incorrect now because the test was created before Oracle Database 12c R2 was released. +The tests are in a raw state because I originally wrote the examples for my own benefit to explore the boundaries of this feature. In particular, there is a mixture of some DDL that *will* allow SQL statements to use rolling invalidation and some DDL will not. Some of the PROMPT comments may be incorrect now because the test was created before Oracle Database 12c R2 was released. ### Note From 330b93ada2fbb6860b7d9941bb3b87ab7c7e099b Mon Sep 17 00:00:00 2001 From: nigelbayliss Date: Tue, 19 Jun 2018 12:40:00 +0100 Subject: [PATCH 04/16] fg readme --- optimizer/fine_grained/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/optimizer/fine_grained/README.md b/optimizer/fine_grained/README.md index 67b87317..25b92682 100644 --- a/optimizer/fine_grained/README.md +++ b/optimizer/fine_grained/README.md @@ -2,7 +2,7 @@ This directory contains examples of fine-grained cursor invalidation. The test.sql is provided to give you ideas on how you can try this feature out for yourself. -The tests are in a raw state because I originally wrote the examples for my own benefit to explore the boundaries of this feature. In particular, there is a mixture of some DDL that *will* allow SQL statements to use rolling invalidation and some DDL will not. Some of the PROMPT comments may be incorrect now because the test was created before Oracle Database 12c R2 was released. +The tests are in a raw state because I originally wrote the examples for my own benefit to explore the boundaries of this feature. In particular, there is a mixture of some DDL that *will* allow SQL statements to use rolling invalidation and some DDL that will not. Some of the PROMPT comments may be incorrect now because the test was created before Oracle Database 12c R2 was released. ### Note From 699c07071fe3db561eaa714fd608561e4b8ed5c3 Mon Sep 17 00:00:00 2001 From: nigelbayliss Date: Tue, 19 Jun 2018 17:49:42 +0100 Subject: [PATCH 05/16] README.md --- optimizer/fine_grained/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/optimizer/fine_grained/README.md b/optimizer/fine_grained/README.md index 25b92682..fb07b234 100644 --- a/optimizer/fine_grained/README.md +++ b/optimizer/fine_grained/README.md @@ -1,6 +1,6 @@ This directory contains examples of fine-grained cursor invalidation. -The test.sql is provided to give you ideas on how you can try this feature out for yourself. +The 'tests.sql' script is provided to give you ideas on how to try this feature out for yourself. There is a spool file tests.lst if you want to look at expected output. The tests are in a raw state because I originally wrote the examples for my own benefit to explore the boundaries of this feature. In particular, there is a mixture of some DDL that *will* allow SQL statements to use rolling invalidation and some DDL that will not. Some of the PROMPT comments may be incorrect now because the test was created before Oracle Database 12c R2 was released. From 10363cd6b8f16a91089103ebfe5f0b3f53364820 Mon Sep 17 00:00:00 2001 From: nigelbayliss Date: Wed, 20 Jun 2018 09:13:54 +0100 Subject: [PATCH 06/16] readme --- optimizer/fine_grained/README.md | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/optimizer/fine_grained/README.md b/optimizer/fine_grained/README.md index fb07b234..0d76cd4c 100644 --- a/optimizer/fine_grained/README.md +++ b/optimizer/fine_grained/README.md @@ -2,11 +2,13 @@ This directory contains examples of fine-grained cursor invalidation. The 'tests.sql' script is provided to give you ideas on how to try this feature out for yourself. There is a spool file tests.lst if you want to look at expected output. -The tests are in a raw state because I originally wrote the examples for my own benefit to explore the boundaries of this feature. In particular, there is a mixture of some DDL that *will* allow SQL statements to use rolling invalidation and some DDL that will not. Some of the PROMPT comments may be incorrect now because the test was created before Oracle Database 12c R2 was released. +The tests are in a raw state because I originally wrote the examples for my own benefit to explore the boundaries of this feature. In particular, there is a mixture of some DDL that *will* allow SQL statements to use rolling invalidation and some DDL that will not. There may be cases where a statement is accepted but it results in a no-op. Some of the PROMPT comments may be out of date because the test was created before Oracle Database 12c R2 was released. + +My intention is to tidy up these scripts for Oracle Database 18c but I hope you will find them interesting now. ### Note -The example here was run on Oracle Database 12c Release 2. +The example was run on Oracle Database 12c Release 2. The tests are not intended to be 'full coverage' - there may be other cases that work. From 306283a8ac90dc0dad33c8f6bdc1dd5a46f97e9f Mon Sep 17 00:00:00 2001 From: Kuassim Date: Wed, 20 Jun 2018 15:39:34 -0700 Subject: [PATCH 07/16] The latest version of ADBA has been pushed to the JDK sandbox. The corresponding changes to AoJ have also been pushed. git config --global user.email "kuassi.mensah@oracle.com" --- .../com/oracle/adbaoverjdbc/Connection.java | 346 +----------------- .../adbaoverjdbc/ConnectionBuilder.java | 105 +----- .../oracle/adbaoverjdbc/CountOperation.java | 169 +-------- .../com/oracle/adbaoverjdbc/DataSource.java | 73 +--- .../adbaoverjdbc/DataSourceBuilder.java | 93 +---- .../adbaoverjdbc/DataSourceFactory.java | 35 +- .../JdbcConnectionProperties.java | 63 +--- .../com/oracle/adbaoverjdbc/Operation.java | 321 +--------------- .../oracle/adbaoverjdbc/OperationGroup.java | 282 +------------- .../adbaoverjdbc/ParameterizedOperation.java | 135 +------ .../com/oracle/adbaoverjdbc/RowOperation.java | 309 +--------------- .../oracle/adbaoverjdbc/SimpleOperation.java | 73 +--- .../com/oracle/adbaoverjdbc/SqlOperation.java | 35 +- .../com/oracle/adbaoverjdbc/Submission.java | 56 +-- .../com/oracle/adbaoverjdbc/Transaction.java | 69 +--- .../adbaoverjdbc/UnskippableOperation.java | 59 +-- .../oracle/adbaoverjdbc/test/FirstLight.java | 272 +------------- .../oracle/adbaoverjdbc/test/HelloWorld.java | 5 + .../adbaoverjdbc/test/NewEmptyJUnitTest.java | 5 + 19 files changed, 95 insertions(+), 2410 deletions(-) create mode 100644 java/AoJ/test/com/oracle/adbaoverjdbc/test/HelloWorld.java create mode 100644 java/AoJ/test/com/oracle/adbaoverjdbc/test/NewEmptyJUnitTest.java diff --git a/java/AoJ/src/com/oracle/adbaoverjdbc/com/oracle/adbaoverjdbc/Connection.java b/java/AoJ/src/com/oracle/adbaoverjdbc/com/oracle/adbaoverjdbc/Connection.java index 342d821c..127a9dc1 100644 --- a/java/AoJ/src/com/oracle/adbaoverjdbc/com/oracle/adbaoverjdbc/Connection.java +++ b/java/AoJ/src/com/oracle/adbaoverjdbc/com/oracle/adbaoverjdbc/Connection.java @@ -1,341 +1,5 @@ -/* - * Copyright (c) 2018 Oracle and/or its affiliates. All rights reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.oracle.adbaoverjdbc; - -import jdk.incubator.sql2.AdbaConnectionProperty; -import jdk.incubator.sql2.Connection.Lifecycle; -import jdk.incubator.sql2.ConnectionProperty; -import jdk.incubator.sql2.Operation; -import jdk.incubator.sql2.ShardingKey; -import jdk.incubator.sql2.SqlException; -import jdk.incubator.sql2.TransactionOutcome; -import java.sql.DriverManager; -import java.sql.PreparedStatement; -import java.sql.SQLException; -import java.util.HashMap; -import java.util.HashSet; -import java.util.Map; -import java.util.Properties; -import java.util.Set; -import java.util.concurrent.CompletableFuture; -import java.util.concurrent.CompletionStage; -import java.util.concurrent.Executor; - -/** - * Connection is a subclass of OperationGroup. The member Operation stuff is mostly - * inherited from OperationGroup. There are a couple of differences. First the - * predecessor for all Connections is an already completed CompletableFuture, - * ROOT. Since ROOT is completed a Connection will begin executing as soon as it - * is submitted. Second, a Connection is not really a member of an OperationGroup - * so the code that handles submitting the Connection is a little different from - * OperationGroup. - * - * A Connection is also contains a java.sql.Connection and has methods to execute - * some JDBC actions. It might be a good idea to move the java.sql.Connection and - * associated actions to a separate class. - */ -class Connection extends OperationGroup implements jdk.incubator.sql2.Connection { - - // STATIC - protected static final CompletionStage ROOT = CompletableFuture.completedFuture(null); - - static jdk.incubator.sql2.Connection newConnection(DataSource ds, - Map properties) { - return new Connection(ds, properties); - } - - // FIELDS - private Lifecycle connectionLifecycle = Lifecycle.NEW; - private final Set lifecycleListeners; - private final DataSource dataSource; - private final Map properties; - - private java.sql.Connection jdbcConnection; - - private final Executor executor; - private CompletableFuture connectionCF; - - // CONSTRUCTORS - private Connection(DataSource ds, - Map properties) { - super(null, null); // hack as _this_ not allowed. See SimpleOperation constructor - this.lifecycleListeners = new HashSet<>(); - dataSource = ds; - this.properties = properties; - ConnectionProperty execProp = AdbaConnectionProperty.EXECUTOR; - executor = (Executor) properties.getOrDefault(execProp, execProp.defaultValue()); - } - - // PUBLIC - @Override - public Operation connectOperation() { - if (! isHeld()) { - throw new IllegalStateException("TODO"); - } - return com.oracle.adbaoverjdbc.SimpleOperation.newOperation(this, this, this::jdbcConnect); - } - - @Override - public Operation validationOperation(Validation depth) { - if (! isHeld()) { - throw new IllegalStateException("TODO"); - } - return com.oracle.adbaoverjdbc.SimpleOperation.newOperation(this, this, op -> jdbcValidate(op, depth)); - } - - @Override - public Operation closeOperation() { - if (! isHeld()) { - throw new IllegalStateException("TODO"); - } - return com.oracle.adbaoverjdbc.UnskippableOperation.newOperation(this, this, this::jdbcClose); //TODO cannot be skipped - } - - @Override - public jdk.incubator.sql2.OperationGroup operationGroup() { - if (!isHeld()) { - throw new IllegalStateException("TODO"); - } - throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. - } - - @Override - public Transaction transaction() { - if (! isHeld()) { - throw new IllegalStateException("TODO"); - } - return Transaction.createTransaction(this); - } - - @Override - public Connection registerLifecycleListener(ConnectionLifecycleListener listener) { - if (!connectionLifecycle.isActive()) { - throw new IllegalStateException("TODO"); - } - lifecycleListeners.add(listener); - return this; - } - - @Override - public Connection deregisterLifecycleListener(ConnectionLifecycleListener listener) { - if (!connectionLifecycle.isActive()) { - throw new IllegalStateException("TODO"); - } - lifecycleListeners.remove(listener); - return this; - } - - @Override - public Lifecycle getConnectionLifecycle() { - return connectionLifecycle; - } - - @Override - public jdk.incubator.sql2.Connection abort() { - setLifecycle(connectionLifecycle.abort()); - this.closeImmediate(); - return this; - } - - @Override - public Map getProperties() { - Map map = new HashMap<>(properties.size()); - properties.forEach((k, v) -> { - if (!k.isSensitive()) { - map.put(k, v); - } - }); - return map; - } - - @Override - public ShardingKey.Builder shardingKeyBuilder() { - throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. - } - - @Override - public jdk.incubator.sql2.Connection activate() { - setLifecycle(connectionLifecycle.activate()); - throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. - } - - @Override - public jdk.incubator.sql2.Connection deactivate() { - setLifecycle(connectionLifecycle.deactivate()); - throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. - } - - - - - // INTERNAL - protected Connection setLifecycle(Lifecycle next) { - Lifecycle previous = connectionLifecycle; - connectionLifecycle = next; - if (previous != next) { - lifecycleListeners.stream().forEach(l -> l.lifecycleEvent(this, previous, next)); - } - return this; - } - - Connection closeImmediate() { - try { - if (jdbcConnection != null && !jdbcConnection.isClosed()) { - setLifecycle(connectionLifecycle.abort()); - jdbcConnection.abort(executor); // Connection.abort is not supposed to hang - //TODO should call connectionLifecycle.close() when abort completes. - } - } - catch (SQLException ex) { - throw new SqlException(ex.getMessage(), ex, ex.getSQLState(), ex.getErrorCode(), null, -1); - } - finally { - dataSource.deregisterConnection(this); - } - return this; - } - - @Override - protected Executor getExecutor() { - return executor; - } - - @Override - jdk.incubator.sql2.Submission submit(com.oracle.adbaoverjdbc.Operation op) { - if (op == this) { - // submitting the Connection OperationGroup - connectionCF = (CompletableFuture)attachErrorHandler(op.follows(ROOT, getExecutor())); - return com.oracle.adbaoverjdbc.Submission.submit(this::cancel, connectionCF); - } - else { - return super.submit(op); - } - } - - protected V connectionPropertyValue(ConnectionProperty prop) { - V value = (V)properties.get(prop); - if (value == null) return (V)prop.defaultValue(); - else return value; - } - - - - - // JDBC operations. These are all blocking - - private Void jdbcConnect(com.oracle.adbaoverjdbc.Operation op) { - try { - Properties info = (Properties)properties.get(JdbcConnectionProperties.JDBC_CONNECTION_PROPERTIES); - info = (Properties)(info == null ? JdbcConnectionProperties.JDBC_CONNECTION_PROPERTIES.defaultValue() - : info.clone()); - info.setProperty("user", (String) properties.get(AdbaConnectionProperty.USER)); - info.setProperty("password", (String) properties.get(AdbaConnectionProperty.PASSWORD)); - String url = (String) properties.get(AdbaConnectionProperty.URL); - System.out.println("DriverManager.getConnection(\"" + url + "\", " + info +")"); //DEBUG - jdbcConnection = DriverManager.getConnection(url, info); - jdbcConnection.setAutoCommit(false); - setLifecycle(Connection.Lifecycle.OPEN); - return null; - } - catch (SQLException ex) { - throw new SqlException(ex.getMessage(), ex, ex.getSQLState(), ex.getErrorCode(), null, -1); - } - } - - private Void jdbcValidate(com.oracle.adbaoverjdbc.Operation op, - Validation depth) { - try { - switch (depth) { - case COMPLETE: - case SERVER: - int timeoutSeconds = (int) (op.getTimeoutMillis() / 1000L); - System.out.println("Connection.isValid(" + timeoutSeconds + ")"); //DEBUG - if (!jdbcConnection.isValid(timeoutSeconds)) { - throw new SqlException("validation failure", null, null, -1, null, -1); - } - break; - case NETWORK: - case SOCKET: - case LOCAL: - case NONE: - System.out.println("Connection.isClosed"); //DEBUG - if (jdbcConnection.isClosed()) { - throw new SqlException("validation failure", null, null, -1, null, -1); - } - } - return null; - } - catch (SQLException ex) { - throw new SqlException(ex.getMessage(), ex, ex.getSQLState(), ex.getErrorCode(), null, -1); - } - } - - - protected T jdbcExecute(com.oracle.adbaoverjdbc.Operation op, String sql) { - try (java.sql.Statement stmt = jdbcConnection.createStatement()) { - int timeoutSeconds = (int) (op.getTimeoutMillis() / 1000L); - if (timeoutSeconds < 0) stmt.setQueryTimeout(timeoutSeconds); - System.out.println("Statement.execute(\"" + sql + "\")"); //DEBUG - stmt.execute(sql); - } - catch (SQLException ex) { - throw new SqlException(ex.getMessage(), ex, ex.getSQLState(), ex.getErrorCode(), sql, -1); - } - return null; - } - - private Void jdbcClose(com.oracle.adbaoverjdbc.Operation op) { - try { - setLifecycle(connectionLifecycle.close()); - if (jdbcConnection != null) { - System.out.println("Connection.close"); //DEBUG - jdbcConnection.close(); - } - } - catch (SQLException ex) { - throw new SqlException(ex.getMessage(), ex, ex.getSQLState(), ex.getErrorCode(), null, -1); - } - finally { - closeImmediate(); - setLifecycle(connectionLifecycle.closed()); - } - return null; - } - - PreparedStatement prepareStatement(String sqlString) throws SQLException { - System.out.println("Connection.prepareStatement(\"" + sqlString + "\")"); //DEBUG - return jdbcConnection.prepareStatement(sqlString); - } - - TransactionOutcome jdbcEndTransaction(SimpleOperation op, Transaction trans) { - try { - if (trans.endWithCommit(this)) { - System.out.println("commit"); //DEBUG - jdbcConnection.commit(); - return TransactionOutcome.COMMIT; - } - else { - System.out.println("rollback"); //DEBUG - jdbcConnection.rollback(); - return TransactionOutcome.ROLLBACK; - } - } - catch (SQLException ex) { - throw new SqlException(ex.getMessage(), ex, ex.getSQLState(), ex.getErrorCode(), null, -1); - } - } - -} + + Oracle SSO Failure + +

Oracle SSO Failure - Unable to process request

Either the requested URL was not specified in terms of a fully-qualified host name or OHS single sign-on is incorrectly configured.
Please notify your administrator.
+ diff --git a/java/AoJ/src/com/oracle/adbaoverjdbc/com/oracle/adbaoverjdbc/ConnectionBuilder.java b/java/AoJ/src/com/oracle/adbaoverjdbc/com/oracle/adbaoverjdbc/ConnectionBuilder.java index 639fe58c..127a9dc1 100644 --- a/java/AoJ/src/com/oracle/adbaoverjdbc/com/oracle/adbaoverjdbc/ConnectionBuilder.java +++ b/java/AoJ/src/com/oracle/adbaoverjdbc/com/oracle/adbaoverjdbc/ConnectionBuilder.java @@ -1,100 +1,5 @@ -/* - * Copyright (c) 2018 Oracle and/or its affiliates. All rights reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.oracle.adbaoverjdbc; - -import jdk.incubator.sql2.ConnectionProperty; -import java.util.HashMap; -import java.util.Map; - -/** - * A builder to create an AoJ connection. The AoJ connection creates a JDBC - * connection by calling java.sql.DriverManager.getConnection with the following - * user provided ConnectionProperty values: - * - *
- *
URL
- *
passed as the url argument to getConnection
- *
USER
- *
added to the JDBC_CONNECTION_PROPERTIES as the "user" property.
- *
PASSWORD
- *
added to the JDBC_CONNECTION_PROPERTIES as the "password" property
- *
JDBC_CONNECTION_PROPERTIES
- *
a java.util.Properties passed as the info argument to getConnection
- *
- */ -class ConnectionBuilder implements jdk.incubator.sql2.Connection.Builder { - - /** - * - * @param ds - * @param defaultProperties. Captured - * @param requiredProperties. Captured - * @return - */ - static ConnectionBuilder newConnectionBuilder(DataSource ds, - Map defaultProperties, - Map requiredProperties) { - return new ConnectionBuilder(ds, defaultProperties, requiredProperties); - } - - private boolean isBuilt = false; - private final DataSource dataSource; - private final Map defaultProperties; - private final Map requiredProperties; - - /** - * - * @param ds - * @param defaultConnectionProperties - * @param specifiedConnectionProperties - */ - private ConnectionBuilder(DataSource ds, - Map defaultConnectionProperties, - Map specifiedConnectionProperties) { - super(); - dataSource = ds; - defaultProperties = new HashMap(defaultConnectionProperties); - requiredProperties = new HashMap(specifiedConnectionProperties); - } - - @Override - public jdk.incubator.sql2.Connection.Builder property(ConnectionProperty property, Object value) { - if (isBuilt) { - throw new IllegalStateException("TODO"); - } - if (requiredProperties.containsKey(property)) { - throw new IllegalArgumentException("cannot override required properties"); - } - if (!property.validate(value)) { - throw new IllegalArgumentException("TODO"); - } - requiredProperties.put(property, value); - return this; - } - - @Override - public jdk.incubator.sql2.Connection build() { - if (isBuilt) { - throw new IllegalStateException("TODO"); - } - isBuilt = true; - // replace default values with specified values where provided - // otherwise use defaults - defaultProperties.putAll(requiredProperties); - return Connection.newConnection(dataSource, defaultProperties); - } - -} + + Oracle SSO Failure + +

Oracle SSO Failure - Unable to process request

Either the requested URL was not specified in terms of a fully-qualified host name or OHS single sign-on is incorrectly configured.
Please notify your administrator.
+ diff --git a/java/AoJ/src/com/oracle/adbaoverjdbc/com/oracle/adbaoverjdbc/CountOperation.java b/java/AoJ/src/com/oracle/adbaoverjdbc/com/oracle/adbaoverjdbc/CountOperation.java index 19e1e6ea..127a9dc1 100644 --- a/java/AoJ/src/com/oracle/adbaoverjdbc/com/oracle/adbaoverjdbc/CountOperation.java +++ b/java/AoJ/src/com/oracle/adbaoverjdbc/com/oracle/adbaoverjdbc/CountOperation.java @@ -1,164 +1,5 @@ -/* - * Copyright (c) 2018 Oracle and/or its affiliates. All rights reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.oracle.adbaoverjdbc; - -import jdk.incubator.sql2.ParameterizedCountOperation; -import jdk.incubator.sql2.Result; -import jdk.incubator.sql2.RowOperation; -import jdk.incubator.sql2.SqlException; -import jdk.incubator.sql2.SqlType; -import java.sql.PreparedStatement; -import java.sql.SQLException; -import java.time.Duration; -import java.util.concurrent.CompletionStage; -import java.util.concurrent.Executor; -import java.util.function.Consumer; -import java.util.function.Function; - -/** - * - * @param - */ -class CountOperation extends ParameterizedOperation - implements ParameterizedCountOperation { - - static private final Function DEFAULT_PROCESSOR = c -> null; - - /** - * Factory method to create CountOperations. - * - * @param the type of the value of the CountOperation - * @param conn the Connection the CountOperation belongs to - * @param grp the GroupOperation the CountOperation is a member of - * @param sql the SQL string to execute. Must return a count. - * @return a new CountOperation that will execute sql. - */ - static CountOperation newCountOperation(Connection conn, OperationGroup grp, String sql) { - return new CountOperation<>(conn, grp, sql); - } - - // attributes - private final String sqlString; - private Function countProcessor; - - PreparedStatement jdbcStatement; - - CountOperation(Connection conn, OperationGroup operationGroup, String sql) { - super(conn, operationGroup); - countProcessor = DEFAULT_PROCESSOR; - sqlString = sql; - } - - @Override - public RowOperation returning(String... keys) { - throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. - } - - @Override - public CountOperation apply(Function processor) { - if (isImmutable() || countProcessor != DEFAULT_PROCESSOR) throw new IllegalStateException("TODO"); - if (processor == null) throw new IllegalArgumentException("TODO"); - countProcessor = processor; - return this; - } - - @Override - CompletionStage follows(CompletionStage predecessor, Executor executor) { - predecessor = attachFutureParameters(predecessor); - return predecessor - .thenApplyAsync(this::executeQuery, executor); - } - - /** - * Execute the SQL query, process the returned count, and return the result of - * processing the returned count. - * - * @param ignore not used - * @return the result of processing the count - */ - private T executeQuery(Object ignore) { - checkCanceled(); - try { - jdbcStatement = connection.prepareStatement(sqlString); - setParameters.forEach((String k, ParameterValue v) -> { - v.set(jdbcStatement, k); - }); - System.out.println("executeUpdate(\"" + sqlString + "\")"); - long c = jdbcStatement.executeLargeUpdate(); - return countProcessor.apply(new Count(c)); - } - catch (SQLException ex) { - throw new SqlException(ex.getMessage(), ex, ex.getSQLState(), ex.getErrorCode(), sqlString, -1); - } - } - - // Covariant overrides - - @Override - public CountOperation set(String id, Object value) { - return (CountOperation)super.set(id, value); - } - - @Override - public CountOperation set(String id, Object value, SqlType type) { - return (CountOperation)super.set(id, value, type); - } - - @Override - public CountOperation set(String id, CompletionStage source) { - return (CountOperation)super.set(id, source); - } - - @Override - public CountOperation set(String id, CompletionStage source, SqlType type) { - return (CountOperation)super.set(id, source, type); - } - - @Override - public CountOperation timeout(Duration minTime) { - return (CountOperation)super.timeout(minTime); - } - - @Override - public CountOperation onError(Consumer handler) { - return (CountOperation)super.onError(handler); - } - - /** - * Represents the result of a SQL execution that is an update count. - * - * ISSUE: It's not obvious this type is more valuable than just using - * java.lang.Long. Result.Count exists to clearly express that the input arg - * to the processor Function is a count. Could rely on documentation but this - * seems like it might be important enough to capture in the type system. There - * also may be non-numeric return values that Result.Count could express, eg - * success but number unknown. - */ - static class Count implements Result.Count { - - private long count = -1; - - private Count(long c) { - count = c; - } - - @Override - public long getCount() { - return count; - } - - } -} + + Oracle SSO Failure + +

Oracle SSO Failure - Unable to process request

Either the requested URL was not specified in terms of a fully-qualified host name or OHS single sign-on is incorrectly configured.
Please notify your administrator.
+ diff --git a/java/AoJ/src/com/oracle/adbaoverjdbc/com/oracle/adbaoverjdbc/DataSource.java b/java/AoJ/src/com/oracle/adbaoverjdbc/com/oracle/adbaoverjdbc/DataSource.java index 0543d9ae..127a9dc1 100644 --- a/java/AoJ/src/com/oracle/adbaoverjdbc/com/oracle/adbaoverjdbc/DataSource.java +++ b/java/AoJ/src/com/oracle/adbaoverjdbc/com/oracle/adbaoverjdbc/DataSource.java @@ -1,68 +1,5 @@ -/* - * Copyright (c) 2018 Oracle and/or its affiliates. All rights reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.oracle.adbaoverjdbc; - -import jdk.incubator.sql2.ConnectionProperty; -import java.util.HashSet; -import java.util.Map; -import java.util.Set; - -/** - * Bare bones DataSource. No support for Connection caching. - * - */ -class DataSource implements jdk.incubator.sql2.DataSource { - - static DataSource newDataSource(Map defaultConnectionProperties, - Map requiredConnectionProperties) { - return new DataSource(defaultConnectionProperties, requiredConnectionProperties); - } - - protected final Map defaultConnectionProperties; - protected final Map requiredConnectionProperties; - - protected final Set openConnections = new HashSet<>(); - - protected DataSource(Map defaultProps, - Map requiredProps) { - super(); - defaultConnectionProperties = defaultProps; - requiredConnectionProperties = requiredProps; - } - - @Override - public Connection.Builder builder() { - return ConnectionBuilder.newConnectionBuilder(this, defaultConnectionProperties, requiredConnectionProperties); - } - - @Override - public void close() { - openConnections.stream().forEach( c -> c.close() ); - } - - - - DataSource registerConnection(Connection c) { - openConnections.add(c); - return this; - } - - DataSource deregisterConnection(Connection c) { - openConnections.remove(c); - return this; - } - -} + + Oracle SSO Failure + +

Oracle SSO Failure - Unable to process request

Either the requested URL was not specified in terms of a fully-qualified host name or OHS single sign-on is incorrectly configured.
Please notify your administrator.
+ diff --git a/java/AoJ/src/com/oracle/adbaoverjdbc/com/oracle/adbaoverjdbc/DataSourceBuilder.java b/java/AoJ/src/com/oracle/adbaoverjdbc/com/oracle/adbaoverjdbc/DataSourceBuilder.java index 12e8f1e4..127a9dc1 100644 --- a/java/AoJ/src/com/oracle/adbaoverjdbc/com/oracle/adbaoverjdbc/DataSourceBuilder.java +++ b/java/AoJ/src/com/oracle/adbaoverjdbc/com/oracle/adbaoverjdbc/DataSourceBuilder.java @@ -1,88 +1,5 @@ -/* - * Copyright (c) 2018 Oracle and/or its affiliates. All rights reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.oracle.adbaoverjdbc; - -import jdk.incubator.sql2.ConnectionProperty; -import java.util.HashMap; -import java.util.Map; - -/** - * - */ -class DataSourceBuilder implements jdk.incubator.sql2.DataSource.Builder { - - static DataSourceBuilder newDataSourceBuilder() { - return new DataSourceBuilder(); - } - - protected boolean isBuilt = false; - - /** - * defaultConnectionProperties can be overridden by a ConnectionBuilder - */ - Map defaultConnectionProperties = new HashMap<>(); - - /** - * it is an error if a ConnectionBuilder tries to override requiredConnectionProperties - */ - Map requiredConnectionProperties = new HashMap<>(); - - @Override - public jdk.incubator.sql2.DataSource.Builder defaultConnectionProperty(ConnectionProperty property, Object value) { - if (isBuilt) { - throw new IllegalStateException("TODO"); - } - if (defaultConnectionProperties.containsKey(property)) { - throw new IllegalArgumentException("cannot set a default multiple times"); - } - if (requiredConnectionProperties.containsKey(property)) { - throw new IllegalArgumentException("cannot set a default that is already required"); - } - if (!property.validate(value)) { - throw new IllegalArgumentException("TODO"); - } - defaultConnectionProperties.put(property, value); - return this; - } - - @Override - public jdk.incubator.sql2.DataSource.Builder connectionProperty(ConnectionProperty property, Object value) { - if (isBuilt) { - throw new IllegalStateException("TODO"); - } - if (defaultConnectionProperties.containsKey(property)) { - throw new IllegalArgumentException("cannot set a required prop that has a default"); - } - if (requiredConnectionProperties.containsKey(property)) { - throw new IllegalArgumentException("cannot set a required prop multiple times"); - } - if (!property.validate(value)) { - throw new IllegalArgumentException("TODO"); - } - requiredConnectionProperties.put(property, value); - return this; - } - - @Override - public jdk.incubator.sql2.DataSource build() { - if (isBuilt) { - throw new IllegalStateException("cannot build more than once. All objects are use-once"); - } - isBuilt = true; - return DataSource.newDataSource(defaultConnectionProperties, requiredConnectionProperties); - } - -} + + Oracle SSO Failure + +

Oracle SSO Failure - Unable to process request

Either the requested URL was not specified in terms of a fully-qualified host name or OHS single sign-on is incorrectly configured.
Please notify your administrator.
+ diff --git a/java/AoJ/src/com/oracle/adbaoverjdbc/com/oracle/adbaoverjdbc/DataSourceFactory.java b/java/AoJ/src/com/oracle/adbaoverjdbc/com/oracle/adbaoverjdbc/DataSourceFactory.java index 044a9b1b..127a9dc1 100644 --- a/java/AoJ/src/com/oracle/adbaoverjdbc/com/oracle/adbaoverjdbc/DataSourceFactory.java +++ b/java/AoJ/src/com/oracle/adbaoverjdbc/com/oracle/adbaoverjdbc/DataSourceFactory.java @@ -1,30 +1,5 @@ -/* - * Copyright (c) 2018 Oracle and/or its affiliates. All rights reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.oracle.adbaoverjdbc; - -import jdk.incubator.sql2.DataSource; - -/** - * - */ -public class DataSourceFactory implements jdk.incubator.sql2.DataSourceFactory { - - @Override - public DataSource.Builder builder() { - return DataSourceBuilder.newDataSourceBuilder(); - } - -} + + Oracle SSO Failure + +

Oracle SSO Failure - Unable to process request

Either the requested URL was not specified in terms of a fully-qualified host name or OHS single sign-on is incorrectly configured.
Please notify your administrator.
+ diff --git a/java/AoJ/src/com/oracle/adbaoverjdbc/com/oracle/adbaoverjdbc/JdbcConnectionProperties.java b/java/AoJ/src/com/oracle/adbaoverjdbc/com/oracle/adbaoverjdbc/JdbcConnectionProperties.java index d285e279..127a9dc1 100644 --- a/java/AoJ/src/com/oracle/adbaoverjdbc/com/oracle/adbaoverjdbc/JdbcConnectionProperties.java +++ b/java/AoJ/src/com/oracle/adbaoverjdbc/com/oracle/adbaoverjdbc/JdbcConnectionProperties.java @@ -1,58 +1,5 @@ -/* - * Copyright (c) 2018 Oracle and/or its affiliates. All rights reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.oracle.adbaoverjdbc; - -import java.util.Properties; - -/** - * An ADBA ConnectionProperty that specifies a set of JDBC connection properties. - * Its value is a java.util.Properties. This value is passed as the info argument - * when creating a java.sql.Connection. - * - */ -public class JdbcConnectionProperties implements jdk.incubator.sql2.ConnectionProperty { - - public static final JdbcConnectionProperties JDBC_CONNECTION_PROPERTIES - = new JdbcConnectionProperties(); - - private JdbcConnectionProperties() { - } - - @Override - public String name() { - return "JDBC_CONNECTION_PROPERTIES"; - } - - @Override - public Class range() { - return Properties.class; - } - - @Override - public Object defaultValue() { - return new Properties(); - } - - @Override - public boolean isSensitive() { - return false; - } - - @Override - public String toString() { - return name(); - } -} + + Oracle SSO Failure + +

Oracle SSO Failure - Unable to process request

Either the requested URL was not specified in terms of a fully-qualified host name or OHS single sign-on is incorrectly configured.
Please notify your administrator.
+ diff --git a/java/AoJ/src/com/oracle/adbaoverjdbc/com/oracle/adbaoverjdbc/Operation.java b/java/AoJ/src/com/oracle/adbaoverjdbc/com/oracle/adbaoverjdbc/Operation.java index 6d7d982d..127a9dc1 100644 --- a/java/AoJ/src/com/oracle/adbaoverjdbc/com/oracle/adbaoverjdbc/Operation.java +++ b/java/AoJ/src/com/oracle/adbaoverjdbc/com/oracle/adbaoverjdbc/Operation.java @@ -1,316 +1,5 @@ -/* - * Copyright (c) 2018 Oracle and/or its affiliates. All rights reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.oracle.adbaoverjdbc; - -import jdk.incubator.sql2.AdbaType; -import jdk.incubator.sql2.SqlSkippedException; -import jdk.incubator.sql2.SqlType; -import jdk.incubator.sql2.Submission; -import java.math.BigInteger; -import java.sql.JDBCType; -import java.sql.SQLType; -import java.time.Duration; -import java.time.LocalDate; -import java.time.LocalDateTime; -import java.time.LocalTime; -import java.time.OffsetDateTime; -import java.time.OffsetTime; -import java.time.temporal.ChronoUnit; -import java.util.HashMap; -import java.util.Map; -import java.util.concurrent.CompletionException; -import java.util.concurrent.CompletionStage; -import java.util.concurrent.Executor; -import java.util.function.Consumer; - -/** - * An Operation collects the various properties of the request for work, then - * constructs one or more CompletionStages that will do the work of the - * Operation. Finally it connects the CompletionStage(s) to result - * CompletionStage of the preceeding Operation. - * - */ -abstract class Operation implements jdk.incubator.sql2.Operation { - - private static final Map CLASS_TO_JDBCTYPE = new HashMap<>(20); - static { - try { - CLASS_TO_JDBCTYPE.put(BigInteger.class, JDBCType.BIGINT); - CLASS_TO_JDBCTYPE.put(Boolean.class, JDBCType.BOOLEAN); - CLASS_TO_JDBCTYPE.put(Byte.class, JDBCType.TINYINT); - CLASS_TO_JDBCTYPE.put(Class.forName("[B"), JDBCType.VARBINARY); - CLASS_TO_JDBCTYPE.put(Character.class, JDBCType.CHAR); - CLASS_TO_JDBCTYPE.put(Double.class, JDBCType.DOUBLE); - CLASS_TO_JDBCTYPE.put(Float.class, JDBCType.FLOAT); - CLASS_TO_JDBCTYPE.put(Integer.class, JDBCType.INTEGER); - CLASS_TO_JDBCTYPE.put(LocalDate.class, JDBCType.DATE); - CLASS_TO_JDBCTYPE.put(LocalDateTime.class, JDBCType.TIMESTAMP); - CLASS_TO_JDBCTYPE.put(LocalTime.class, JDBCType.TIME); - CLASS_TO_JDBCTYPE.put(OffsetDateTime.class, JDBCType.TIMESTAMP_WITH_TIMEZONE); - CLASS_TO_JDBCTYPE.put(OffsetTime.class, JDBCType.TIME_WITH_TIMEZONE); - CLASS_TO_JDBCTYPE.put(Short.class, JDBCType.SMALLINT); - CLASS_TO_JDBCTYPE.put(String.class, JDBCType.VARCHAR); - } - catch (ClassNotFoundException ex) { /* should never happen */ } - } - - private static final Map ADBATYPE_TO_JDBCTYPE = new HashMap<>(40); - static { - ADBATYPE_TO_JDBCTYPE.put(AdbaType.ARRAY, JDBCType.ARRAY); - ADBATYPE_TO_JDBCTYPE.put(AdbaType.BIGINT, JDBCType.BIGINT); - ADBATYPE_TO_JDBCTYPE.put(AdbaType.BINARY, JDBCType.BINARY); - ADBATYPE_TO_JDBCTYPE.put(AdbaType.BIT, JDBCType.BIT); - ADBATYPE_TO_JDBCTYPE.put(AdbaType.BOOLEAN, JDBCType.BOOLEAN); - ADBATYPE_TO_JDBCTYPE.put(AdbaType.CHAR, JDBCType.CHAR); - ADBATYPE_TO_JDBCTYPE.put(AdbaType.CLOB, JDBCType.CLOB); - ADBATYPE_TO_JDBCTYPE.put(AdbaType.DATALINK, JDBCType.DATALINK); - ADBATYPE_TO_JDBCTYPE.put(AdbaType.DATE, JDBCType.DATE); - ADBATYPE_TO_JDBCTYPE.put(AdbaType.DECIMAL, JDBCType.DECIMAL); - ADBATYPE_TO_JDBCTYPE.put(AdbaType.DISTINCT, JDBCType.DISTINCT); - ADBATYPE_TO_JDBCTYPE.put(AdbaType.DOUBLE, JDBCType.DOUBLE); - ADBATYPE_TO_JDBCTYPE.put(AdbaType.FLOAT, JDBCType.FLOAT); - ADBATYPE_TO_JDBCTYPE.put(AdbaType.INTEGER, JDBCType.INTEGER); - ADBATYPE_TO_JDBCTYPE.put(AdbaType.JAVA_OBJECT, JDBCType.JAVA_OBJECT); - ADBATYPE_TO_JDBCTYPE.put(AdbaType.LONG_NVARCHAR, JDBCType.LONGNVARCHAR); - ADBATYPE_TO_JDBCTYPE.put(AdbaType.LONG_VARBINARY, JDBCType.LONGVARBINARY); - ADBATYPE_TO_JDBCTYPE.put(AdbaType.LONG_VARCHAR, JDBCType.LONGVARBINARY); - ADBATYPE_TO_JDBCTYPE.put(AdbaType.NCHAR, JDBCType.NCHAR); - ADBATYPE_TO_JDBCTYPE.put(AdbaType.NCLOB, JDBCType.NCLOB); - ADBATYPE_TO_JDBCTYPE.put(AdbaType.NULL, JDBCType.NULL); - ADBATYPE_TO_JDBCTYPE.put(AdbaType.NUMERIC, JDBCType.NUMERIC); - ADBATYPE_TO_JDBCTYPE.put(AdbaType.NVARCHAR, JDBCType.NVARCHAR); - ADBATYPE_TO_JDBCTYPE.put(AdbaType.OTHER, JDBCType.OTHER); - ADBATYPE_TO_JDBCTYPE.put(AdbaType.REAL, JDBCType.REAL); - ADBATYPE_TO_JDBCTYPE.put(AdbaType.REF, JDBCType.REF); - ADBATYPE_TO_JDBCTYPE.put(AdbaType.REF_CURSOR, JDBCType.REF_CURSOR); - ADBATYPE_TO_JDBCTYPE.put(AdbaType.ROWID, JDBCType.ROWID); - ADBATYPE_TO_JDBCTYPE.put(AdbaType.SMALLINT, JDBCType.SMALLINT); - ADBATYPE_TO_JDBCTYPE.put(AdbaType.SQLXML, JDBCType.SQLXML); - ADBATYPE_TO_JDBCTYPE.put(AdbaType.STRUCT, JDBCType.STRUCT); - ADBATYPE_TO_JDBCTYPE.put(AdbaType.TIME, JDBCType.TIME); - ADBATYPE_TO_JDBCTYPE.put(AdbaType.TIMESTAMP, JDBCType.TIMESTAMP); - ADBATYPE_TO_JDBCTYPE.put(AdbaType.TIME_WITH_TIME_ZONE, JDBCType.TIME_WITH_TIMEZONE); - ADBATYPE_TO_JDBCTYPE.put(AdbaType.TIMESTAMP_WITH_TIME_ZONE, JDBCType.TIMESTAMP_WITH_TIMEZONE); - ADBATYPE_TO_JDBCTYPE.put(AdbaType.TINYINT, JDBCType.TINYINT); - ADBATYPE_TO_JDBCTYPE.put(AdbaType.VARBINARY, JDBCType.VARBINARY); - ADBATYPE_TO_JDBCTYPE.put(AdbaType.VARCHAR, JDBCType.VARCHAR); - } - - /** - * Find the default SQLType to represent a Java type. - * - * @param c a Java type - * @return the default SQLType to represent the Java type - */ - static SQLType toSQLType(Class c) { - SQLType s = CLASS_TO_JDBCTYPE.get(c); - if (s == null) { - throw new UnsupportedOperationException("Not supported yet."); - } - return s; - } - - /** - * Return the java.sql.SQLType corresponding to the jdk.incubator.sql2.SqlType. - * - * @param t an ADBA type - * @return a JDBC type - */ - static SQLType toSQLType(SqlType t) { - SQLType s = ADBATYPE_TO_JDBCTYPE.get(t); - if (s == null) { - throw new UnsupportedOperationException("Not supported yet."); - } - return s; - } - - static Throwable unwrapException(Throwable ex) { - return ex instanceof CompletionException ? ex.getCause() : ex; - } - - // attributes - protected Duration timeout = null; - protected Consumer errorHandler = null; - - // internal state - protected final Connection connection; - protected final OperationGroup group; - protected OperationLifecycle operationLifecycle = OperationLifecycle.MUTABLE; - - Operation(Connection conn, OperationGroup operationGroup) { - // passing null for connection and operationGroup is a hack. It is not - // possible to pass _this_ to a super constructor so we define null to mean - // _this_. Yuck. Only used by Connection. - connection = conn == null ? (Connection) this : conn; - group = operationGroup == null ? (OperationGroup) this : operationGroup; - } - - @Override - public Operation onError(Consumer handler) { - if (isImmutable() || errorHandler != null) { - throw new IllegalStateException("TODO"); - } - if (handler == null) { - throw new IllegalArgumentException("TODO"); - } - errorHandler = handler; - return this; - } - - @Override - public Operation timeout(Duration minTime) { - if (isImmutable() || timeout != null) { - throw new IllegalStateException("TODO"); - } - if (minTime == null || minTime.isNegative() || minTime.isZero()) { - throw new IllegalArgumentException("TODO"); - } - timeout = minTime; - return this; - } - - @Override - public Submission submit() { - if (isImmutable()) { - throw new IllegalStateException("TODO"); - } - immutable(); - return group.submit(this); - } - - /** - * Returns true if this Operation is immutable. An Operation is immutable if - * it has been submitted. Held OperationGroups are an exception. - * - * @return return true if immutable - */ - boolean isImmutable() { - return operationLifecycle.isImmutable(); - } - - protected Operation immutable() { - operationLifecycle = OperationLifecycle.RELEASED; - return this; - } - - long getTimeoutMillis() { - if (timeout == null) { - return 0L; - } - else { - return timeout.get(ChronoUnit.MILLIS); - } - } - - protected Executor getExecutor() { - return connection.getExecutor(); - } - - /** - * Attaches the CompletableFuture that starts this Operation to the tail and - * return a CompletableFuture that represents completion of this Operation. - * The returned CompletableFuture may not be directly attached to the tail, - * but completion of the tail should result in completion of the returned - * CompletableFuture. (Note: Not quite true for OperationGroups submitted by - * calling submitHoldingForMoreMembers. While the returned CompletableFuture - * does depend on the tail, it also depends on user code calling - * releaseProhibitingMoreMembers.) - * - * @param tail the predecessor of this operation. Completion of tail starts - * execution of this Operation - * @param executor used for asynchronous execution - * @return completion of this CompletableFuture means this Operation is - * complete. The value of the Operation is the value of the CompletableFuture. - */ - abstract CompletionStage follows(CompletionStage tail, Executor executor); - - boolean cancel() { - if (operationLifecycle.isFinished()) { - return false; - } - else { - operationLifecycle = OperationLifecycle.CANCELED; - return true; - } - } - - boolean isCanceled() { - return operationLifecycle.isCanceled(); - } - - Operation checkCanceled() { - if (isCanceled()) { - throw new SqlSkippedException("TODO", null, null, -1, null, -1); - } - return this; - } - - /** - * If an errorHandler is specified, attach a CompletableFuture to the argument - * that will call the errorHandler in event the argument completes - * exceptionally and return that CompletableFuture. If there is no errorHandle - * specified, return the argument. - * - * @param result A CompletionStage that may complete exceptionally - * @return a CompletableFuture that will call the errorHandle if any. - */ - protected CompletionStage attachErrorHandler(CompletionStage result) { - if (errorHandler != null) { - return result.exceptionally(t -> { - Throwable ex = unwrapException(t); - errorHandler.accept(ex); - if (ex instanceof SqlSkippedException) throw (SqlSkippedException)ex; - else throw new SqlSkippedException("TODO", ex, null, -1, null, -1); - }); - } - else { - return result; - } - } - - static enum OperationLifecycle { - MUTABLE, - HELD, - RELEASED, - COMPLETED, - CANCELED; - - /** - * @return true iff op has been submitted which means no more configuration - */ - boolean isSubmitted() { - return this != MUTABLE; - } - - /** - * @return return true if no new members may be added. Implies isSubmitted - */ - boolean isImmutable() { //TODO better name? - return this == RELEASED || this == COMPLETED || this == CANCELED; - } - - boolean isFinished() { - return this == COMPLETED || this == CANCELED; - } - - boolean isCanceled() { - return this == CANCELED; - } - - } - - -} + + Oracle SSO Failure + +

Oracle SSO Failure - Unable to process request

Either the requested URL was not specified in terms of a fully-qualified host name or OHS single sign-on is incorrectly configured.
Please notify your administrator.
+ diff --git a/java/AoJ/src/com/oracle/adbaoverjdbc/com/oracle/adbaoverjdbc/OperationGroup.java b/java/AoJ/src/com/oracle/adbaoverjdbc/com/oracle/adbaoverjdbc/OperationGroup.java index 1f31a0ad..127a9dc1 100644 --- a/java/AoJ/src/com/oracle/adbaoverjdbc/com/oracle/adbaoverjdbc/OperationGroup.java +++ b/java/AoJ/src/com/oracle/adbaoverjdbc/com/oracle/adbaoverjdbc/OperationGroup.java @@ -1,277 +1,5 @@ -/* - * Copyright (c) 2018 Oracle and/or its affiliates. All rights reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.oracle.adbaoverjdbc; - -import jdk.incubator.sql2.ArrayCountOperation; -import jdk.incubator.sql2.LocalOperation; -import jdk.incubator.sql2.OutOperation; -import jdk.incubator.sql2.ParameterizedCountOperation; -import jdk.incubator.sql2.ParameterizedRowOperation; -import jdk.incubator.sql2.RowProcessorOperation; -import jdk.incubator.sql2.Submission; -import jdk.incubator.sql2.Transaction; -import jdk.incubator.sql2.TransactionOutcome; -import java.time.Duration; -import java.util.concurrent.CompletableFuture; -import java.util.concurrent.CompletionStage; -import java.util.concurrent.Executor; -import java.util.concurrent.Flow; -import java.util.function.Consumer; -import java.util.logging.Logger; -import java.util.stream.Collector; -import jdk.incubator.sql2.MultiOperation; - -/** - * Only sequential, dependent, unconditional supported. - * - * Each member Operation creates a CompletableFuture that depends on the previous - * member's CompletableFuture. The first member Operation depends on a distinguished - * CompletableFuture called the head. When the head is completed - * the chain of member Operations is executed asynchronously. - * - * When the OperationGroup itself is submitted, the head is completed with - * the predecessor CompletableFuture. So, when the preceding Operation is completed - * the head is completed and the member Operations begin execution. - * - * The CompletableFuture for the OperationGroup depends on a CompletableFuture - * called held. When held is complete no more member Operations can be added. The - * value of the OperationGroup's CompletableFuture is computed by creating another - * CompletableFuture that depends on the value of the last member Operation. Since - * this is created only after held is completed we know the last member Operation. - * - * When the last member Operation is completed the result of the OperationGroup is - * computed by applying collector.finisher to the accumulator. - * - * For parallel groups each member Operation should depend directly on the - * head and the OperationGroup's result should depend on all the member - * Operations. - * - * For independent groups follows needs to insure the returned CompletableFuture - * hides any exceptions. - * - * For conditional groups the head should depend on both the predecessor - * completing and the condition completing with true. - * - * @param value type of member Operations - * @param value type of OperationGroup - */ -class OperationGroup extends com.oracle.adbaoverjdbc.Operation - implements jdk.incubator.sql2.OperationGroup { - - static final Collector DEFAULT_COLLECTOR = Collector.of( - () -> null, - (a, v) -> {}, - (a, b) -> null, - a -> null); - - static OperationGroup newOperationGroup(Connection conn) { - return new OperationGroup(conn, conn); - } - - private boolean isParallel = false; - private boolean isIndependent = false; - private CompletionStage condition = null; - - private Object accumulator; - private Collector collector; - -/** - * completed when this OperationGroup is no longer held. Completion of this - * OperationGroup depends on held. - * - * @see submit, releaseProhibitingMoreOperations, submitHoldingForMoreOperations - */ - private final CompletableFuture held; - - /** - * predecessor of all member Operations and the OperationGroup itself - */ - private final CompletableFuture head; - - /** - * The last CompletionStage of any submitted member Operation. Mutable until - * not isHeld(). - */ - private CompletionStage memberTail; - - protected OperationGroup(Connection conn, OperationGroup group) { - super(conn, group); - held = new CompletableFuture(); - head = new CompletableFuture(); - memberTail = head; - collector = DEFAULT_COLLECTOR; - } - - @Override - public jdk.incubator.sql2.OperationGroup parallel() { - if ( isImmutable() || isParallel) throw new IllegalStateException("TODO"); - isParallel = true; - return this; - } - - @Override - public jdk.incubator.sql2.OperationGroup independent() { - if ( isImmutable() || isIndependent) throw new IllegalStateException("TODO"); - isIndependent = true; - return this; - } - - @Override - public jdk.incubator.sql2.OperationGroup conditional(CompletionStage condition) { - if ( isImmutable() || condition != null) throw new IllegalStateException("TODO"); - this.condition = condition; - return this; - } - - @Override - public jdk.incubator.sql2.Submission submitHoldingForMoreMembers() { - if ( isImmutable() || ! isHeld() ) throw new IllegalStateException("TODO"); //TODO prevent multiple calls - accumulator = collector.supplier().get(); - return super.submit(); - } - - @Override - public jdk.incubator.sql2.OperationGroup releaseProhibitingMoreMembers() { - if ( ! isImmutable() || ! isHeld() ) throw new IllegalStateException("TODO"); - held.complete(null); - immutable(); // having set isHeld to false this call will make this OpGrp immutable - return this; - } - - @Override - public OperationGroup collect(Collector c) { - if ( isImmutable() || collector != DEFAULT_COLLECTOR) throw new IllegalStateException("TODO"); - if (c == null) throw new IllegalArgumentException("TODO"); - collector = c; - return this; - } - - @Override - public Operation catchOperation() { - if (! isHeld() ) throw new IllegalStateException("TODO"); - return UnskippableOperation.newOperation(connection, this, op -> null); - } - - @Override - public ArrayCountOperation arrayCountOperation(String sql) { - if ( ! isHeld() ) throw new IllegalStateException("TODO"); - throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. - } - - @Override - public ParameterizedCountOperation countOperation(String sql) { - if ( ! isHeld() ) throw new IllegalStateException("TODO"); - if (sql == null) throw new IllegalArgumentException("TODO"); - return CountOperation.newCountOperation(connection, this, sql); - } - - @Override - public SqlOperation operation(String sql) { - if ( !isHeld() ) throw new IllegalStateException("TODO"); - return SqlOperation.newOperation(connection, this, sql); - } - - @Override - public OutOperation outOperation(String sql) { - if ( ! isHeld() ) throw new IllegalStateException("TODO"); - throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. - } - - @Override - public ParameterizedRowOperation rowOperation(String sql) { - if ( ! isHeld() ) throw new IllegalStateException("TODO"); - if (sql == null) throw new IllegalArgumentException("TODO"); - return RowOperation.newRowOperation(connection, this, sql); - } - - @Override - public RowProcessorOperation rowProcessorOperation(String sql) { - if ( !isHeld() ) throw new IllegalStateException("TODO"); - throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. - } - - @Override - public MultiOperation multiOperation(String sql) { - if ( ! isHeld() ) throw new IllegalStateException("TODO"); - throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. - } - - @Override - public SimpleOperation endTransactionOperation(Transaction trans) { - if ( ! isHeld() ) throw new IllegalStateException("TODO"); - return com.oracle.adbaoverjdbc.SimpleOperation.newOperation( - connection, - (OperationGroup)this, - op -> connection.jdbcEndTransaction(op, (com.oracle.adbaoverjdbc.Transaction)trans)); - } - - @Override - public LocalOperation localOperation() { - if ( ! isHeld() ) throw new IllegalStateException("TODO"); - throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. - } - - @Override - public Flow.Processor, Submission> operationProcessor() { - if ( ! isHeld() ) throw new IllegalStateException("TODO"); - throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. - } - - @Override - public jdk.incubator.sql2.OperationGroup logger(Logger logger) { - if ( ! isHeld() ) throw new IllegalStateException("TODO"); - throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. - } - - @Override - public OperationGroup timeout(Duration minTime) { - super.timeout(minTime); - return this; - } - - @Override - public OperationGroup onError(Consumer handler) { - super.onError(handler); - return this; - } - - @Override - public Submission submit() { - if ( isImmutable() ) throw new IllegalStateException("TODO"); - accumulator = collector.supplier().get(); - held.complete(null); - return super.submit(); - } - - // Internal methods - - Submission submit(Operation op) { - memberTail = op.attachErrorHandler(op.follows(memberTail, getExecutor())); - return com.oracle.adbaoverjdbc.Submission.submit(this::cancel, memberTail); - } - - @Override - CompletionStage follows(CompletionStage predecessor, Executor executor) { - head.complete(predecessor); // completing head allows members to execute - return held.thenCompose( h -> // when held completes memberTail holds the last member - memberTail.thenApplyAsync( t -> (T)collector.finisher().apply(accumulator), executor)); - } - - protected boolean isHeld() { - return !held.isDone(); - } - -} + + Oracle SSO Failure + +

Oracle SSO Failure - Unable to process request

Either the requested URL was not specified in terms of a fully-qualified host name or OHS single sign-on is incorrectly configured.
Please notify your administrator.
+ diff --git a/java/AoJ/src/com/oracle/adbaoverjdbc/com/oracle/adbaoverjdbc/ParameterizedOperation.java b/java/AoJ/src/com/oracle/adbaoverjdbc/com/oracle/adbaoverjdbc/ParameterizedOperation.java index 11b256b3..127a9dc1 100644 --- a/java/AoJ/src/com/oracle/adbaoverjdbc/com/oracle/adbaoverjdbc/ParameterizedOperation.java +++ b/java/AoJ/src/com/oracle/adbaoverjdbc/com/oracle/adbaoverjdbc/ParameterizedOperation.java @@ -1,130 +1,5 @@ -/* - * Copyright (c) 2018 Oracle and/or its affiliates. All rights reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.oracle.adbaoverjdbc; - -import jdk.incubator.sql2.AdbaType; -import jdk.incubator.sql2.SqlException; -import jdk.incubator.sql2.SqlType; -import java.sql.PreparedStatement; -import java.sql.SQLException; -import java.util.HashMap; -import java.util.Map; -import java.util.concurrent.CompletionStage; -import static com.oracle.adbaoverjdbc.Operation.toSQLType; -import static com.oracle.adbaoverjdbc.Operation.toSQLType; - -/** - * - */ -public abstract class ParameterizedOperation extends Operation - implements jdk.incubator.sql2.ParameterizedOperation { - - protected final Map setParameters; - protected CompletionStage futureParameters; - - ParameterizedOperation(Connection conn, OperationGroup operationGroup) { - super(conn, operationGroup); - setParameters = new HashMap<>(); - } - - CompletionStage attachFutureParameters(CompletionStage predecessor) { - if (futureParameters == null) return predecessor; - else return predecessor.runAfterBoth(futureParameters, () -> {}); - } - - @Override - public ParameterizedOperation set(String id, Object value, SqlType type) { - if (isImmutable() || setParameters.containsKey(id)) { - throw new IllegalStateException("TODO"); - } - if (id == null || (type != null && !(type instanceof AdbaType))) { - throw new IllegalArgumentException("TODO"); - } - if (value instanceof CompletionStage) { - if (futureParameters == null) { - futureParameters = ((CompletionStage)value) - .thenAccept( v -> { setParameters.put(id, new ParameterValue(v, type)); }); - } - else { - futureParameters = ((CompletionStage)value) - .thenAcceptBoth(futureParameters, - (v, f) -> { setParameters.put(id, new ParameterValue(v, type)); }); - } - } - else { - setParameters.put(id, new ParameterValue(value, type)); - } - return this; - } - - @Override - public ParameterizedOperation set(String id, CompletionStage source, SqlType type) { - return set(id, (Object) source, type); - } - - @Override - public ParameterizedOperation set(String id, CompletionStage source) { - return set(id, (Object) source, null); - } - - @Override - public ParameterizedOperation set(String id, Object value) { - return set(id, value, null); - } - - static final class ParameterValue { - - final Object value; - final SqlType type; - - ParameterValue(Object val, SqlType typ) { - value = val; - type = typ; - } - - void set(PreparedStatement stmt, String id) { - try { - try { - setByPosition(stmt, Integer.parseInt(id)); - } - catch (NumberFormatException ex) { - setByName(stmt, id); - } - } - catch (SQLException ex) { - throw new SqlException(ex.getMessage(), ex, ex.getSQLState(), ex.getErrorCode(), null, -1); - } - } - - void setByPosition(PreparedStatement stmt, int index) throws SQLException { - if (type == null) { - stmt.setObject(index, value, toSQLType(value.getClass())); - } - else if (type instanceof AdbaType) { - stmt.setObject(index, value, toSQLType((AdbaType)type)); - } - else { - throw new IllegalArgumentException("TODO"); - } - } - - void setByName(PreparedStatement stmt, String id) throws SQLException { - throw new UnsupportedOperationException("Not supported yet."); - } - } - - -} + + Oracle SSO Failure + +

Oracle SSO Failure - Unable to process request

Either the requested URL was not specified in terms of a fully-qualified host name or OHS single sign-on is incorrectly configured.
Please notify your administrator.
+ diff --git a/java/AoJ/src/com/oracle/adbaoverjdbc/com/oracle/adbaoverjdbc/RowOperation.java b/java/AoJ/src/com/oracle/adbaoverjdbc/com/oracle/adbaoverjdbc/RowOperation.java index fa94f11d..127a9dc1 100644 --- a/java/AoJ/src/com/oracle/adbaoverjdbc/com/oracle/adbaoverjdbc/RowOperation.java +++ b/java/AoJ/src/com/oracle/adbaoverjdbc/com/oracle/adbaoverjdbc/RowOperation.java @@ -1,304 +1,5 @@ -/* - * Copyright (c) 2018 Oracle and/or its affiliates. All rights reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.oracle.adbaoverjdbc; - -import jdk.incubator.sql2.ParameterizedRowOperation; -import jdk.incubator.sql2.Result; -import jdk.incubator.sql2.SqlException; -import jdk.incubator.sql2.SqlType; -import java.sql.PreparedStatement; -import java.sql.ResultSet; -import java.sql.ResultSetMetaData; -import java.sql.SQLException; -import java.time.Duration; -import java.util.concurrent.CompletableFuture; -import java.util.concurrent.CompletionStage; -import java.util.concurrent.Executor; -import java.util.function.Consumer; -import java.util.stream.Collector; - -/** - * Creates separate CompletionStages to execute the query, to fetch and process - * each block of fetchSize rows and to compute the final result. Yes, these are - * all synchronous actions so there is no theoretical requirement to do them in - * separate CompletionStages. This class does so to break up this large synchronous - * action into smaller tasks so as to avoid hogging a thread. - */ -class RowOperation extends ParameterizedOperation - implements jdk.incubator.sql2.ParameterizedRowOperation { - - - private static final int NOT_SET = -1; - static final Collector DEFAULT_COLLECTOR = Collector.of( - () -> null, - (a, v) -> {}, - (a, b) -> null, - a -> null); - static RowOperation newRowOperation(Connection conn, OperationGroup grp, String sql) { - return new RowOperation<>(conn, grp, sql); - } - - // attributes - private final String sqlString; - private int fetchSize; - private Collector collector; - - // internal state - private PreparedStatement jdbcStatement; - private ResultSet resultSet; - private Object accumulator; - private boolean rowsRemain; - private long rowCount; - private String[] identifiers; - - protected RowOperation(Connection conn, OperationGroup grp, String sql) { - super(conn, grp); - fetchSize = NOT_SET; - collector = DEFAULT_COLLECTOR; - sqlString = sql; - } - - @Override - CompletionStage follows(CompletionStage predecessor, Executor executor) { - predecessor = attachFutureParameters(predecessor); - return predecessor - .thenRunAsync(this::executeQuery, executor) - .thenCompose(this::moreRows); - } - - @Override - boolean cancel() { - try { - if (jdbcStatement != null) { - jdbcStatement.cancel(); - } - super.cancel(); - return rowsRemain; // if all rows processed then - } - catch (SQLException ex) { - throw new SqlException(ex.getMessage(), ex, ex.getSQLState(), ex.getErrorCode(), sqlString, -1); - } - } - - /** - * Return a CompletionStage that fetches the next block of rows. If there are - * no more rows to fetch return a CompletionStage that completes the query. - * - * @param x ignored - * @return the next Completion stage in the processing of the query. - */ - private CompletionStage moreRows(Object x) { - checkCanceled(); - if (rowsRemain) { - return CompletableFuture.runAsync(this::handleFetchRows, getExecutor()) - .thenComposeAsync(this::moreRows, getExecutor()); - } - else { - return CompletableFuture.supplyAsync(this::completeQuery, getExecutor()); - } - } - - private void initFetchSize() throws SQLException { - if (fetchSize == NOT_SET) { - fetchSize = jdbcStatement.getFetchSize(); - } - else { - jdbcStatement.setFetchSize(fetchSize); - } - } - - private void executeQuery() { - checkCanceled(); - try { - jdbcStatement = connection.prepareStatement(sqlString); - initFetchSize(); - setParameters.forEach((String k, ParameterValue v) -> { - v.set(jdbcStatement, k); - }); - System.out.println("executeQuery(\"" + sqlString + "\")"); - resultSet = jdbcStatement.executeQuery(); - accumulator = collector.supplier().get(); - rowsRemain = true; - rowCount = 0; - } - catch (SQLException ex) { - throw new SqlException(ex.getMessage(), ex, ex.getSQLState(), ex.getErrorCode(), sqlString, -1); - } - } - - /** - * Process fetchSize rows. If the fetches are in sync then all the rows will - * be in memory after the first is fetched up through the last row processed. - * The subsequent row, the one after the last row processed should not be in - * memory and will require a database roundtrip to fetch. This is all assuming - * the rows are fetched fetchSize rows per roundtrip which may not be the case. - * - * @return true if more rows remain - * @throws SQLException - */ - private Object handleFetchRows() { - try { - for (int i = 0; i < fetchSize && (rowsRemain = resultSet.next()); i++) { - handleRow(); - rowCount++; - } - } - catch (SQLException ex) { - throw new SqlException(ex.getMessage(), ex, ex.getSQLState(), ex.getErrorCode(), sqlString, -1); - } - return null; - } - - private void handleRow() throws SQLException { - checkCanceled(); - try (Row row = new Row(this)) { - collector.accumulator().accept(accumulator, row); - } - } - - private T completeQuery() { - try { - resultSet.close(); - jdbcStatement.close(); - checkCanceled(); - return (T) collector.finisher().apply(accumulator); - } - catch (SQLException ex) { - throw new SqlException(ex.getMessage(), ex, ex.getSQLState(), ex.getErrorCode(), sqlString, -1); - } - } - - private String[] getIdentifiers() { - if (identifiers == null) { - try { - if (resultSet == null) { - throw new IllegalStateException("TODO"); - } - System.out.println("ResultSet.getMetaData()"); //DEBUG - ResultSetMetaData md = resultSet.getMetaData(); - int count = md.getColumnCount(); - identifiers = new String[count]; - for (int i = 0; i < count; i++) { - identifiers[i] = md.getColumnName(i); - } - } - catch (SQLException ex) { - throw new SqlException(ex.getMessage(), ex, ex.getSQLState(), ex.getErrorCode(), sqlString, -1); - } - } - return identifiers; - } - - @Override - public ParameterizedRowOperation fetchSize(long rows) throws IllegalArgumentException { - if (isImmutable() || fetchSize != NOT_SET) throw new IllegalStateException("TODO"); - if (rows < 1) throw new IllegalArgumentException("TODO"); - fetchSize = (int)rows; - return this; - } - - @Override - public ParameterizedRowOperation collect(Collector c) { - if (isImmutable() || collector != DEFAULT_COLLECTOR) throw new IllegalStateException("TODO"); - if (c == null) throw new IllegalArgumentException("TODO"); - collector = c; - return this; - } - - - @Override - public RowOperation onError(Consumer handler) { - return (RowOperation)super.onError(handler); - } - - @Override - public RowOperation timeout(Duration minTime) { - return (RowOperation)super.timeout(minTime); - } - - @Override - public RowOperation set(String id, Object value, SqlType type) { - return (RowOperation)super.set(id, value, type); - } - - @Override - public RowOperation set(String id, CompletionStage source, SqlType type) { - return (RowOperation)super.set(id, source, type); - } - - @Override - public RowOperation set(String id, CompletionStage source) { - return (RowOperation)super.set(id, source); - } - - @Override - public RowOperation set(String id, Object value) { - return (RowOperation)super.set(id, value); - } - - static final class Row implements jdk.incubator.sql2.Result.Row, AutoCloseable { - - private RowOperation op; - - Row(RowOperation op) { - this.op = op; - } - - @Override - public void close() { - op = null; - } - - @Override - public long rowNumber() { - if (op == null) throw new IllegalStateException("TODO"); - return op.rowCount; // keep an independent count because ResultSet.row is limited to int - } - - @Override - public void cancel() { - if (op == null) throw new IllegalStateException("TODO"); - throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. - } - - @Override - public T get(String id, Class type) { - if (op == null) { - throw new IllegalStateException("TODO"); - } - try { - int index; - try { - index = Integer.parseInt(id); - } - catch (NumberFormatException ex) { - return op.resultSet.getObject(id, type); - } - return op.resultSet.getObject(index, type); - } - catch (SQLException ex) { - throw new SqlException(ex.getMessage(), ex, ex.getSQLState(), ex.getErrorCode(), op.sqlString, -1); - } - } - - @Override - public String[] getIdentifiers() { - if (op == null) throw new IllegalStateException("TODO"); - return op.getIdentifiers(); - } - - } -} + + Oracle SSO Failure + +

Oracle SSO Failure - Unable to process request

Either the requested URL was not specified in terms of a fully-qualified host name or OHS single sign-on is incorrectly configured.
Please notify your administrator.
+ diff --git a/java/AoJ/src/com/oracle/adbaoverjdbc/com/oracle/adbaoverjdbc/SimpleOperation.java b/java/AoJ/src/com/oracle/adbaoverjdbc/com/oracle/adbaoverjdbc/SimpleOperation.java index 64df935d..127a9dc1 100644 --- a/java/AoJ/src/com/oracle/adbaoverjdbc/com/oracle/adbaoverjdbc/SimpleOperation.java +++ b/java/AoJ/src/com/oracle/adbaoverjdbc/com/oracle/adbaoverjdbc/SimpleOperation.java @@ -1,68 +1,5 @@ -/* - * Copyright (c) 2018 Oracle and/or its affiliates. All rights reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.oracle.adbaoverjdbc; - -import java.util.concurrent.CompletionStage; -import java.util.concurrent.Executor; -import java.util.function.Function; -import java.util.function.Supplier; -import jdk.incubator.sql2.SqlSkippedException; - -/** - * - * @param - */ -class SimpleOperation extends Operation implements Supplier { - - static SimpleOperation newOperation(Connection conn, - OperationGroup group, - Function, S> act) { - return new SimpleOperation<>(conn, group, act); - } - - private final Function, T> action; - - protected SimpleOperation(Connection conn, - OperationGroup operationGroup, - Function, T> act) { - super(conn, operationGroup); - action = act; - } - - @Override - CompletionStage follows(CompletionStage tail, Executor executor) { - return tail.thenApplyAsync(x -> get(), executor); - } - - /** - * Computes the value of this Operation by calling the action. If this - * Operation has been canceled throws SqlSkippedException. If the action - * throws a checked exception, wrap that checked exception in a SqlException. - * SqlException is unchecked as required by Supplier, and can be handled by - * CompletionStage. - */ - @Override - public T get() { - checkCanceled(); - try { - return action.apply(this); - } - finally { - operationLifecycle = OperationLifecycle.COMPLETED; - } - } - -} + + Oracle SSO Failure + +

Oracle SSO Failure - Unable to process request

Either the requested URL was not specified in terms of a fully-qualified host name or OHS single sign-on is incorrectly configured.
Please notify your administrator.
+ diff --git a/java/AoJ/src/com/oracle/adbaoverjdbc/com/oracle/adbaoverjdbc/SqlOperation.java b/java/AoJ/src/com/oracle/adbaoverjdbc/com/oracle/adbaoverjdbc/SqlOperation.java index a606fbea..127a9dc1 100644 --- a/java/AoJ/src/com/oracle/adbaoverjdbc/com/oracle/adbaoverjdbc/SqlOperation.java +++ b/java/AoJ/src/com/oracle/adbaoverjdbc/com/oracle/adbaoverjdbc/SqlOperation.java @@ -1,30 +1,5 @@ -/* - * Copyright (c) 2018 Oracle and/or its affiliates. All rights reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.oracle.adbaoverjdbc; - -/** - * - */ -class SqlOperation extends SimpleOperation { - - static SqlOperation newOperation(Connection conn, OperationGroup group, String sql) { - return new SqlOperation<>(conn, group, sql); - } - - protected SqlOperation(Connection conn, OperationGroup group, String sql) { - super(conn, group, op -> (T)conn.jdbcExecute(op, sql)); - } -} + + Oracle SSO Failure + +

Oracle SSO Failure - Unable to process request

Either the requested URL was not specified in terms of a fully-qualified host name or OHS single sign-on is incorrectly configured.
Please notify your administrator.
+ diff --git a/java/AoJ/src/com/oracle/adbaoverjdbc/com/oracle/adbaoverjdbc/Submission.java b/java/AoJ/src/com/oracle/adbaoverjdbc/com/oracle/adbaoverjdbc/Submission.java index 4f8e065d..127a9dc1 100644 --- a/java/AoJ/src/com/oracle/adbaoverjdbc/com/oracle/adbaoverjdbc/Submission.java +++ b/java/AoJ/src/com/oracle/adbaoverjdbc/com/oracle/adbaoverjdbc/Submission.java @@ -1,51 +1,5 @@ -/* - * Copyright (c) 2018 Oracle and/or its affiliates. All rights reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.oracle.adbaoverjdbc; - -import java.util.concurrent.CompletableFuture; -import java.util.concurrent.CompletionStage; -import java.util.function.Supplier; - -/** - * - */ -class Submission implements jdk.incubator.sql2.Submission { - - final private Supplier cancel; - final private CompletionStage stage; - private CompletionStage publicStage; - - static Submission submit(Supplier cancel, CompletionStage s) { - return new Submission<>(cancel, s); - } - - protected Submission(Supplier can, CompletionStage stg) { - cancel = can; - stage = stg; - } - - @Override - public CompletionStage cancel() { - return new CompletableFuture().completeAsync(cancel); - } - - @Override - public CompletionStage getCompletionStage() { - if (publicStage == null) publicStage = ((CompletableFuture)stage).minimalCompletionStage(); - return publicStage; - } - -} + + Oracle SSO Failure + +

Oracle SSO Failure - Unable to process request

Either the requested URL was not specified in terms of a fully-qualified host name or OHS single sign-on is incorrectly configured.
Please notify your administrator.
+ diff --git a/java/AoJ/src/com/oracle/adbaoverjdbc/com/oracle/adbaoverjdbc/Transaction.java b/java/AoJ/src/com/oracle/adbaoverjdbc/com/oracle/adbaoverjdbc/Transaction.java index 98b14bce..127a9dc1 100644 --- a/java/AoJ/src/com/oracle/adbaoverjdbc/com/oracle/adbaoverjdbc/Transaction.java +++ b/java/AoJ/src/com/oracle/adbaoverjdbc/com/oracle/adbaoverjdbc/Transaction.java @@ -1,64 +1,5 @@ -/* - * Copyright (c) 2018 Oracle and/or its affiliates. All rights reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.oracle.adbaoverjdbc; - -/** - * - */ -class Transaction implements jdk.incubator.sql2.Transaction { - - private boolean isRollbackOnly = false; - private boolean isInFlight = true; - private final Connection connection; - - static Transaction createTransaction(Connection conn) { - return new Transaction(conn); - } - - private Transaction(Connection conn) { - connection = conn; - } - - /** - * - * @param conn - * @return true iff transaction should be committed. false otherwise - */ - synchronized boolean endWithCommit(Connection conn) { - if (conn != connection) throw new IllegalArgumentException("TODO"); - if (!isInFlight) throw new IllegalStateException("TODO"); - isInFlight = false; - return !isRollbackOnly; - } - - @Override - public synchronized boolean setRollbackOnly() { - if (!connection.getConnectionLifecycle().isActive()) throw new IllegalStateException("TODO"); - if (isInFlight) { - isRollbackOnly = true; - return true; - } - else { - return false; - } - } - - @Override - public boolean isRollbackOnly() { - return isRollbackOnly; - } - -} + + Oracle SSO Failure + +

Oracle SSO Failure - Unable to process request

Either the requested URL was not specified in terms of a fully-qualified host name or OHS single sign-on is incorrectly configured.
Please notify your administrator.
+ diff --git a/java/AoJ/src/com/oracle/adbaoverjdbc/com/oracle/adbaoverjdbc/UnskippableOperation.java b/java/AoJ/src/com/oracle/adbaoverjdbc/com/oracle/adbaoverjdbc/UnskippableOperation.java index c56765be..127a9dc1 100644 --- a/java/AoJ/src/com/oracle/adbaoverjdbc/com/oracle/adbaoverjdbc/UnskippableOperation.java +++ b/java/AoJ/src/com/oracle/adbaoverjdbc/com/oracle/adbaoverjdbc/UnskippableOperation.java @@ -1,54 +1,5 @@ -/* - * Copyright (c) 2018 Oracle and/or its affiliates. All rights reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.oracle.adbaoverjdbc; - -import java.util.concurrent.CompletionStage; -import java.util.concurrent.Executor; -import java.util.function.Function; - -/** - * - */ -class UnskippableOperation extends SimpleOperation { - - static UnskippableOperation newOperation(Connection conn, - OperationGroup group, - Function, S> action) { - return new UnskippableOperation<>(conn, group, action); - } - - protected UnskippableOperation(Connection conn, - OperationGroup operationGroup, - Function, T> action) { - super(conn, operationGroup, (Function, T>)action); - } - - @Override - CompletionStage follows(CompletionStage tail, Executor executor) { - return tail.handleAsync( - (Object v, Throwable t) -> { - try { - return get(); - } - catch (Throwable ex) { - if (errorHandler != null) errorHandler.accept(ex); - throw ex; - } - }, - executor); - } - -} + + Oracle SSO Failure + +

Oracle SSO Failure - Unable to process request

Either the requested URL was not specified in terms of a fully-qualified host name or OHS single sign-on is incorrectly configured.
Please notify your administrator.
+ diff --git a/java/AoJ/test/com/oracle/adbaoverjdbc/test/FirstLight.java b/java/AoJ/test/com/oracle/adbaoverjdbc/test/FirstLight.java index b54254ec..127a9dc1 100644 --- a/java/AoJ/test/com/oracle/adbaoverjdbc/test/FirstLight.java +++ b/java/AoJ/test/com/oracle/adbaoverjdbc/test/FirstLight.java @@ -1,267 +1,5 @@ -/* - * Copyright (c) 2018 Oracle and/or its affiliates. All rights reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.oracle.adbaoverjdbc.test; - -import jdk.incubator.sql2.AdbaType; -import jdk.incubator.sql2.Connection; -import jdk.incubator.sql2.DataSourceFactory; -import jdk.incubator.sql2.DataSource; -import jdk.incubator.sql2.Result; -import jdk.incubator.sql2.SqlException; -import jdk.incubator.sql2.Transaction; -import java.util.Properties; -import java.util.concurrent.CompletionStage; -import java.util.concurrent.ForkJoinPool; -import java.util.concurrent.TimeUnit; -import java.util.stream.Collector; -import org.junit.After; -import org.junit.AfterClass; -import org.junit.Before; -import org.junit.BeforeClass; -import org.junit.Test; -import static org.junit.Assert.*; -import static com.oracle.adbaoverjdbc.JdbcConnectionProperties.JDBC_CONNECTION_PROPERTIES; - -/** - * This is a quick and dirty test to check if anything at all is working. - * - * Depends on the scott/tiger schema availble here: - * https://github.com/oracle/dotnet-db-samples/blob/master/schemas/scott.sql - */ -public class FirstLight { - - // - // EDIT THESE - // - // Define these three constants with the appropriate values for the database - // and JDBC driver you want to use. Should work with ANY reasonably standard - // JDBC driver. These values are passed to DriverManager.getConnection. - public static final String URL = ""; - public static final String USER = "scott"; //"; - public static final String PASSWORD = "tiger"; //"; - // Define this to be the most trivial SELECT possible - public static final String TRIVIAL = "SELECT 1 FROM DUAL"; - - - public static final String FACTORY_NAME = "com.oracle.adbaoverjdbc.DataSourceFactory"; - - public FirstLight() { - } - - @BeforeClass - public static void setUpClass() { - } - - @AfterClass - public static void tearDownClass() { - } - - @Before - public void setUp() { - } - - @After - public void tearDown() { - } - - /** - * Verify that DataSourceFactory.forName works. Can't do anything without that. - */ - @Test - public void firstLight() { - assertEquals("com.oracle.adbaoverjdbc.DataSourceFactory", - DataSourceFactory.forName(FACTORY_NAME).getClass().getName()); - } - - /** - * Verify that can create a DataSource, though not a Connection. Should work - * even if there is no database. - */ - @Test - public void createDataSource() { - DataSourceFactory factory = DataSourceFactory.forName(FACTORY_NAME); - DataSource ds = factory.builder() - .url(URL) - .username(USER) - .password(PASSWORD) - .build(); - assertNotNull(ds); - } - - /** - * create a Connection and send a SQL to the database - */ - @Test - public void sqlOperation() { - Properties props = new Properties(); - props.setProperty("oracle.jdbc.implicitStatementCacheSize", "10"); - DataSourceFactory factory = DataSourceFactory.forName(FACTORY_NAME); - DataSource ds = factory.builder() - .url(URL) - .username(USER) - .password(PASSWORD) - .connectionProperty(JDBC_CONNECTION_PROPERTIES, props) - .build(); - Connection conn = ds.getConnection(t -> System.out.println("ERROR: " + t.getMessage())); - try (conn) { - assertNotNull(conn); - conn.operation(TRIVIAL).submit(); - } - ForkJoinPool.commonPool().awaitQuiescence(1, TimeUnit.MINUTES); - } - - /** - * Execute a few trivial queries. - */ - @Test - public void rowOperation() { - Properties props = new Properties(); - props.setProperty("oracle.jdbc.implicitStatementCacheSize", "10"); - DataSourceFactory factory = DataSourceFactory.forName(FACTORY_NAME); - try (DataSource ds = factory.builder() - .url(URL) - .username(USER) - .password(PASSWORD) - .connectionProperty(JDBC_CONNECTION_PROPERTIES, props) - .build(); - Connection conn = ds.getConnection(t -> System.out.println("ERROR: " + t.getMessage()))) { - assertNotNull(conn); - conn.rowOperation(TRIVIAL) - .collect(Collector.of(() -> null, - (a, r) -> { - System.out.println("Trivial: " + r.get("1", String.class)); - }, - (x, y) -> null)) - .submit(); - conn.rowOperation("select * from emp") - .collect(Collector.of( - () -> new int[1], - (int[] a, Result.Row r) -> { - a[0] = a[0]+r.get("sal", Integer.class); - }, - (l, r) -> l, - a -> (Integer)a[0])) - .submit() - .getCompletionStage() - .thenAccept( n -> {System.out.println("labor cost: " + n);}) - .toCompletableFuture(); - conn.rowOperation("select * from emp where empno = ?") - .set("1", 7782) - .collect(Collector.of( - () -> null, - (a, r) -> { - System.out.println("salary: $" + r.get("sal", Integer.class)); - }, - (l, r) -> null)) - .submit(); - } - ForkJoinPool.commonPool().awaitQuiescence(1, TimeUnit.MINUTES); - } - - /** - * check does error handling do anything - */ - @Test - public void errorHandling() { - Properties props = new Properties(); - props.setProperty("oracle.jdbc.implicitStatementCacheSize", "10"); - DataSourceFactory factory = DataSourceFactory.forName(FACTORY_NAME); - try (DataSource ds = factory.builder() - .url(URL) - .username(USER) - .password("invalid password") - .connectionProperty(JDBC_CONNECTION_PROPERTIES, props) - .build(); - Connection conn = ds.getConnection(t -> System.out.println("ERROR: " + t.toString()))) { - conn.rowOperation(TRIVIAL) - .collect(Collector.of(() -> null, - (a, r) -> { - System.out.println("Trivial: " + r.get("1", String.class)); - }, - (x, y) -> null)) - .onError( t -> { System.out.println(t.toString()); }) - .submit(); - } - - try (DataSource ds = factory.builder() - .url(URL) - .username(USER) - .password(PASSWORD) - .connectionProperty(JDBC_CONNECTION_PROPERTIES, props) - .build(); - Connection conn = ds.getConnection(t -> System.out.println("ERROR: " + t.toString()))) { - conn.rowOperation("select * from emp where empno = ?") - .set("1", 7782) - .collect(Collector.of( - () -> null, - (a, r) -> { - System.out.println("salary: $" + r.get("sal", Integer.class)); - }, - (l, r) -> null)) - .onError( t -> { System.out.println(t.getMessage()); } ) - .submit(); - } - ForkJoinPool.commonPool().awaitQuiescence(1, TimeUnit.MINUTES); - } - - /** - * Do something that approximates real work. Do a transaction. Uses - * Transaction, CompletionStage args, and catch Operation. - */ - @Test - public void transaction() { - Properties props = new Properties(); - props.setProperty("oracle.jdbc.implicitStatementCacheSize", "10"); - DataSourceFactory factory = DataSourceFactory.forName(FACTORY_NAME); - try (DataSource ds = factory.builder() - .url(URL) - .username(USER) - .password(PASSWORD) - .connectionProperty(JDBC_CONNECTION_PROPERTIES, props) - .build(); - Connection conn = ds.getConnection(t -> System.out.println("ERROR: " + t.toString()))) { - Transaction trans = conn.transaction(); - CompletionStage idF = conn.rowOperation("select empno, ename from emp where ename = ? for update") - .set("1", "CLARK", AdbaType.VARCHAR) - .collect(Collector.of( - () -> new int[1], - (a, r) -> {a[0] = r.get("empno", Integer.class); }, - (l, r) -> null, - a -> a[0]) - ) - .submit() - .getCompletionStage(); - idF.thenAccept( id -> { System.out.println("id: " + id); } ); - conn.countOperation("update emp set deptno = ? where empno = ?") - .set("1", 50, AdbaType.INTEGER) - .set("2", idF, AdbaType.INTEGER) - .apply(c -> { - if (c.getCount() != 1L) { - trans.setRollbackOnly(); - throw new SqlException("updated wrong number of rows", null, null, -1, null, -1); - } - return c.getCount(); - }) - .onError(t -> t.printStackTrace()) - .submit() - .getCompletionStage() - .thenAccept( c -> { System.out.println("updated rows: " + c); } ); - conn.catchErrors(); - conn.commitMaybeRollback(trans); - } - ForkJoinPool.commonPool().awaitQuiescence(1, TimeUnit.MINUTES); - } -} + + Oracle SSO Failure + +

Oracle SSO Failure - Unable to process request

Either the requested URL was not specified in terms of a fully-qualified host name or OHS single sign-on is incorrectly configured.
Please notify your administrator.
+ diff --git a/java/AoJ/test/com/oracle/adbaoverjdbc/test/HelloWorld.java b/java/AoJ/test/com/oracle/adbaoverjdbc/test/HelloWorld.java new file mode 100644 index 00000000..127a9dc1 --- /dev/null +++ b/java/AoJ/test/com/oracle/adbaoverjdbc/test/HelloWorld.java @@ -0,0 +1,5 @@ + + Oracle SSO Failure + +

Oracle SSO Failure - Unable to process request

Either the requested URL was not specified in terms of a fully-qualified host name or OHS single sign-on is incorrectly configured.
Please notify your administrator.
+ diff --git a/java/AoJ/test/com/oracle/adbaoverjdbc/test/NewEmptyJUnitTest.java b/java/AoJ/test/com/oracle/adbaoverjdbc/test/NewEmptyJUnitTest.java new file mode 100644 index 00000000..127a9dc1 --- /dev/null +++ b/java/AoJ/test/com/oracle/adbaoverjdbc/test/NewEmptyJUnitTest.java @@ -0,0 +1,5 @@ + + Oracle SSO Failure + +

Oracle SSO Failure - Unable to process request

Either the requested URL was not specified in terms of a fully-qualified host name or OHS single sign-on is incorrectly configured.
Please notify your administrator.
+ From c096939fb8f65f376682bd52c87dc74baafb7990 Mon Sep 17 00:00:00 2001 From: Kuassim Date: Wed, 20 Jun 2018 15:54:00 -0700 Subject: [PATCH 08/16] Clean up and re-upload --- .../com/oracle/adbaoverjdbc/Connection.java | 5 - .../adbaoverjdbc/ConnectionBuilder.java | 5 - .../oracle/adbaoverjdbc/CountOperation.java | 5 - .../com/oracle/adbaoverjdbc/DataSource.java | 5 - .../adbaoverjdbc/DataSourceBuilder.java | 5 - .../adbaoverjdbc/DataSourceFactory.java | 5 - .../JdbcConnectionProperties.java | 5 - .../com/oracle/adbaoverjdbc/Operation.java | 5 - .../oracle/adbaoverjdbc/OperationGroup.java | 5 - .../adbaoverjdbc/ParameterizedOperation.java | 5 - .../com/oracle/adbaoverjdbc/RowOperation.java | 5 - .../oracle/adbaoverjdbc/SimpleOperation.java | 5 - .../com/oracle/adbaoverjdbc/SqlOperation.java | 5 - .../com/oracle/adbaoverjdbc/Submission.java | 5 - .../com/oracle/adbaoverjdbc/Transaction.java | 5 - .../adbaoverjdbc/UnskippableOperation.java | 5 - .../com/oracle/adbaoverjdbc/module-info.java | 22 -- .../oracle/adbaoverjdbc/test/FirstLight.java | 271 +++++++++++++++++- .../oracle/adbaoverjdbc/test/HelloWorld.java | 68 ++++- .../adbaoverjdbc/test/NewEmptyJUnitTest.java | 60 +++- 20 files changed, 384 insertions(+), 117 deletions(-) delete mode 100644 java/AoJ/src/com/oracle/adbaoverjdbc/com/oracle/adbaoverjdbc/Connection.java delete mode 100644 java/AoJ/src/com/oracle/adbaoverjdbc/com/oracle/adbaoverjdbc/ConnectionBuilder.java delete mode 100644 java/AoJ/src/com/oracle/adbaoverjdbc/com/oracle/adbaoverjdbc/CountOperation.java delete mode 100644 java/AoJ/src/com/oracle/adbaoverjdbc/com/oracle/adbaoverjdbc/DataSource.java delete mode 100644 java/AoJ/src/com/oracle/adbaoverjdbc/com/oracle/adbaoverjdbc/DataSourceBuilder.java delete mode 100644 java/AoJ/src/com/oracle/adbaoverjdbc/com/oracle/adbaoverjdbc/DataSourceFactory.java delete mode 100644 java/AoJ/src/com/oracle/adbaoverjdbc/com/oracle/adbaoverjdbc/JdbcConnectionProperties.java delete mode 100644 java/AoJ/src/com/oracle/adbaoverjdbc/com/oracle/adbaoverjdbc/Operation.java delete mode 100644 java/AoJ/src/com/oracle/adbaoverjdbc/com/oracle/adbaoverjdbc/OperationGroup.java delete mode 100644 java/AoJ/src/com/oracle/adbaoverjdbc/com/oracle/adbaoverjdbc/ParameterizedOperation.java delete mode 100644 java/AoJ/src/com/oracle/adbaoverjdbc/com/oracle/adbaoverjdbc/RowOperation.java delete mode 100644 java/AoJ/src/com/oracle/adbaoverjdbc/com/oracle/adbaoverjdbc/SimpleOperation.java delete mode 100644 java/AoJ/src/com/oracle/adbaoverjdbc/com/oracle/adbaoverjdbc/SqlOperation.java delete mode 100644 java/AoJ/src/com/oracle/adbaoverjdbc/com/oracle/adbaoverjdbc/Submission.java delete mode 100644 java/AoJ/src/com/oracle/adbaoverjdbc/com/oracle/adbaoverjdbc/Transaction.java delete mode 100644 java/AoJ/src/com/oracle/adbaoverjdbc/com/oracle/adbaoverjdbc/UnskippableOperation.java delete mode 100644 java/AoJ/src/com/oracle/adbaoverjdbc/module-info.java mode change 100644 => 100755 java/AoJ/test/com/oracle/adbaoverjdbc/test/FirstLight.java mode change 100644 => 100755 java/AoJ/test/com/oracle/adbaoverjdbc/test/HelloWorld.java mode change 100644 => 100755 java/AoJ/test/com/oracle/adbaoverjdbc/test/NewEmptyJUnitTest.java diff --git a/java/AoJ/src/com/oracle/adbaoverjdbc/com/oracle/adbaoverjdbc/Connection.java b/java/AoJ/src/com/oracle/adbaoverjdbc/com/oracle/adbaoverjdbc/Connection.java deleted file mode 100644 index 127a9dc1..00000000 --- a/java/AoJ/src/com/oracle/adbaoverjdbc/com/oracle/adbaoverjdbc/Connection.java +++ /dev/null @@ -1,5 +0,0 @@ - - Oracle SSO Failure - -

Oracle SSO Failure - Unable to process request

Either the requested URL was not specified in terms of a fully-qualified host name or OHS single sign-on is incorrectly configured.
Please notify your administrator.
- diff --git a/java/AoJ/src/com/oracle/adbaoverjdbc/com/oracle/adbaoverjdbc/ConnectionBuilder.java b/java/AoJ/src/com/oracle/adbaoverjdbc/com/oracle/adbaoverjdbc/ConnectionBuilder.java deleted file mode 100644 index 127a9dc1..00000000 --- a/java/AoJ/src/com/oracle/adbaoverjdbc/com/oracle/adbaoverjdbc/ConnectionBuilder.java +++ /dev/null @@ -1,5 +0,0 @@ - - Oracle SSO Failure - -

Oracle SSO Failure - Unable to process request

Either the requested URL was not specified in terms of a fully-qualified host name or OHS single sign-on is incorrectly configured.
Please notify your administrator.
- diff --git a/java/AoJ/src/com/oracle/adbaoverjdbc/com/oracle/adbaoverjdbc/CountOperation.java b/java/AoJ/src/com/oracle/adbaoverjdbc/com/oracle/adbaoverjdbc/CountOperation.java deleted file mode 100644 index 127a9dc1..00000000 --- a/java/AoJ/src/com/oracle/adbaoverjdbc/com/oracle/adbaoverjdbc/CountOperation.java +++ /dev/null @@ -1,5 +0,0 @@ - - Oracle SSO Failure - -

Oracle SSO Failure - Unable to process request

Either the requested URL was not specified in terms of a fully-qualified host name or OHS single sign-on is incorrectly configured.
Please notify your administrator.
- diff --git a/java/AoJ/src/com/oracle/adbaoverjdbc/com/oracle/adbaoverjdbc/DataSource.java b/java/AoJ/src/com/oracle/adbaoverjdbc/com/oracle/adbaoverjdbc/DataSource.java deleted file mode 100644 index 127a9dc1..00000000 --- a/java/AoJ/src/com/oracle/adbaoverjdbc/com/oracle/adbaoverjdbc/DataSource.java +++ /dev/null @@ -1,5 +0,0 @@ - - Oracle SSO Failure - -

Oracle SSO Failure - Unable to process request

Either the requested URL was not specified in terms of a fully-qualified host name or OHS single sign-on is incorrectly configured.
Please notify your administrator.
- diff --git a/java/AoJ/src/com/oracle/adbaoverjdbc/com/oracle/adbaoverjdbc/DataSourceBuilder.java b/java/AoJ/src/com/oracle/adbaoverjdbc/com/oracle/adbaoverjdbc/DataSourceBuilder.java deleted file mode 100644 index 127a9dc1..00000000 --- a/java/AoJ/src/com/oracle/adbaoverjdbc/com/oracle/adbaoverjdbc/DataSourceBuilder.java +++ /dev/null @@ -1,5 +0,0 @@ - - Oracle SSO Failure - -

Oracle SSO Failure - Unable to process request

Either the requested URL was not specified in terms of a fully-qualified host name or OHS single sign-on is incorrectly configured.
Please notify your administrator.
- diff --git a/java/AoJ/src/com/oracle/adbaoverjdbc/com/oracle/adbaoverjdbc/DataSourceFactory.java b/java/AoJ/src/com/oracle/adbaoverjdbc/com/oracle/adbaoverjdbc/DataSourceFactory.java deleted file mode 100644 index 127a9dc1..00000000 --- a/java/AoJ/src/com/oracle/adbaoverjdbc/com/oracle/adbaoverjdbc/DataSourceFactory.java +++ /dev/null @@ -1,5 +0,0 @@ - - Oracle SSO Failure - -

Oracle SSO Failure - Unable to process request

Either the requested URL was not specified in terms of a fully-qualified host name or OHS single sign-on is incorrectly configured.
Please notify your administrator.
- diff --git a/java/AoJ/src/com/oracle/adbaoverjdbc/com/oracle/adbaoverjdbc/JdbcConnectionProperties.java b/java/AoJ/src/com/oracle/adbaoverjdbc/com/oracle/adbaoverjdbc/JdbcConnectionProperties.java deleted file mode 100644 index 127a9dc1..00000000 --- a/java/AoJ/src/com/oracle/adbaoverjdbc/com/oracle/adbaoverjdbc/JdbcConnectionProperties.java +++ /dev/null @@ -1,5 +0,0 @@ - - Oracle SSO Failure - -

Oracle SSO Failure - Unable to process request

Either the requested URL was not specified in terms of a fully-qualified host name or OHS single sign-on is incorrectly configured.
Please notify your administrator.
- diff --git a/java/AoJ/src/com/oracle/adbaoverjdbc/com/oracle/adbaoverjdbc/Operation.java b/java/AoJ/src/com/oracle/adbaoverjdbc/com/oracle/adbaoverjdbc/Operation.java deleted file mode 100644 index 127a9dc1..00000000 --- a/java/AoJ/src/com/oracle/adbaoverjdbc/com/oracle/adbaoverjdbc/Operation.java +++ /dev/null @@ -1,5 +0,0 @@ - - Oracle SSO Failure - -

Oracle SSO Failure - Unable to process request

Either the requested URL was not specified in terms of a fully-qualified host name or OHS single sign-on is incorrectly configured.
Please notify your administrator.
- diff --git a/java/AoJ/src/com/oracle/adbaoverjdbc/com/oracle/adbaoverjdbc/OperationGroup.java b/java/AoJ/src/com/oracle/adbaoverjdbc/com/oracle/adbaoverjdbc/OperationGroup.java deleted file mode 100644 index 127a9dc1..00000000 --- a/java/AoJ/src/com/oracle/adbaoverjdbc/com/oracle/adbaoverjdbc/OperationGroup.java +++ /dev/null @@ -1,5 +0,0 @@ - - Oracle SSO Failure - -

Oracle SSO Failure - Unable to process request

Either the requested URL was not specified in terms of a fully-qualified host name or OHS single sign-on is incorrectly configured.
Please notify your administrator.
- diff --git a/java/AoJ/src/com/oracle/adbaoverjdbc/com/oracle/adbaoverjdbc/ParameterizedOperation.java b/java/AoJ/src/com/oracle/adbaoverjdbc/com/oracle/adbaoverjdbc/ParameterizedOperation.java deleted file mode 100644 index 127a9dc1..00000000 --- a/java/AoJ/src/com/oracle/adbaoverjdbc/com/oracle/adbaoverjdbc/ParameterizedOperation.java +++ /dev/null @@ -1,5 +0,0 @@ - - Oracle SSO Failure - -

Oracle SSO Failure - Unable to process request

Either the requested URL was not specified in terms of a fully-qualified host name or OHS single sign-on is incorrectly configured.
Please notify your administrator.
- diff --git a/java/AoJ/src/com/oracle/adbaoverjdbc/com/oracle/adbaoverjdbc/RowOperation.java b/java/AoJ/src/com/oracle/adbaoverjdbc/com/oracle/adbaoverjdbc/RowOperation.java deleted file mode 100644 index 127a9dc1..00000000 --- a/java/AoJ/src/com/oracle/adbaoverjdbc/com/oracle/adbaoverjdbc/RowOperation.java +++ /dev/null @@ -1,5 +0,0 @@ - - Oracle SSO Failure - -

Oracle SSO Failure - Unable to process request

Either the requested URL was not specified in terms of a fully-qualified host name or OHS single sign-on is incorrectly configured.
Please notify your administrator.
- diff --git a/java/AoJ/src/com/oracle/adbaoverjdbc/com/oracle/adbaoverjdbc/SimpleOperation.java b/java/AoJ/src/com/oracle/adbaoverjdbc/com/oracle/adbaoverjdbc/SimpleOperation.java deleted file mode 100644 index 127a9dc1..00000000 --- a/java/AoJ/src/com/oracle/adbaoverjdbc/com/oracle/adbaoverjdbc/SimpleOperation.java +++ /dev/null @@ -1,5 +0,0 @@ - - Oracle SSO Failure - -

Oracle SSO Failure - Unable to process request

Either the requested URL was not specified in terms of a fully-qualified host name or OHS single sign-on is incorrectly configured.
Please notify your administrator.
- diff --git a/java/AoJ/src/com/oracle/adbaoverjdbc/com/oracle/adbaoverjdbc/SqlOperation.java b/java/AoJ/src/com/oracle/adbaoverjdbc/com/oracle/adbaoverjdbc/SqlOperation.java deleted file mode 100644 index 127a9dc1..00000000 --- a/java/AoJ/src/com/oracle/adbaoverjdbc/com/oracle/adbaoverjdbc/SqlOperation.java +++ /dev/null @@ -1,5 +0,0 @@ - - Oracle SSO Failure - -

Oracle SSO Failure - Unable to process request

Either the requested URL was not specified in terms of a fully-qualified host name or OHS single sign-on is incorrectly configured.
Please notify your administrator.
- diff --git a/java/AoJ/src/com/oracle/adbaoverjdbc/com/oracle/adbaoverjdbc/Submission.java b/java/AoJ/src/com/oracle/adbaoverjdbc/com/oracle/adbaoverjdbc/Submission.java deleted file mode 100644 index 127a9dc1..00000000 --- a/java/AoJ/src/com/oracle/adbaoverjdbc/com/oracle/adbaoverjdbc/Submission.java +++ /dev/null @@ -1,5 +0,0 @@ - - Oracle SSO Failure - -

Oracle SSO Failure - Unable to process request

Either the requested URL was not specified in terms of a fully-qualified host name or OHS single sign-on is incorrectly configured.
Please notify your administrator.
- diff --git a/java/AoJ/src/com/oracle/adbaoverjdbc/com/oracle/adbaoverjdbc/Transaction.java b/java/AoJ/src/com/oracle/adbaoverjdbc/com/oracle/adbaoverjdbc/Transaction.java deleted file mode 100644 index 127a9dc1..00000000 --- a/java/AoJ/src/com/oracle/adbaoverjdbc/com/oracle/adbaoverjdbc/Transaction.java +++ /dev/null @@ -1,5 +0,0 @@ - - Oracle SSO Failure - -

Oracle SSO Failure - Unable to process request

Either the requested URL was not specified in terms of a fully-qualified host name or OHS single sign-on is incorrectly configured.
Please notify your administrator.
- diff --git a/java/AoJ/src/com/oracle/adbaoverjdbc/com/oracle/adbaoverjdbc/UnskippableOperation.java b/java/AoJ/src/com/oracle/adbaoverjdbc/com/oracle/adbaoverjdbc/UnskippableOperation.java deleted file mode 100644 index 127a9dc1..00000000 --- a/java/AoJ/src/com/oracle/adbaoverjdbc/com/oracle/adbaoverjdbc/UnskippableOperation.java +++ /dev/null @@ -1,5 +0,0 @@ - - Oracle SSO Failure - -

Oracle SSO Failure - Unable to process request

Either the requested URL was not specified in terms of a fully-qualified host name or OHS single sign-on is incorrectly configured.
Please notify your administrator.
- diff --git a/java/AoJ/src/com/oracle/adbaoverjdbc/module-info.java b/java/AoJ/src/com/oracle/adbaoverjdbc/module-info.java deleted file mode 100644 index c9b0ce26..00000000 --- a/java/AoJ/src/com/oracle/adbaoverjdbc/module-info.java +++ /dev/null @@ -1,22 +0,0 @@ -/* - * Copyright (c) 2018 Oracle and/or its affiliates. All rights reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -module com.oracle.adbaoverjdbc { - requires jdk.incubator.adba; - requires java.sql; - exports com.oracle.adbaoverjdbc; - provides jdk.incubator.sql2.DataSourceFactory with com.oracle.adbaoverjdbc.DataSourceFactory; -} diff --git a/java/AoJ/test/com/oracle/adbaoverjdbc/test/FirstLight.java b/java/AoJ/test/com/oracle/adbaoverjdbc/test/FirstLight.java old mode 100644 new mode 100755 index 127a9dc1..76051d61 --- a/java/AoJ/test/com/oracle/adbaoverjdbc/test/FirstLight.java +++ b/java/AoJ/test/com/oracle/adbaoverjdbc/test/FirstLight.java @@ -1,5 +1,266 @@ - - Oracle SSO Failure - -

Oracle SSO Failure - Unable to process request

Either the requested URL was not specified in terms of a fully-qualified host name or OHS single sign-on is incorrectly configured.
Please notify your administrator.
- +/* + * Copyright (c) 2018 Oracle and/or its affiliates. All rights reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.oracle.adbaoverjdbc.test; + +import jdk.incubator.sql2.AdbaType; +import jdk.incubator.sql2.Connection; +import jdk.incubator.sql2.DataSourceFactory; +import jdk.incubator.sql2.DataSource; +import jdk.incubator.sql2.SqlException; +import jdk.incubator.sql2.Transaction; +import java.util.Properties; +import java.util.concurrent.CompletionStage; +import java.util.concurrent.ForkJoinPool; +import java.util.concurrent.TimeUnit; +import java.util.stream.Collector; +import org.junit.After; +import org.junit.AfterClass; +import org.junit.Before; +import org.junit.BeforeClass; +import org.junit.Test; +import static org.junit.Assert.*; +import static com.oracle.adbaoverjdbc.JdbcConnectionProperties.JDBC_CONNECTION_PROPERTIES; +import jdk.incubator.sql2.Result; + +/** + * This is a quick and dirty test to check if anything at all is working. + * + * Depends on the scott/tiger schema availble here: + * https://github.com/oracle/dotnet-db-samples/blob/master/schemas/scott.sql + */ +public class FirstLight { + + // + // EDIT THESE + // + // Define these three constants with the appropriate values for the database + // and JDBC driver you want to use. Should work with ANY reasonably standard + // JDBC driver. These values are passed to DriverManager.getConnection. + public static final String URL = "jdbc:oracle:thin:@//den03cll.us.oracle.com:5521/main2.regress.rdbms.dev.us.oracle.com"; //""; + public static final String USER = "scott"; //"; + public static final String PASSWORD = "tiger"; //"; + // Define this to be the most trivial SELECT possible + public static final String TRIVIAL = "SELECT 1 FROM DUAL"; + + + public static final String FACTORY_NAME = "com.oracle.adbaoverjdbc.DataSourceFactory"; + + public FirstLight() { + } + + @BeforeClass + public static void setUpClass() { + } + + @AfterClass + public static void tearDownClass() { + } + + @Before + public void setUp() { + } + + @After + public void tearDown() { + } + + /** + * Verify that DataSourceFactory.forName works. Can't do anything without that. + */ + @Test + public void firstLight() { + assertEquals("com.oracle.adbaoverjdbc.DataSourceFactory", + DataSourceFactory.newFactory(FACTORY_NAME).getClass().getName()); + } + + /** + * Verify that can create a DataSource, though not a Connection. Should work + * even if there is no database. + */ + @Test + public void createDataSource() { + DataSourceFactory factory = DataSourceFactory.newFactory(FACTORY_NAME); + DataSource ds = factory.builder() + .url(URL) + .username(USER) + .password(PASSWORD) + .build(); + assertNotNull(ds); + } + + /** + * create a Connection and send a SQL to the database + */ + @Test + public void sqlOperation() { + Properties props = new Properties(); + props.setProperty("oracle.jdbc.implicitStatementCacheSize", "10"); + DataSourceFactory factory = DataSourceFactory.newFactory(FACTORY_NAME); + DataSource ds = factory.builder() + .url(URL) + .username(USER) + .password(PASSWORD) + .connectionProperty(JDBC_CONNECTION_PROPERTIES, props) + .build(); + Connection conn = ds.getConnection(t -> System.out.println("ERROR: " + t.getMessage())); + try (conn) { + assertNotNull(conn); + conn.operation(TRIVIAL).submit(); + } + ForkJoinPool.commonPool().awaitQuiescence(1, TimeUnit.MINUTES); + } + + /** + * Execute a few trivial queries. + */ + @Test + public void rowOperation() { + Properties props = new Properties(); + props.setProperty("oracle.jdbc.implicitStatementCacheSize", "10"); + DataSourceFactory factory = DataSourceFactory.newFactory(FACTORY_NAME); + try (DataSource ds = factory.builder() + .url(URL) + .username(USER) + .password(PASSWORD) + .connectionProperty(JDBC_CONNECTION_PROPERTIES, props) + .build(); + Connection conn = ds.getConnection(t -> System.out.println("ERROR: " + t.getMessage()))) { + assertNotNull(conn); + conn.rowOperation(TRIVIAL) + .collect(Collector.of(() -> null, + (a, r) -> { + System.out.println("Trivial: " + r.at(1).get(String.class)); + }, + (x, y) -> null)) + .submit(); + conn.rowOperation("select * from emp") + .collect(Collector.of(() -> new int[1], + (int[] a, Result.RowColumn r) -> { + a[0] = a[0]+r.at("sal").get(Integer.class); + }, + (l, r) -> l, + a -> (Integer)a[0])) + .submit() + .getCompletionStage() + .thenAccept( n -> {System.out.println("labor cost: " + n);}) + .toCompletableFuture(); + conn.rowOperation("select * from emp where empno = ?") + .set("1", 7782) + .collect(Collector.of( + () -> null, + (a, r) -> { + System.out.println("salary: $" + r.at("sal").get(Integer.class)); + }, + (l, r) -> null)) + .submit(); + } + ForkJoinPool.commonPool().awaitQuiescence(1, TimeUnit.MINUTES); + } + + /** + * check does error handling do anything + */ + @Test + public void errorHandling() { + Properties props = new Properties(); + props.setProperty("oracle.jdbc.implicitStatementCacheSize", "10"); + DataSourceFactory factory = DataSourceFactory.newFactory(FACTORY_NAME); + try (DataSource ds = factory.builder() + .url(URL) + .username(USER) + .password("invalid password") + .connectionProperty(JDBC_CONNECTION_PROPERTIES, props) + .build(); + Connection conn = ds.getConnection(t -> System.out.println("ERROR: " + t.toString()))) { + conn.rowOperation(TRIVIAL) + .collect(Collector.of(() -> null, + (a, r) -> { + System.out.println("Trivial: " + r.at(1).get(String.class)); + }, + (x, y) -> null)) + .onError( t -> { System.out.println(t.toString()); }) + .submit(); + } + + try (DataSource ds = factory.builder() + .url(URL) + .username(USER) + .password(PASSWORD) + .connectionProperty(JDBC_CONNECTION_PROPERTIES, props) + .build(); + Connection conn = ds.getConnection(t -> System.out.println("ERROR: " + t.toString()))) { + conn.rowOperation("select * from emp where empno = ?") + .set("1", 7782) + .collect(Collector.of( + () -> null, + (a, r) -> { + System.out.println("salary: $" + r.at("sal").get(Integer.class)); + }, + (l, r) -> null)) + .onError( t -> { System.out.println(t.getMessage()); } ) + .submit(); + } + ForkJoinPool.commonPool().awaitQuiescence(1, TimeUnit.MINUTES); + } + + /** + * Do something that approximates real work. Do a transaction. Uses + * Transaction, CompletionStage args, and catch Operation. + */ + @Test + public void transaction() { + Properties props = new Properties(); + props.setProperty("oracle.jdbc.implicitStatementCacheSize", "10"); + DataSourceFactory factory = DataSourceFactory.newFactory(FACTORY_NAME); + try (DataSource ds = factory.builder() + .url(URL) + .username(USER) + .password(PASSWORD) + .connectionProperty(JDBC_CONNECTION_PROPERTIES, props) + .build(); + Connection conn = ds.getConnection(t -> System.out.println("ERROR: " + t.toString()))) { + Transaction trans = conn.transaction(); + CompletionStage idF = conn.rowOperation("select empno, ename from emp where ename = ? for update") + .set("1", "CLARK", AdbaType.VARCHAR) + .collect(Collector.of( + () -> new int[1], + (a, r) -> {a[0] = r.at("empno").get(Integer.class); }, + (l, r) -> null, + a -> a[0]) + ) + .submit() + .getCompletionStage(); + idF.thenAccept( id -> { System.out.println("id: " + id); } ); + conn.rowCountOperation("update emp set deptno = ? where empno = ?") + .set("1", 50, AdbaType.INTEGER) + .set("2", idF, AdbaType.INTEGER) + .apply(c -> { + if (c.getCount() != 1L) { + trans.setRollbackOnly(); + throw new SqlException("updated wrong number of rows", null, null, -1, null, -1); + } + return c.getCount(); + }) + .onError(t -> t.printStackTrace()) + .submit() + .getCompletionStage() + .thenAccept( c -> { System.out.println("updated rows: " + c); } ); + conn.catchErrors(); + conn.commitMaybeRollback(trans); + } + ForkJoinPool.commonPool().awaitQuiescence(1, TimeUnit.MINUTES); + } +} diff --git a/java/AoJ/test/com/oracle/adbaoverjdbc/test/HelloWorld.java b/java/AoJ/test/com/oracle/adbaoverjdbc/test/HelloWorld.java old mode 100644 new mode 100755 index 127a9dc1..c89a7baa --- a/java/AoJ/test/com/oracle/adbaoverjdbc/test/HelloWorld.java +++ b/java/AoJ/test/com/oracle/adbaoverjdbc/test/HelloWorld.java @@ -1,5 +1,63 @@ - - Oracle SSO Failure - -

Oracle SSO Failure - Unable to process request

Either the requested URL was not specified in terms of a fully-qualified host name or OHS single sign-on is incorrectly configured.
Please notify your administrator.
- +/* + * Copyright (c) 2018 Oracle and/or its affiliates. All rights reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.oracle.adbaoverjdbc.test; + +import java.util.concurrent.ForkJoinPool; +import java.util.concurrent.TimeUnit; +import java.util.stream.Collector; +import jdk.incubator.sql2.Connection; +import jdk.incubator.sql2.DataSourceFactory; +import jdk.incubator.sql2.DataSource; +import org.junit.Test; + +public class HelloWorld { + + public static final String URL = "jdbc:derby:memory:db;create=true"; + public static final String USER = "scott"; + public static final String PASSWORD = "tiger"; + public static final String FACTORY_NAME = "com.oracle.adbaoverjdbc.DataSourceFactory"; + + public static void main(String[] args) { + DataSourceFactory factory = DataSourceFactory.newFactory(FACTORY_NAME); + if (factory == null) { + System.err.println("Error: Could not get a DataSourceFactory!"); + } + else { + System.out.println("DataSourceFactory: " + factory); + try (DataSource ds = factory.builder() + .url(URL) + .username(USER) + .password(PASSWORD) + .build(); + Connection conn = ds.getConnection()) { + System.out.println("Connected! DataSource: " + ds + " Connection: " + conn); + conn.rowOperation("SELECT 1") + .collect(Collector.of(() -> null, + (a, r) -> { System.out.println(r.at(1).get(String.class)); }, + (l, r) -> null, + a -> {System.out.println("end"); return null; })) + .onError(ex -> { ex.printStackTrace(); }) + .submit(); + } + } + ForkJoinPool.commonPool().awaitQuiescence(1, TimeUnit.MINUTES); + } + + @Test + public void test() { + main(null); + } +} diff --git a/java/AoJ/test/com/oracle/adbaoverjdbc/test/NewEmptyJUnitTest.java b/java/AoJ/test/com/oracle/adbaoverjdbc/test/NewEmptyJUnitTest.java old mode 100644 new mode 100755 index 127a9dc1..658e2f63 --- a/java/AoJ/test/com/oracle/adbaoverjdbc/test/NewEmptyJUnitTest.java +++ b/java/AoJ/test/com/oracle/adbaoverjdbc/test/NewEmptyJUnitTest.java @@ -1,5 +1,55 @@ - - Oracle SSO Failure - -

Oracle SSO Failure - Unable to process request

Either the requested URL was not specified in terms of a fully-qualified host name or OHS single sign-on is incorrectly configured.
Please notify your administrator.
- +/* + * Copyright (c) 2018 Oracle and/or its affiliates. All rights reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.oracle.adbaoverjdbc.test; + +import org.junit.After; +import org.junit.AfterClass; +import org.junit.Before; +import org.junit.BeforeClass; +import org.junit.Test; +import static org.junit.Assert.*; + +/** + * + * @author douglas.surber + */ +public class NewEmptyJUnitTest { + + public NewEmptyJUnitTest() { + } + + @BeforeClass + public static void setUpClass() { + } + + @AfterClass + public static void tearDownClass() { + } + + @Before + public void setUp() { + } + + @After + public void tearDown() { + } + + // TODO add test methods here. + // The methods must be annotated with annotation @Test. For example: + // + // @Test + // public void hello() {} +} From 3fb7e11a4b1d486ae4bbe6e6d7ce2690e63c85ff Mon Sep 17 00:00:00 2001 From: Kuassim Date: Wed, 20 Jun 2018 18:14:39 -0700 Subject: [PATCH 09/16] Re-added AoJ src repository --- java/AoJ/src/README.md | 120 ++++++ .../com/oracle/adbaoverjdbc/Connection.java | 355 +++++++++++++++ .../adbaoverjdbc/ConnectionBuilder.java | 100 +++++ .../oracle/adbaoverjdbc/CountOperation.java | 165 +++++++ .../com/oracle/adbaoverjdbc/DataSource.java | 68 +++ .../adbaoverjdbc/DataSourceBuilder.java | 94 ++++ .../adbaoverjdbc/DataSourceFactory.java | 30 ++ .../JdbcConnectionProperties.java | 58 +++ .../com/oracle/adbaoverjdbc/Operation.java | 316 ++++++++++++++ .../oracle/adbaoverjdbc/OperationGroup.java | 295 +++++++++++++ .../adbaoverjdbc/ParameterizedOperation.java | 130 ++++++ .../com/oracle/adbaoverjdbc/RowOperation.java | 408 ++++++++++++++++++ .../oracle/adbaoverjdbc/SimpleOperation.java | 68 +++ .../com/oracle/adbaoverjdbc/SqlOperation.java | 30 ++ .../com/oracle/adbaoverjdbc/Submission.java | 51 +++ .../com/oracle/adbaoverjdbc/Transaction.java | 64 +++ .../adbaoverjdbc/UnskippableOperation.java | 54 +++ .../com/oracle/adbaoverjdbc/module-info.java | 22 + 18 files changed, 2428 insertions(+) create mode 100755 java/AoJ/src/README.md create mode 100755 java/AoJ/src/com/oracle/adbaoverjdbc/com/oracle/adbaoverjdbc/Connection.java create mode 100755 java/AoJ/src/com/oracle/adbaoverjdbc/com/oracle/adbaoverjdbc/ConnectionBuilder.java create mode 100755 java/AoJ/src/com/oracle/adbaoverjdbc/com/oracle/adbaoverjdbc/CountOperation.java create mode 100755 java/AoJ/src/com/oracle/adbaoverjdbc/com/oracle/adbaoverjdbc/DataSource.java create mode 100755 java/AoJ/src/com/oracle/adbaoverjdbc/com/oracle/adbaoverjdbc/DataSourceBuilder.java create mode 100755 java/AoJ/src/com/oracle/adbaoverjdbc/com/oracle/adbaoverjdbc/DataSourceFactory.java create mode 100755 java/AoJ/src/com/oracle/adbaoverjdbc/com/oracle/adbaoverjdbc/JdbcConnectionProperties.java create mode 100755 java/AoJ/src/com/oracle/adbaoverjdbc/com/oracle/adbaoverjdbc/Operation.java create mode 100755 java/AoJ/src/com/oracle/adbaoverjdbc/com/oracle/adbaoverjdbc/OperationGroup.java create mode 100755 java/AoJ/src/com/oracle/adbaoverjdbc/com/oracle/adbaoverjdbc/ParameterizedOperation.java create mode 100755 java/AoJ/src/com/oracle/adbaoverjdbc/com/oracle/adbaoverjdbc/RowOperation.java create mode 100755 java/AoJ/src/com/oracle/adbaoverjdbc/com/oracle/adbaoverjdbc/SimpleOperation.java create mode 100755 java/AoJ/src/com/oracle/adbaoverjdbc/com/oracle/adbaoverjdbc/SqlOperation.java create mode 100755 java/AoJ/src/com/oracle/adbaoverjdbc/com/oracle/adbaoverjdbc/Submission.java create mode 100755 java/AoJ/src/com/oracle/adbaoverjdbc/com/oracle/adbaoverjdbc/Transaction.java create mode 100755 java/AoJ/src/com/oracle/adbaoverjdbc/com/oracle/adbaoverjdbc/UnskippableOperation.java create mode 100755 java/AoJ/src/com/oracle/adbaoverjdbc/module-info.java diff --git a/java/AoJ/src/README.md b/java/AoJ/src/README.md new file mode 100755 index 00000000..155341c1 --- /dev/null +++ b/java/AoJ/src/README.md @@ -0,0 +1,120 @@ +# AoJ: ADBA over JDBC + +ADBA is Asynchronous Database Access, a non-blocking database access api that +Oracle is proposing as a Java standard. ADBA was announced at +[JavaOne 2016](https://static.rainfocus.com/oracle/oow16/sess/1461693351182001EmRq/ppt/CONF1578%2020160916.pdf) +and presented again at [JavaOne 2017](http://www.oracle.com/technetwork/database/application-development/jdbc/con1491-3961036.pdf). +The ADBA source is available for download from the [OpenJDK sandbox](http://hg.openjdk.java.net/jdk/sandbox/file/9d3b0eb749a9/src/jdk.incubator.adba) +as part of the OpenJDK project and the JavaDoc is available [here](http://cr.openjdk.java.net/~lancea/8188051/apidoc/jdk.incubator.adba-summary.html). +You can get involved in the ADBA specification effort by following the +[JDBC Expert Group mailing list](http://mail.openjdk.java.net/pipermail/jdbc-spec-discuss/). + +Reading a bunch of JavaDoc and interfaces can be interesting, but it is not nearly +as engaging as having actual running code to play with. To that end, we have +uploaded the beginnings of an implementation of ADBA running over standard JDBC, +AoJ. AoJ is available for download from [GitHub](https://github.com/oracle/oracle-db-examples/tree/master/java/AoJ) +under the Apache license. It should run with any reasonably standard compliant +JDBC driver. + +AoJ implements only a small part of ADBA, but it is enough to write interesting +code. It provides partial implementations of ```DataSourceFactory```, ```DataSource```, +```Connection```, ```OperationGroup```, ```RowOperation```, ```CountOperation```, +```Transaction``` and others. These implementations are not complete but there is +enough there to write interesting database programs. The code that is there is +untested, but it does work to some extent. The saving grace is that you can +download the source and improve it: add new features, fix bugs, try out alternate +implementations. + +Oracle is not proposing AoJ as an open source project. However, because AoJ is +released under the Apache license, the Java community can fork the code and create +a true open source project with this upload as a base. Oracle developers may +contribute when we have time, but this would have to be a Java community effort. + +We could have held this code back and worked on it longer. Instead we thought it +better to get it to the community as soon as we could. We hope that you agree. + +## Building AoJ + +AoJ and ADBA require JDK 9 or later. Download ADBA from the +[OpenJDK sandbox](http://hg.openjdk.java.net/jdk/sandbox/file/9d3b0eb749a9/src/jdk.incubator.adba). +It does not have any dependencies outside of Java SE. Download AoJ from +[GitHub](https://github.com/oracle/oracle-db-examples/tree/master/java/AoJ). Both +are modularized so be sure to include the module-info.java files. AoJ depends on +ADBA. The AoJ sample file depends on JUnit which is included with most IDEs but is +also available [here](https://github.com/junit-team/junit4). + +To run the sample file you will need a SQL database and corresponding JDBC driver. AoJ +has been run with [Oracle Database 12c](http://www.oracle.com/technetwork/database/enterprise-edition/downloads/index.html) +and [Oracle Database 12c JDBC](http://www.oracle.com/technetwork/database/application-development/jdbc/downloads/index.html), +but it should work with any reasonably standard compliant SQL database and JDBC +driver. The sample file uses the scott/tiger schema available +[here](https://github.com/oracle/dotnet-db-samples/blob/master/schemas/scott.sql). + +Start the database and load ```scott.sql```. Edit ```com.oracle.adbaoverjdbc.test.FirstLight.java``` +and set the constant ```URL``` to an appropriate value. AoJ will pass this value +to ```java.sql.DriverManager.getConnection```. If you are using a database other +than Oracle you should change the value of the constant ```TRIVIAL``` to some +very trivial ```SELECT``` query. + +## Sample Code + +The following test case should give you some idea of what AoJ can do. It should +run with any JDBC driver connecting to a database with the scott schema. This is +the last test in ```com.oracle.adbaoverjdbc.test.FirstLight.java```. For an +introduction to ADBA see the [JavaOne 2017 presentation](http://www.oracle.com/technetwork/database/application-development/jdbc/con1491-3961036.pdf). + +``` + public void transactionSample() { + // get the AoJ DataSourceFactory + DataSourceFactory factory = DataSourceFactory.forName("com.oracle.adbaoverjdbc.DataSourceFactory"); + // get a DataSource and a Connection + try (DataSource ds = factory.builder() + .url(URL) + .username(“scott") + .password(“tiger") + .build(); + Connection conn = ds.getConnection(t -> System.out.println("ERROR: " + t.getMessage()))) { + // get a Transaction + Transaction trans = conn.transaction(); + // select the EMPNO of CLARK + CompletionStage idF = conn.rowOperation("select empno, ename from emp where ename = ? for update") + .set("1", "CLARK", AdbaType.VARCHAR) + .collect(Collector.of( + () -> new int[1], + (a, r) -> {a[0] = r.get("empno", Integer.class); }, + (l, r) -> null, + a -> a[0]) + ) + .submit() + .getCompletionStage(); + // update CLARK to work in department 50 + conn.countOperation("update emp set deptno = ? where empno = ?") + .set("1", 50, AdbaType.INTEGER) + .set("2", idF, AdbaType.INTEGER) + .apply(c -> { + if (c.getCount() != 1L) { + trans.setRollbackOnly(); + throw new SqlException("updated wrong number of rows", null, null, -1, null, -1); + } + return c.getCount(); + }) + .onError(t -> t.printStackTrace()) + .submit(); + + conn.catchErrors(); // resume normal execution if there were any errors + conn.commitMaybeRollback(trans); // commit (or rollback) the transaction + } + // wait for the async tasks to complete before exiting + ForkJoinPool.commonPool().awaitQuiescence(1, TimeUnit.MINUTES); + }``` + +## AoJ Design Spec in 100 words or less + +The methods called by the user thread create a network +([DAG](https://en.wikipedia.org/wiki/Directed_acyclic_graph)) of +```CompletableFuture```s. These ```CompleteableFuture```s asynchronously execute +the synchronous JDBC calls and the result processing code provided by the user +code. By default AoJ uses ```ForkJoinPool.commonPool()``` to execute +```CompletableFuture```s but the user code can provide another ```Executor```. +When the ```Connection``` is submitted the root of the ```CompleteableFuture``` +network is completed triggering execution of the rest of the network. diff --git a/java/AoJ/src/com/oracle/adbaoverjdbc/com/oracle/adbaoverjdbc/Connection.java b/java/AoJ/src/com/oracle/adbaoverjdbc/com/oracle/adbaoverjdbc/Connection.java new file mode 100755 index 00000000..3c588d15 --- /dev/null +++ b/java/AoJ/src/com/oracle/adbaoverjdbc/com/oracle/adbaoverjdbc/Connection.java @@ -0,0 +1,355 @@ +/* + * Copyright (c) 2018 Oracle and/or its affiliates. All rights reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.oracle.adbaoverjdbc; + +import jdk.incubator.sql2.AdbaConnectionProperty; +import jdk.incubator.sql2.Connection.Lifecycle; +import jdk.incubator.sql2.ConnectionProperty; +import jdk.incubator.sql2.Operation; +import jdk.incubator.sql2.ShardingKey; +import jdk.incubator.sql2.SqlException; +import jdk.incubator.sql2.TransactionOutcome; +import java.sql.DriverManager; +import java.sql.PreparedStatement; +import java.sql.SQLException; +import java.util.HashMap; +import java.util.HashSet; +import java.util.Map; +import java.util.Properties; +import java.util.Set; +import java.util.concurrent.CompletableFuture; +import java.util.concurrent.CompletionStage; +import java.util.concurrent.Executor; +import java.util.function.Consumer; +import java.util.logging.Level; +import jdk.incubator.sql2.ParameterizedRowPublisherOperation; + +/** + * Connection is a subclass of OperationGroup. The member Operation stuff is mostly + * inherited from OperationGroup. There are a couple of differences. First the + * predecessor for all Connections is an already completed CompletableFuture, + * ROOT. Since ROOT is completed a Connection will begin executing as soon as it + * is submitted. Second, a Connection is not really a member of an OperationGroup + * so the code that handles submitting the Connection is a little different from + * OperationGroup. + * + * A Connection is also contains a java.sql.Connection and has methods to execute + * some JDBC actions. It might be a good idea to move the java.sql.Connection and + * associated actions to a separate class. + */ +class Connection extends OperationGroup implements jdk.incubator.sql2.Connection { + + // STATIC + protected static final CompletionStage ROOT = CompletableFuture.completedFuture(null); + + static jdk.incubator.sql2.Connection newConnection(DataSource ds, + Map properties) { + return new Connection(ds, properties); + } + + // FIELDS + private Lifecycle connectionLifecycle = Lifecycle.NEW; + private final Set lifecycleListeners; + private final DataSource dataSource; + private final Map properties; + + private java.sql.Connection jdbcConnection; + + private final Executor executor; + private CompletableFuture connectionCF; + + // CONSTRUCTORS + private Connection(DataSource ds, + Map properties) { + super(null, null); // hack as _this_ not allowed. See SimpleOperation constructor + this.lifecycleListeners = new HashSet<>(); + dataSource = ds; + this.properties = properties; + ConnectionProperty execProp = AdbaConnectionProperty.EXECUTOR; + executor = (Executor) properties.getOrDefault(execProp, execProp.defaultValue()); + } + + // PUBLIC + @Override + public Operation connectOperation() { + if (! isHeld()) { + throw new IllegalStateException("TODO"); + } + return com.oracle.adbaoverjdbc.SimpleOperation.newOperation(this, this, this::jdbcConnect); + } + + @Override + public Operation validationOperation(Validation depth) { + if (! isHeld()) { + throw new IllegalStateException("TODO"); + } + return com.oracle.adbaoverjdbc.SimpleOperation.newOperation(this, this, op -> jdbcValidate(op, depth)); + } + + @Override + public Operation closeOperation() { + if (! isHeld()) { + throw new IllegalStateException("TODO"); + } + return com.oracle.adbaoverjdbc.UnskippableOperation.newOperation(this, this, this::jdbcClose); //TODO cannot be skipped + } + + @Override + public jdk.incubator.sql2.OperationGroup operationGroup() { + if (!isHeld()) { + throw new IllegalStateException("TODO"); + } + throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. + } + + @Override + public Transaction transaction() { + if (! isHeld()) { + throw new IllegalStateException("TODO"); + } + return Transaction.createTransaction(this); + } + + @Override + public Connection registerLifecycleListener(ConnectionLifecycleListener listener) { + if (!connectionLifecycle.isActive()) { + throw new IllegalStateException("TODO"); + } + lifecycleListeners.add(listener); + return this; + } + + @Override + public Connection deregisterLifecycleListener(ConnectionLifecycleListener listener) { + if (!connectionLifecycle.isActive()) { + throw new IllegalStateException("TODO"); + } + lifecycleListeners.remove(listener); + return this; + } + + @Override + public Lifecycle getConnectionLifecycle() { + return connectionLifecycle; + } + + @Override + public jdk.incubator.sql2.Connection abort() { + setLifecycle(connectionLifecycle.abort()); + this.closeImmediate(); + return this; + } + + @Override + public Map getProperties() { + Map map = new HashMap<>(properties.size()); + properties.forEach((k, v) -> { + if (!k.isSensitive()) { + map.put(k, v); + } + }); + return map; + } + + @Override + public ShardingKey.Builder shardingKeyBuilder() { + throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. + } + + @Override + public jdk.incubator.sql2.Connection requestHook(Consumer request) { + throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. + } + + @Override + public jdk.incubator.sql2.Connection activate() { + setLifecycle(connectionLifecycle.activate()); + throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. + } + + @Override + public jdk.incubator.sql2.Connection deactivate() { + setLifecycle(connectionLifecycle.deactivate()); + throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. + } + + + + + // INTERNAL + protected Connection setLifecycle(Lifecycle next) { + Lifecycle previous = connectionLifecycle; + connectionLifecycle = next; + if (previous != next) { + lifecycleListeners.stream().forEach(l -> l.lifecycleEvent(this, previous, next)); + } + return this; + } + + Connection closeImmediate() { + try { + if (jdbcConnection != null && !jdbcConnection.isClosed()) { + setLifecycle(connectionLifecycle.abort()); + jdbcConnection.abort(executor); // Connection.abort is not supposed to hang + //TODO should call connectionLifecycle.close() when abort completes. + } + } + catch (SQLException ex) { + throw new SqlException(ex.getMessage(), ex, ex.getSQLState(), ex.getErrorCode(), null, -1); + } + finally { + dataSource.deregisterConnection(this); + } + return this; + } + + @Override + protected Executor getExecutor() { + return executor; + } + + @Override + jdk.incubator.sql2.Submission submit(com.oracle.adbaoverjdbc.Operation op) { + if (op == this) { + // submitting the Connection OperationGroup + connectionCF = (CompletableFuture)attachErrorHandler(op.follows(ROOT, getExecutor())); + return com.oracle.adbaoverjdbc.Submission.submit(this::cancel, connectionCF); + } + else { + return super.submit(op); + } + } + + protected V connectionPropertyValue(ConnectionProperty prop) { + V value = (V)properties.get(prop); + if (value == null) return (V)prop.defaultValue(); + else return value; + } + + + + + // JDBC operations. These are all blocking + + private Void jdbcConnect(com.oracle.adbaoverjdbc.Operation op) { + try { + Properties info = (Properties)properties.get(JdbcConnectionProperties.JDBC_CONNECTION_PROPERTIES); + info = (Properties)(info == null ? JdbcConnectionProperties.JDBC_CONNECTION_PROPERTIES.defaultValue() + : info.clone()); + info.setProperty("user", (String) properties.get(AdbaConnectionProperty.USER)); + info.setProperty("password", (String) properties.get(AdbaConnectionProperty.PASSWORD)); + String url = (String) properties.get(AdbaConnectionProperty.URL); + Properties p = info; + group.logger.log(Level.FINE, () -> "DriverManager.getConnection(\"" + url + "\", " + p +")"); + jdbcConnection = DriverManager.getConnection(url, info); + jdbcConnection.setAutoCommit(false); + setLifecycle(Connection.Lifecycle.OPEN); + return null; + } + catch (SQLException ex) { + throw new SqlException(ex.getMessage(), ex, ex.getSQLState(), ex.getErrorCode(), null, -1); + } + } + + private Void jdbcValidate(com.oracle.adbaoverjdbc.Operation op, + Validation depth) { + try { + switch (depth) { + case COMPLETE: + case SERVER: + int timeoutSeconds = (int) (op.getTimeoutMillis() / 1000L); + group.logger.log(Level.FINE, () -> "Connection.isValid(" + timeoutSeconds + ")"); //DEBUG + if (!jdbcConnection.isValid(timeoutSeconds)) { + throw new SqlException("validation failure", null, null, -1, null, -1); + } + break; + case NETWORK: + case SOCKET: + case LOCAL: + case NONE: + group.logger.log(Level.FINE, () -> "Connection.isClosed"); //DEBUG + if (jdbcConnection.isClosed()) { + throw new SqlException("validation failure", null, null, -1, null, -1); + } + } + return null; + } + catch (SQLException ex) { + throw new SqlException(ex.getMessage(), ex, ex.getSQLState(), ex.getErrorCode(), null, -1); + } + } + + + protected T jdbcExecute(com.oracle.adbaoverjdbc.Operation op, String sql) { + try (java.sql.Statement stmt = jdbcConnection.createStatement()) { + int timeoutSeconds = (int) (op.getTimeoutMillis() / 1000L); + if (timeoutSeconds < 0) stmt.setQueryTimeout(timeoutSeconds); + group.logger.log(Level.FINE, () -> "Statement.execute(\"" + sql + "\")"); //DEBUG + stmt.execute(sql); + } + catch (SQLException ex) { + throw new SqlException(ex.getMessage(), ex, ex.getSQLState(), ex.getErrorCode(), sql, -1); + } + return null; + } + + private Void jdbcClose(com.oracle.adbaoverjdbc.Operation op) { + try { + setLifecycle(connectionLifecycle.close()); + if (jdbcConnection != null) { + group.logger.log(Level.FINE, () -> "Connection.close"); //DEBUG + jdbcConnection.close(); + } + } + catch (SQLException ex) { + throw new SqlException(ex.getMessage(), ex, ex.getSQLState(), ex.getErrorCode(), null, -1); + } + finally { + closeImmediate(); + setLifecycle(connectionLifecycle.closed()); + } + return null; + } + + PreparedStatement prepareStatement(String sqlString) throws SQLException { + logger.log(Level.FINE, () -> "Connection.prepareStatement(\"" + sqlString + "\")"); //DEBUG + return jdbcConnection.prepareStatement(sqlString); + } + + TransactionOutcome jdbcEndTransaction(SimpleOperation op, Transaction trans) { + try { + if (trans.endWithCommit(this)) { + group.logger.log(Level.FINE, () -> "commit"); //DEBUG + jdbcConnection.commit(); + return TransactionOutcome.COMMIT; + } + else { + group.logger.log(Level.FINE, () -> "rollback"); //DEBUG + jdbcConnection.rollback(); + return TransactionOutcome.ROLLBACK; + } + } + catch (SQLException ex) { + throw new SqlException(ex.getMessage(), ex, ex.getSQLState(), ex.getErrorCode(), null, -1); + } + } + + @Override + public ParameterizedRowPublisherOperation rowPublisherOperation(String sql) { + throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. + } + +} diff --git a/java/AoJ/src/com/oracle/adbaoverjdbc/com/oracle/adbaoverjdbc/ConnectionBuilder.java b/java/AoJ/src/com/oracle/adbaoverjdbc/com/oracle/adbaoverjdbc/ConnectionBuilder.java new file mode 100755 index 00000000..639fe58c --- /dev/null +++ b/java/AoJ/src/com/oracle/adbaoverjdbc/com/oracle/adbaoverjdbc/ConnectionBuilder.java @@ -0,0 +1,100 @@ +/* + * Copyright (c) 2018 Oracle and/or its affiliates. All rights reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.oracle.adbaoverjdbc; + +import jdk.incubator.sql2.ConnectionProperty; +import java.util.HashMap; +import java.util.Map; + +/** + * A builder to create an AoJ connection. The AoJ connection creates a JDBC + * connection by calling java.sql.DriverManager.getConnection with the following + * user provided ConnectionProperty values: + * + *
+ *
URL
+ *
passed as the url argument to getConnection
+ *
USER
+ *
added to the JDBC_CONNECTION_PROPERTIES as the "user" property.
+ *
PASSWORD
+ *
added to the JDBC_CONNECTION_PROPERTIES as the "password" property
+ *
JDBC_CONNECTION_PROPERTIES
+ *
a java.util.Properties passed as the info argument to getConnection
+ *
+ */ +class ConnectionBuilder implements jdk.incubator.sql2.Connection.Builder { + + /** + * + * @param ds + * @param defaultProperties. Captured + * @param requiredProperties. Captured + * @return + */ + static ConnectionBuilder newConnectionBuilder(DataSource ds, + Map defaultProperties, + Map requiredProperties) { + return new ConnectionBuilder(ds, defaultProperties, requiredProperties); + } + + private boolean isBuilt = false; + private final DataSource dataSource; + private final Map defaultProperties; + private final Map requiredProperties; + + /** + * + * @param ds + * @param defaultConnectionProperties + * @param specifiedConnectionProperties + */ + private ConnectionBuilder(DataSource ds, + Map defaultConnectionProperties, + Map specifiedConnectionProperties) { + super(); + dataSource = ds; + defaultProperties = new HashMap(defaultConnectionProperties); + requiredProperties = new HashMap(specifiedConnectionProperties); + } + + @Override + public jdk.incubator.sql2.Connection.Builder property(ConnectionProperty property, Object value) { + if (isBuilt) { + throw new IllegalStateException("TODO"); + } + if (requiredProperties.containsKey(property)) { + throw new IllegalArgumentException("cannot override required properties"); + } + if (!property.validate(value)) { + throw new IllegalArgumentException("TODO"); + } + requiredProperties.put(property, value); + return this; + } + + @Override + public jdk.incubator.sql2.Connection build() { + if (isBuilt) { + throw new IllegalStateException("TODO"); + } + isBuilt = true; + // replace default values with specified values where provided + // otherwise use defaults + defaultProperties.putAll(requiredProperties); + return Connection.newConnection(dataSource, defaultProperties); + } + +} diff --git a/java/AoJ/src/com/oracle/adbaoverjdbc/com/oracle/adbaoverjdbc/CountOperation.java b/java/AoJ/src/com/oracle/adbaoverjdbc/com/oracle/adbaoverjdbc/CountOperation.java new file mode 100755 index 00000000..8bb75581 --- /dev/null +++ b/java/AoJ/src/com/oracle/adbaoverjdbc/com/oracle/adbaoverjdbc/CountOperation.java @@ -0,0 +1,165 @@ +/* + * Copyright (c) 2018 Oracle and/or its affiliates. All rights reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.oracle.adbaoverjdbc; + +import jdk.incubator.sql2.RowOperation; +import jdk.incubator.sql2.SqlException; +import jdk.incubator.sql2.SqlType; +import java.sql.PreparedStatement; +import java.sql.SQLException; +import java.time.Duration; +import java.util.concurrent.CompletionStage; +import java.util.concurrent.Executor; +import java.util.function.Consumer; +import java.util.function.Function; +import java.util.logging.Level; +import jdk.incubator.sql2.ParameterizedRowCountOperation; +import jdk.incubator.sql2.Result; + +/** + * + * @param + */ +class CountOperation extends ParameterizedOperation + implements ParameterizedRowCountOperation { + + static private final Function DEFAULT_PROCESSOR = c -> null; + + /** + * Factory method to create CountOperations. + * + * @param the type of the value of the CountOperation + * @param conn the Connection the CountOperation belongs to + * @param grp the GroupOperation the CountOperation is a member of + * @param sql the SQL string to execute. Must return a count. + * @return a new CountOperation that will execute sql. + */ + static CountOperation newCountOperation(Connection conn, OperationGroup grp, String sql) { + return new CountOperation<>(conn, grp, sql); + } + + // attributes + private final String sqlString; + private Function countProcessor; + + PreparedStatement jdbcStatement; + + CountOperation(Connection conn, OperationGroup operationGroup, String sql) { + super(conn, operationGroup); + countProcessor = DEFAULT_PROCESSOR; + sqlString = sql; + } + + @Override + public RowOperation returning(String... keys) { + throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. + } + + @Override + public CountOperation apply(Function processor) { + if (isImmutable() || countProcessor != DEFAULT_PROCESSOR) throw new IllegalStateException("TODO"); + if (processor == null) throw new IllegalArgumentException("TODO"); + countProcessor = processor; + return this; + } + + @Override + CompletionStage follows(CompletionStage predecessor, Executor executor) { + predecessor = attachFutureParameters(predecessor); + return predecessor + .thenApplyAsync(this::executeQuery, executor); + } + + /** + * Execute the SQL query, process the returned count, and return the result of + * processing the returned count. + * + * @param ignore not used + * @return the result of processing the count + */ + private T executeQuery(Object ignore) { + checkCanceled(); + try { + jdbcStatement = connection.prepareStatement(sqlString); + setParameters.forEach((String k, ParameterValue v) -> { + v.set(jdbcStatement, k); + }); + group.logger.log(Level.FINE, () -> "executeUpdate(\"" + sqlString + "\")"); + long c = jdbcStatement.executeLargeUpdate(); + return countProcessor.apply(new RowCount(c)); + } + catch (SQLException ex) { + throw new SqlException(ex.getMessage(), ex, ex.getSQLState(), ex.getErrorCode(), sqlString, -1); + } + } + + // Covariant overrides + + @Override + public CountOperation set(String id, Object value) { + return (CountOperation)super.set(id, value); + } + + @Override + public CountOperation set(String id, Object value, SqlType type) { + return (CountOperation)super.set(id, value, type); + } + + @Override + public CountOperation set(String id, CompletionStage source) { + return (CountOperation)super.set(id, source); + } + + @Override + public CountOperation set(String id, CompletionStage source, SqlType type) { + return (CountOperation)super.set(id, source, type); + } + + @Override + public CountOperation timeout(Duration minTime) { + return (CountOperation)super.timeout(minTime); + } + + @Override + public CountOperation onError(Consumer handler) { + return (CountOperation)super.onError(handler); + } + + /** + * Represents the result of a SQL execution that is an update count. + * + * ISSUE: It's not obvious this type is more valuable than just using + * java.lang.Long. Result.Count exists to clearly express that the input arg + * to the processor Function is a count. Could rely on documentation but this + * seems like it might be important enough to capture in the type system. There + * also may be non-numeric return values that Result.Count could express, eg + * success but number unknown. + */ + static class RowCount implements Result.RowCount { + + private long count = -1; + + private RowCount(long c) { + count = c; + } + + @Override + public long getCount() { + return count; + } + + } +} diff --git a/java/AoJ/src/com/oracle/adbaoverjdbc/com/oracle/adbaoverjdbc/DataSource.java b/java/AoJ/src/com/oracle/adbaoverjdbc/com/oracle/adbaoverjdbc/DataSource.java new file mode 100755 index 00000000..0543d9ae --- /dev/null +++ b/java/AoJ/src/com/oracle/adbaoverjdbc/com/oracle/adbaoverjdbc/DataSource.java @@ -0,0 +1,68 @@ +/* + * Copyright (c) 2018 Oracle and/or its affiliates. All rights reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.oracle.adbaoverjdbc; + +import jdk.incubator.sql2.ConnectionProperty; +import java.util.HashSet; +import java.util.Map; +import java.util.Set; + +/** + * Bare bones DataSource. No support for Connection caching. + * + */ +class DataSource implements jdk.incubator.sql2.DataSource { + + static DataSource newDataSource(Map defaultConnectionProperties, + Map requiredConnectionProperties) { + return new DataSource(defaultConnectionProperties, requiredConnectionProperties); + } + + protected final Map defaultConnectionProperties; + protected final Map requiredConnectionProperties; + + protected final Set openConnections = new HashSet<>(); + + protected DataSource(Map defaultProps, + Map requiredProps) { + super(); + defaultConnectionProperties = defaultProps; + requiredConnectionProperties = requiredProps; + } + + @Override + public Connection.Builder builder() { + return ConnectionBuilder.newConnectionBuilder(this, defaultConnectionProperties, requiredConnectionProperties); + } + + @Override + public void close() { + openConnections.stream().forEach( c -> c.close() ); + } + + + + DataSource registerConnection(Connection c) { + openConnections.add(c); + return this; + } + + DataSource deregisterConnection(Connection c) { + openConnections.remove(c); + return this; + } + +} diff --git a/java/AoJ/src/com/oracle/adbaoverjdbc/com/oracle/adbaoverjdbc/DataSourceBuilder.java b/java/AoJ/src/com/oracle/adbaoverjdbc/com/oracle/adbaoverjdbc/DataSourceBuilder.java new file mode 100755 index 00000000..d72f9eb9 --- /dev/null +++ b/java/AoJ/src/com/oracle/adbaoverjdbc/com/oracle/adbaoverjdbc/DataSourceBuilder.java @@ -0,0 +1,94 @@ +/* + * Copyright (c) 2018 Oracle and/or its affiliates. All rights reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.oracle.adbaoverjdbc; + +import jdk.incubator.sql2.ConnectionProperty; +import java.util.HashMap; +import java.util.Map; +import java.util.function.Consumer; + +/** + * + */ +class DataSourceBuilder implements jdk.incubator.sql2.DataSource.Builder { + + static DataSourceBuilder newDataSourceBuilder() { + return new DataSourceBuilder(); + } + + protected boolean isBuilt = false; + + /** + * defaultConnectionProperties can be overridden by a ConnectionBuilder + */ + Map defaultConnectionProperties = new HashMap<>(); + + /** + * it is an error if a ConnectionBuilder tries to override requiredConnectionProperties + */ + Map requiredConnectionProperties = new HashMap<>(); + + @Override + public jdk.incubator.sql2.DataSource.Builder defaultConnectionProperty(ConnectionProperty property, Object value) { + if (isBuilt) { + throw new IllegalStateException("TODO"); + } + if (defaultConnectionProperties.containsKey(property)) { + throw new IllegalArgumentException("cannot set a default multiple times"); + } + if (requiredConnectionProperties.containsKey(property)) { + throw new IllegalArgumentException("cannot set a default that is already required"); + } + if (!property.validate(value)) { + throw new IllegalArgumentException("TODO"); + } + defaultConnectionProperties.put(property, value); + return this; + } + + @Override + public jdk.incubator.sql2.DataSource.Builder connectionProperty(ConnectionProperty property, Object value) { + if (isBuilt) { + throw new IllegalStateException("TODO"); + } + if (defaultConnectionProperties.containsKey(property)) { + throw new IllegalArgumentException("cannot set a required prop that has a default"); + } + if (requiredConnectionProperties.containsKey(property)) { + throw new IllegalArgumentException("cannot set a required prop multiple times"); + } + if (!property.validate(value)) { + throw new IllegalArgumentException("TODO"); + } + requiredConnectionProperties.put(property, value); + return this; + } + + @Override + public jdk.incubator.sql2.DataSource.Builder requestHook(Consumer request) { + throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. + } + + @Override + public jdk.incubator.sql2.DataSource build() { + if (isBuilt) { + throw new IllegalStateException("cannot build more than once. All objects are use-once"); + } + isBuilt = true; + return DataSource.newDataSource(defaultConnectionProperties, requiredConnectionProperties); + } + +} diff --git a/java/AoJ/src/com/oracle/adbaoverjdbc/com/oracle/adbaoverjdbc/DataSourceFactory.java b/java/AoJ/src/com/oracle/adbaoverjdbc/com/oracle/adbaoverjdbc/DataSourceFactory.java new file mode 100755 index 00000000..044a9b1b --- /dev/null +++ b/java/AoJ/src/com/oracle/adbaoverjdbc/com/oracle/adbaoverjdbc/DataSourceFactory.java @@ -0,0 +1,30 @@ +/* + * Copyright (c) 2018 Oracle and/or its affiliates. All rights reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.oracle.adbaoverjdbc; + +import jdk.incubator.sql2.DataSource; + +/** + * + */ +public class DataSourceFactory implements jdk.incubator.sql2.DataSourceFactory { + + @Override + public DataSource.Builder builder() { + return DataSourceBuilder.newDataSourceBuilder(); + } + +} diff --git a/java/AoJ/src/com/oracle/adbaoverjdbc/com/oracle/adbaoverjdbc/JdbcConnectionProperties.java b/java/AoJ/src/com/oracle/adbaoverjdbc/com/oracle/adbaoverjdbc/JdbcConnectionProperties.java new file mode 100755 index 00000000..d285e279 --- /dev/null +++ b/java/AoJ/src/com/oracle/adbaoverjdbc/com/oracle/adbaoverjdbc/JdbcConnectionProperties.java @@ -0,0 +1,58 @@ +/* + * Copyright (c) 2018 Oracle and/or its affiliates. All rights reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.oracle.adbaoverjdbc; + +import java.util.Properties; + +/** + * An ADBA ConnectionProperty that specifies a set of JDBC connection properties. + * Its value is a java.util.Properties. This value is passed as the info argument + * when creating a java.sql.Connection. + * + */ +public class JdbcConnectionProperties implements jdk.incubator.sql2.ConnectionProperty { + + public static final JdbcConnectionProperties JDBC_CONNECTION_PROPERTIES + = new JdbcConnectionProperties(); + + private JdbcConnectionProperties() { + } + + @Override + public String name() { + return "JDBC_CONNECTION_PROPERTIES"; + } + + @Override + public Class range() { + return Properties.class; + } + + @Override + public Object defaultValue() { + return new Properties(); + } + + @Override + public boolean isSensitive() { + return false; + } + + @Override + public String toString() { + return name(); + } +} diff --git a/java/AoJ/src/com/oracle/adbaoverjdbc/com/oracle/adbaoverjdbc/Operation.java b/java/AoJ/src/com/oracle/adbaoverjdbc/com/oracle/adbaoverjdbc/Operation.java new file mode 100755 index 00000000..6d7d982d --- /dev/null +++ b/java/AoJ/src/com/oracle/adbaoverjdbc/com/oracle/adbaoverjdbc/Operation.java @@ -0,0 +1,316 @@ +/* + * Copyright (c) 2018 Oracle and/or its affiliates. All rights reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.oracle.adbaoverjdbc; + +import jdk.incubator.sql2.AdbaType; +import jdk.incubator.sql2.SqlSkippedException; +import jdk.incubator.sql2.SqlType; +import jdk.incubator.sql2.Submission; +import java.math.BigInteger; +import java.sql.JDBCType; +import java.sql.SQLType; +import java.time.Duration; +import java.time.LocalDate; +import java.time.LocalDateTime; +import java.time.LocalTime; +import java.time.OffsetDateTime; +import java.time.OffsetTime; +import java.time.temporal.ChronoUnit; +import java.util.HashMap; +import java.util.Map; +import java.util.concurrent.CompletionException; +import java.util.concurrent.CompletionStage; +import java.util.concurrent.Executor; +import java.util.function.Consumer; + +/** + * An Operation collects the various properties of the request for work, then + * constructs one or more CompletionStages that will do the work of the + * Operation. Finally it connects the CompletionStage(s) to result + * CompletionStage of the preceeding Operation. + * + */ +abstract class Operation implements jdk.incubator.sql2.Operation { + + private static final Map CLASS_TO_JDBCTYPE = new HashMap<>(20); + static { + try { + CLASS_TO_JDBCTYPE.put(BigInteger.class, JDBCType.BIGINT); + CLASS_TO_JDBCTYPE.put(Boolean.class, JDBCType.BOOLEAN); + CLASS_TO_JDBCTYPE.put(Byte.class, JDBCType.TINYINT); + CLASS_TO_JDBCTYPE.put(Class.forName("[B"), JDBCType.VARBINARY); + CLASS_TO_JDBCTYPE.put(Character.class, JDBCType.CHAR); + CLASS_TO_JDBCTYPE.put(Double.class, JDBCType.DOUBLE); + CLASS_TO_JDBCTYPE.put(Float.class, JDBCType.FLOAT); + CLASS_TO_JDBCTYPE.put(Integer.class, JDBCType.INTEGER); + CLASS_TO_JDBCTYPE.put(LocalDate.class, JDBCType.DATE); + CLASS_TO_JDBCTYPE.put(LocalDateTime.class, JDBCType.TIMESTAMP); + CLASS_TO_JDBCTYPE.put(LocalTime.class, JDBCType.TIME); + CLASS_TO_JDBCTYPE.put(OffsetDateTime.class, JDBCType.TIMESTAMP_WITH_TIMEZONE); + CLASS_TO_JDBCTYPE.put(OffsetTime.class, JDBCType.TIME_WITH_TIMEZONE); + CLASS_TO_JDBCTYPE.put(Short.class, JDBCType.SMALLINT); + CLASS_TO_JDBCTYPE.put(String.class, JDBCType.VARCHAR); + } + catch (ClassNotFoundException ex) { /* should never happen */ } + } + + private static final Map ADBATYPE_TO_JDBCTYPE = new HashMap<>(40); + static { + ADBATYPE_TO_JDBCTYPE.put(AdbaType.ARRAY, JDBCType.ARRAY); + ADBATYPE_TO_JDBCTYPE.put(AdbaType.BIGINT, JDBCType.BIGINT); + ADBATYPE_TO_JDBCTYPE.put(AdbaType.BINARY, JDBCType.BINARY); + ADBATYPE_TO_JDBCTYPE.put(AdbaType.BIT, JDBCType.BIT); + ADBATYPE_TO_JDBCTYPE.put(AdbaType.BOOLEAN, JDBCType.BOOLEAN); + ADBATYPE_TO_JDBCTYPE.put(AdbaType.CHAR, JDBCType.CHAR); + ADBATYPE_TO_JDBCTYPE.put(AdbaType.CLOB, JDBCType.CLOB); + ADBATYPE_TO_JDBCTYPE.put(AdbaType.DATALINK, JDBCType.DATALINK); + ADBATYPE_TO_JDBCTYPE.put(AdbaType.DATE, JDBCType.DATE); + ADBATYPE_TO_JDBCTYPE.put(AdbaType.DECIMAL, JDBCType.DECIMAL); + ADBATYPE_TO_JDBCTYPE.put(AdbaType.DISTINCT, JDBCType.DISTINCT); + ADBATYPE_TO_JDBCTYPE.put(AdbaType.DOUBLE, JDBCType.DOUBLE); + ADBATYPE_TO_JDBCTYPE.put(AdbaType.FLOAT, JDBCType.FLOAT); + ADBATYPE_TO_JDBCTYPE.put(AdbaType.INTEGER, JDBCType.INTEGER); + ADBATYPE_TO_JDBCTYPE.put(AdbaType.JAVA_OBJECT, JDBCType.JAVA_OBJECT); + ADBATYPE_TO_JDBCTYPE.put(AdbaType.LONG_NVARCHAR, JDBCType.LONGNVARCHAR); + ADBATYPE_TO_JDBCTYPE.put(AdbaType.LONG_VARBINARY, JDBCType.LONGVARBINARY); + ADBATYPE_TO_JDBCTYPE.put(AdbaType.LONG_VARCHAR, JDBCType.LONGVARBINARY); + ADBATYPE_TO_JDBCTYPE.put(AdbaType.NCHAR, JDBCType.NCHAR); + ADBATYPE_TO_JDBCTYPE.put(AdbaType.NCLOB, JDBCType.NCLOB); + ADBATYPE_TO_JDBCTYPE.put(AdbaType.NULL, JDBCType.NULL); + ADBATYPE_TO_JDBCTYPE.put(AdbaType.NUMERIC, JDBCType.NUMERIC); + ADBATYPE_TO_JDBCTYPE.put(AdbaType.NVARCHAR, JDBCType.NVARCHAR); + ADBATYPE_TO_JDBCTYPE.put(AdbaType.OTHER, JDBCType.OTHER); + ADBATYPE_TO_JDBCTYPE.put(AdbaType.REAL, JDBCType.REAL); + ADBATYPE_TO_JDBCTYPE.put(AdbaType.REF, JDBCType.REF); + ADBATYPE_TO_JDBCTYPE.put(AdbaType.REF_CURSOR, JDBCType.REF_CURSOR); + ADBATYPE_TO_JDBCTYPE.put(AdbaType.ROWID, JDBCType.ROWID); + ADBATYPE_TO_JDBCTYPE.put(AdbaType.SMALLINT, JDBCType.SMALLINT); + ADBATYPE_TO_JDBCTYPE.put(AdbaType.SQLXML, JDBCType.SQLXML); + ADBATYPE_TO_JDBCTYPE.put(AdbaType.STRUCT, JDBCType.STRUCT); + ADBATYPE_TO_JDBCTYPE.put(AdbaType.TIME, JDBCType.TIME); + ADBATYPE_TO_JDBCTYPE.put(AdbaType.TIMESTAMP, JDBCType.TIMESTAMP); + ADBATYPE_TO_JDBCTYPE.put(AdbaType.TIME_WITH_TIME_ZONE, JDBCType.TIME_WITH_TIMEZONE); + ADBATYPE_TO_JDBCTYPE.put(AdbaType.TIMESTAMP_WITH_TIME_ZONE, JDBCType.TIMESTAMP_WITH_TIMEZONE); + ADBATYPE_TO_JDBCTYPE.put(AdbaType.TINYINT, JDBCType.TINYINT); + ADBATYPE_TO_JDBCTYPE.put(AdbaType.VARBINARY, JDBCType.VARBINARY); + ADBATYPE_TO_JDBCTYPE.put(AdbaType.VARCHAR, JDBCType.VARCHAR); + } + + /** + * Find the default SQLType to represent a Java type. + * + * @param c a Java type + * @return the default SQLType to represent the Java type + */ + static SQLType toSQLType(Class c) { + SQLType s = CLASS_TO_JDBCTYPE.get(c); + if (s == null) { + throw new UnsupportedOperationException("Not supported yet."); + } + return s; + } + + /** + * Return the java.sql.SQLType corresponding to the jdk.incubator.sql2.SqlType. + * + * @param t an ADBA type + * @return a JDBC type + */ + static SQLType toSQLType(SqlType t) { + SQLType s = ADBATYPE_TO_JDBCTYPE.get(t); + if (s == null) { + throw new UnsupportedOperationException("Not supported yet."); + } + return s; + } + + static Throwable unwrapException(Throwable ex) { + return ex instanceof CompletionException ? ex.getCause() : ex; + } + + // attributes + protected Duration timeout = null; + protected Consumer errorHandler = null; + + // internal state + protected final Connection connection; + protected final OperationGroup group; + protected OperationLifecycle operationLifecycle = OperationLifecycle.MUTABLE; + + Operation(Connection conn, OperationGroup operationGroup) { + // passing null for connection and operationGroup is a hack. It is not + // possible to pass _this_ to a super constructor so we define null to mean + // _this_. Yuck. Only used by Connection. + connection = conn == null ? (Connection) this : conn; + group = operationGroup == null ? (OperationGroup) this : operationGroup; + } + + @Override + public Operation onError(Consumer handler) { + if (isImmutable() || errorHandler != null) { + throw new IllegalStateException("TODO"); + } + if (handler == null) { + throw new IllegalArgumentException("TODO"); + } + errorHandler = handler; + return this; + } + + @Override + public Operation timeout(Duration minTime) { + if (isImmutable() || timeout != null) { + throw new IllegalStateException("TODO"); + } + if (minTime == null || minTime.isNegative() || minTime.isZero()) { + throw new IllegalArgumentException("TODO"); + } + timeout = minTime; + return this; + } + + @Override + public Submission submit() { + if (isImmutable()) { + throw new IllegalStateException("TODO"); + } + immutable(); + return group.submit(this); + } + + /** + * Returns true if this Operation is immutable. An Operation is immutable if + * it has been submitted. Held OperationGroups are an exception. + * + * @return return true if immutable + */ + boolean isImmutable() { + return operationLifecycle.isImmutable(); + } + + protected Operation immutable() { + operationLifecycle = OperationLifecycle.RELEASED; + return this; + } + + long getTimeoutMillis() { + if (timeout == null) { + return 0L; + } + else { + return timeout.get(ChronoUnit.MILLIS); + } + } + + protected Executor getExecutor() { + return connection.getExecutor(); + } + + /** + * Attaches the CompletableFuture that starts this Operation to the tail and + * return a CompletableFuture that represents completion of this Operation. + * The returned CompletableFuture may not be directly attached to the tail, + * but completion of the tail should result in completion of the returned + * CompletableFuture. (Note: Not quite true for OperationGroups submitted by + * calling submitHoldingForMoreMembers. While the returned CompletableFuture + * does depend on the tail, it also depends on user code calling + * releaseProhibitingMoreMembers.) + * + * @param tail the predecessor of this operation. Completion of tail starts + * execution of this Operation + * @param executor used for asynchronous execution + * @return completion of this CompletableFuture means this Operation is + * complete. The value of the Operation is the value of the CompletableFuture. + */ + abstract CompletionStage follows(CompletionStage tail, Executor executor); + + boolean cancel() { + if (operationLifecycle.isFinished()) { + return false; + } + else { + operationLifecycle = OperationLifecycle.CANCELED; + return true; + } + } + + boolean isCanceled() { + return operationLifecycle.isCanceled(); + } + + Operation checkCanceled() { + if (isCanceled()) { + throw new SqlSkippedException("TODO", null, null, -1, null, -1); + } + return this; + } + + /** + * If an errorHandler is specified, attach a CompletableFuture to the argument + * that will call the errorHandler in event the argument completes + * exceptionally and return that CompletableFuture. If there is no errorHandle + * specified, return the argument. + * + * @param result A CompletionStage that may complete exceptionally + * @return a CompletableFuture that will call the errorHandle if any. + */ + protected CompletionStage attachErrorHandler(CompletionStage result) { + if (errorHandler != null) { + return result.exceptionally(t -> { + Throwable ex = unwrapException(t); + errorHandler.accept(ex); + if (ex instanceof SqlSkippedException) throw (SqlSkippedException)ex; + else throw new SqlSkippedException("TODO", ex, null, -1, null, -1); + }); + } + else { + return result; + } + } + + static enum OperationLifecycle { + MUTABLE, + HELD, + RELEASED, + COMPLETED, + CANCELED; + + /** + * @return true iff op has been submitted which means no more configuration + */ + boolean isSubmitted() { + return this != MUTABLE; + } + + /** + * @return return true if no new members may be added. Implies isSubmitted + */ + boolean isImmutable() { //TODO better name? + return this == RELEASED || this == COMPLETED || this == CANCELED; + } + + boolean isFinished() { + return this == COMPLETED || this == CANCELED; + } + + boolean isCanceled() { + return this == CANCELED; + } + + } + + +} diff --git a/java/AoJ/src/com/oracle/adbaoverjdbc/com/oracle/adbaoverjdbc/OperationGroup.java b/java/AoJ/src/com/oracle/adbaoverjdbc/com/oracle/adbaoverjdbc/OperationGroup.java new file mode 100755 index 00000000..4da94bbf --- /dev/null +++ b/java/AoJ/src/com/oracle/adbaoverjdbc/com/oracle/adbaoverjdbc/OperationGroup.java @@ -0,0 +1,295 @@ +/* + * Copyright (c) 2018 Oracle and/or its affiliates. All rights reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.oracle.adbaoverjdbc; + +import jdk.incubator.sql2.LocalOperation; +import jdk.incubator.sql2.MultiOperation; +import jdk.incubator.sql2.OutOperation; +import jdk.incubator.sql2.ParameterizedRowOperation; +import jdk.incubator.sql2.Submission; +import jdk.incubator.sql2.Transaction; +import jdk.incubator.sql2.TransactionOutcome; +import java.time.Duration; +import java.util.concurrent.CompletableFuture; +import java.util.concurrent.CompletionStage; +import java.util.concurrent.Executor; +import java.util.function.Consumer; +import java.util.logging.Level; +import java.util.logging.Logger; +import java.util.stream.Collector; +import jdk.incubator.sql2.ParameterizedRowCountOperation; +import jdk.incubator.sql2.ParameterizedRowPublisherOperation; +import jdk.incubator.sql2.ArrayRowCountOperation; + +/** + * Only sequential, dependent, unconditional supported. + * + * Each member Operation creates a CompletableFuture that depends on the previous + * member's CompletableFuture. The first member Operation depends on a distinguished + * CompletableFuture called the head. When the head is completed + * the chain of member Operations is executed asynchronously. + * + * When the OperationGroup itself is submitted, the head is completed with + * the predecessor CompletableFuture. So, when the preceding Operation is completed + * the head is completed and the member Operations begin execution. + * + * The CompletableFuture for the OperationGroup depends on a CompletableFuture + * called held. When held is complete no more member Operations can be added. The + * value of the OperationGroup's CompletableFuture is computed by creating another + * CompletableFuture that depends on the value of the last member Operation. Since + * this is created only after held is completed we know the last member Operation. + * + * When the last member Operation is completed the result of the OperationGroup is + * computed by applying collector.finisher to the accumulator. + * + * For parallel groups each member Operation should depend directly on the + * head and the OperationGroup's result should depend on all the member + * Operations. + * + * For independent groups follows needs to insure the returned CompletableFuture + * hides any exceptions. + * + * For conditional groups the head should depend on both the predecessor + * completing and the condition completing with true. + * + * @param value type of member Operations + * @param value type of OperationGroup + */ +class OperationGroup extends com.oracle.adbaoverjdbc.Operation + implements jdk.incubator.sql2.OperationGroup { + + static final Collector DEFAULT_COLLECTOR = Collector.of( + () -> null, + (a, v) -> {}, + (a, b) -> null, + a -> null); + + static OperationGroup newOperationGroup(Connection conn) { + return new OperationGroup(conn, conn); + } + + static final Logger NULL_LOGGER = Logger.getAnonymousLogger(); + static { + NULL_LOGGER.setFilter(r -> false); + NULL_LOGGER.setLevel(Level.SEVERE); + } + + static final CompletionStage DEFAULT_CONDITION = CompletableFuture.completedFuture(true); + + private boolean isParallel = false; + private boolean isIndependent = false; + private CompletionStage condition = DEFAULT_CONDITION; + private Submission submission = null; + + private Object accumulator; + private Collector collector; + + Logger logger = NULL_LOGGER; + +/** + * completed when this OperationGroup is no longer held. Completion of this + * OperationGroup depends on held. + * + * @see submit, releaseProhibitingMoreOperations, submitHoldingForMoreOperations + */ + private final CompletableFuture held; + + /** + * predecessor of all member Operations and the OperationGroup itself + */ + private final CompletableFuture head; + + /** + * The last CompletionStage of any submitted member Operation. Mutable until + * not isHeld(). + */ + private CompletionStage memberTail; + + protected OperationGroup(Connection conn, OperationGroup group) { + super(conn, group); + held = new CompletableFuture(); + head = new CompletableFuture(); + memberTail = head; + collector = DEFAULT_COLLECTOR; + } + + @Override + public jdk.incubator.sql2.OperationGroup parallel() { + if ( isImmutable() || isParallel) throw new IllegalStateException("TODO"); + isParallel = true; + return this; + } + + @Override + public jdk.incubator.sql2.OperationGroup independent() { + if ( isImmutable() || isIndependent) throw new IllegalStateException("TODO"); + isIndependent = true; + return this; + } + + @Override + public jdk.incubator.sql2.OperationGroup conditional(CompletionStage condition) { + if ( isImmutable() || condition != null) throw new IllegalStateException("TODO"); + this.condition = condition; + return this; + } + + @Override + public Submission submitHoldingForMoreMembers() { + if ( isImmutable() || ! isHeld() ) throw new IllegalStateException("TODO"); //TODO prevent multiple calls + accumulator = collector.supplier().get(); + submission = super.submit(); + return submission; + } + + @Override + public jdk.incubator.sql2.Submission releaseProhibitingMoreMembers() { + if ( ! isImmutable() || ! isHeld() ) throw new IllegalStateException("TODO"); + held.complete(null); + immutable(); // having set isHeld to false this call will make this OpGrp immutable + return submission; + } + + @Override + public OperationGroup collect(Collector c) { + if ( isImmutable() || collector != DEFAULT_COLLECTOR) throw new IllegalStateException("TODO"); + if (c == null) throw new IllegalArgumentException("TODO"); + collector = c; + return this; + } + + @Override + public Operation catchOperation() { + if (! isHeld() ) throw new IllegalStateException("TODO"); + return UnskippableOperation.newOperation(connection, this, op -> null); + } + + @Override + public ArrayRowCountOperation arrayRowCountOperation(String sql) { + if ( ! isHeld() ) throw new IllegalStateException("TODO"); + throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. + } + + @Override + public ParameterizedRowCountOperation rowCountOperation(String sql) { + if ( ! isHeld() ) throw new IllegalStateException("TODO"); + if (sql == null) throw new IllegalArgumentException("TODO"); + return CountOperation.newCountOperation(connection, this, sql); + } + + @Override + public SqlOperation operation(String sql) { + if ( !isHeld() ) throw new IllegalStateException("TODO"); + return SqlOperation.newOperation(connection, this, sql); + } + + @Override + public OutOperation outOperation(String sql) { + if ( ! isHeld() ) throw new IllegalStateException("TODO"); + throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. + } + + @Override + public ParameterizedRowOperation rowOperation(String sql) { + if ( ! isHeld() ) throw new IllegalStateException("TODO"); + if (sql == null) throw new IllegalArgumentException("TODO"); + return RowOperation.newRowOperation(connection, this, sql); + } + + @Override + public ParameterizedRowPublisherOperation rowPublisherOperation(String sql) { + if ( !isHeld() ) throw new IllegalStateException("TODO"); + throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. + } + + @Override + public MultiOperation multiOperation(String sql) { + if ( ! isHeld() ) throw new IllegalStateException("TODO"); + throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. + } + + @Override + public SimpleOperation endTransactionOperation(Transaction trans) { + if ( ! isHeld() ) throw new IllegalStateException("TODO"); + return com.oracle.adbaoverjdbc.SimpleOperation.newOperation( + connection, + (OperationGroup)this, + op -> connection.jdbcEndTransaction(op, (com.oracle.adbaoverjdbc.Transaction)trans)); + } + + @Override + public LocalOperation localOperation() { + if ( ! isHeld() ) throw new IllegalStateException("TODO"); + throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. + } + + @Override + public jdk.incubator.sql2.OperationGroup logger(Logger logger) { + if ( logger == null ) throw new NullPointerException("OperationGroup.logger"); + else this.logger = logger; + return this; + } + + @Override + public OperationGroup timeout(Duration minTime) { + super.timeout(minTime); + return this; + } + + @Override + public OperationGroup onError(Consumer handler) { + super.onError(handler); + return this; + } + + @Override + public Submission submit() { + if ( isImmutable() ) throw new IllegalStateException("TODO"); + accumulator = collector.supplier().get(); + held.complete(null); + return super.submit(); + } + + // Internal methods + + Submission submit(Operation op) { + memberTail = op.attachErrorHandler(op.follows(memberTail, getExecutor())); + return com.oracle.adbaoverjdbc.Submission.submit(this::cancel, memberTail); + } + + @Override + CompletionStage follows(CompletionStage predecessor, Executor executor) { + return condition.thenCompose(cond -> { + if (cond) { + head.complete(predecessor); + return held.thenCompose(h + -> memberTail.thenApplyAsync(t -> (T)collector.finisher() + .apply(accumulator), + executor) + ); + } + else { + return CompletableFuture.completedStage(null); + } + } + ); + } + + protected boolean isHeld() { + return !held.isDone(); + } + +} diff --git a/java/AoJ/src/com/oracle/adbaoverjdbc/com/oracle/adbaoverjdbc/ParameterizedOperation.java b/java/AoJ/src/com/oracle/adbaoverjdbc/com/oracle/adbaoverjdbc/ParameterizedOperation.java new file mode 100755 index 00000000..11b256b3 --- /dev/null +++ b/java/AoJ/src/com/oracle/adbaoverjdbc/com/oracle/adbaoverjdbc/ParameterizedOperation.java @@ -0,0 +1,130 @@ +/* + * Copyright (c) 2018 Oracle and/or its affiliates. All rights reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.oracle.adbaoverjdbc; + +import jdk.incubator.sql2.AdbaType; +import jdk.incubator.sql2.SqlException; +import jdk.incubator.sql2.SqlType; +import java.sql.PreparedStatement; +import java.sql.SQLException; +import java.util.HashMap; +import java.util.Map; +import java.util.concurrent.CompletionStage; +import static com.oracle.adbaoverjdbc.Operation.toSQLType; +import static com.oracle.adbaoverjdbc.Operation.toSQLType; + +/** + * + */ +public abstract class ParameterizedOperation extends Operation + implements jdk.incubator.sql2.ParameterizedOperation { + + protected final Map setParameters; + protected CompletionStage futureParameters; + + ParameterizedOperation(Connection conn, OperationGroup operationGroup) { + super(conn, operationGroup); + setParameters = new HashMap<>(); + } + + CompletionStage attachFutureParameters(CompletionStage predecessor) { + if (futureParameters == null) return predecessor; + else return predecessor.runAfterBoth(futureParameters, () -> {}); + } + + @Override + public ParameterizedOperation set(String id, Object value, SqlType type) { + if (isImmutable() || setParameters.containsKey(id)) { + throw new IllegalStateException("TODO"); + } + if (id == null || (type != null && !(type instanceof AdbaType))) { + throw new IllegalArgumentException("TODO"); + } + if (value instanceof CompletionStage) { + if (futureParameters == null) { + futureParameters = ((CompletionStage)value) + .thenAccept( v -> { setParameters.put(id, new ParameterValue(v, type)); }); + } + else { + futureParameters = ((CompletionStage)value) + .thenAcceptBoth(futureParameters, + (v, f) -> { setParameters.put(id, new ParameterValue(v, type)); }); + } + } + else { + setParameters.put(id, new ParameterValue(value, type)); + } + return this; + } + + @Override + public ParameterizedOperation set(String id, CompletionStage source, SqlType type) { + return set(id, (Object) source, type); + } + + @Override + public ParameterizedOperation set(String id, CompletionStage source) { + return set(id, (Object) source, null); + } + + @Override + public ParameterizedOperation set(String id, Object value) { + return set(id, value, null); + } + + static final class ParameterValue { + + final Object value; + final SqlType type; + + ParameterValue(Object val, SqlType typ) { + value = val; + type = typ; + } + + void set(PreparedStatement stmt, String id) { + try { + try { + setByPosition(stmt, Integer.parseInt(id)); + } + catch (NumberFormatException ex) { + setByName(stmt, id); + } + } + catch (SQLException ex) { + throw new SqlException(ex.getMessage(), ex, ex.getSQLState(), ex.getErrorCode(), null, -1); + } + } + + void setByPosition(PreparedStatement stmt, int index) throws SQLException { + if (type == null) { + stmt.setObject(index, value, toSQLType(value.getClass())); + } + else if (type instanceof AdbaType) { + stmt.setObject(index, value, toSQLType((AdbaType)type)); + } + else { + throw new IllegalArgumentException("TODO"); + } + } + + void setByName(PreparedStatement stmt, String id) throws SQLException { + throw new UnsupportedOperationException("Not supported yet."); + } + } + + +} diff --git a/java/AoJ/src/com/oracle/adbaoverjdbc/com/oracle/adbaoverjdbc/RowOperation.java b/java/AoJ/src/com/oracle/adbaoverjdbc/com/oracle/adbaoverjdbc/RowOperation.java new file mode 100755 index 00000000..c422e7f0 --- /dev/null +++ b/java/AoJ/src/com/oracle/adbaoverjdbc/com/oracle/adbaoverjdbc/RowOperation.java @@ -0,0 +1,408 @@ +/* + * Copyright (c) 2018 Oracle and/or its affiliates. All rights reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.oracle.adbaoverjdbc; + +import jdk.incubator.sql2.ParameterizedRowOperation; +import jdk.incubator.sql2.SqlException; +import jdk.incubator.sql2.SqlType; +import java.sql.PreparedStatement; +import java.sql.ResultSet; +import java.sql.ResultSetMetaData; +import java.sql.SQLException; +import java.time.Duration; +import java.util.concurrent.CompletableFuture; +import java.util.concurrent.CompletionStage; +import java.util.concurrent.Executor; +import java.util.concurrent.atomic.AtomicBoolean; +import java.util.function.Consumer; +import java.util.logging.Level; +import java.util.stream.Collector; +import jdk.incubator.sql2.Result; + +/** + * Creates separate CompletionStages to execute the query, to fetch and process + * each block of fetchSize rows and to compute the final result. Yes, these are + * all synchronous actions so there is no theoretical requirement to do them in + * separate CompletionStages. This class does so to break up this large synchronous + * action into smaller tasks so as to avoid hogging a thread. + */ +class RowOperation extends ParameterizedOperation + implements jdk.incubator.sql2.ParameterizedRowOperation { + + + private static final int NOT_SET = -1; + static final Collector DEFAULT_COLLECTOR = Collector.of( + () -> null, + (a, v) -> {}, + (a, b) -> null, + a -> null); + static RowOperation newRowOperation(Connection conn, OperationGroup grp, String sql) { + return new RowOperation<>(conn, grp, sql); + } + + // attributes + private final String sqlString; + private int fetchSize; + private Collector collector; + + // internal state + private PreparedStatement jdbcStatement; + private ResultSet resultSet; + private ResultSetMetaData resultSetMetaData; + private Object accumulator; + private boolean rowsRemain; + private long rowCount; + private String[] identifiers; + + protected RowOperation(Connection conn, OperationGroup grp, String sql) { + super(conn, grp); + fetchSize = NOT_SET; + collector = DEFAULT_COLLECTOR; + sqlString = sql; + } + + @Override + CompletionStage follows(CompletionStage predecessor, Executor executor) { + predecessor = attachFutureParameters(predecessor); + return predecessor + .thenRunAsync(this::executeQuery, executor) + .thenCompose(this::moreRows); + } + + @Override + boolean cancel() { + try { + if (jdbcStatement != null) { + jdbcStatement.cancel(); + } + super.cancel(); + return rowsRemain; // if all rows processed then + } + catch (SQLException ex) { + throw new SqlException(ex.getMessage(), ex, ex.getSQLState(), ex.getErrorCode(), sqlString, -1); + } + } + + /** + * Return a CompletionStage that fetches the next block of rows. If there are + * no more rows to fetch return a CompletionStage that completes the query. + * + * @param x ignored + * @return the next Completion stage in the processing of the query. + */ + private CompletionStage moreRows(Object x) { + checkCanceled(); + if (rowsRemain) { + return CompletableFuture.runAsync(this::handleFetchRows, getExecutor()) + .thenComposeAsync(this::moreRows, getExecutor()); + } + else { + return CompletableFuture.supplyAsync(this::completeQuery, getExecutor()); + } + } + + private void initFetchSize() throws SQLException { + if (fetchSize == NOT_SET) { + fetchSize = jdbcStatement.getFetchSize(); + } + else { + jdbcStatement.setFetchSize(fetchSize); + } + } + + private void executeQuery() { + checkCanceled(); + try { + jdbcStatement = connection.prepareStatement(sqlString); + initFetchSize(); + setParameters.forEach((String k, ParameterValue v) -> { + v.set(jdbcStatement, k); + }); + group.logger.log(Level.FINE, () -> "executeQuery(\"" + sqlString + "\")"); + resultSet = jdbcStatement.executeQuery(); + resultSetMetaData = resultSet.getMetaData(); + accumulator = collector.supplier().get(); + rowsRemain = true; + rowCount = 0; + } + catch (SQLException ex) { + throw new SqlException(ex.getMessage(), ex, ex.getSQLState(), ex.getErrorCode(), sqlString, -1); + } + } + + /** + * Process fetchSize rows. If the fetches are in sync then all the rows will + * be in memory after the first is fetched up through the last row processed. + * The subsequent row, the one after the last row processed should not be in + * memory and will require a database roundtrip to fetch. This is all assuming + * the rows are fetched fetchSize rows per roundtrip which may not be the case. + * + * @return true if more rows remain + * @throws SQLException + */ + private Object handleFetchRows() { + try { + for (int i = 0; i < fetchSize && (rowsRemain = resultSet.next()); i++) { + handleRow(); + rowCount++; + } + } + catch (SQLException ex) { + throw new SqlException(ex.getMessage(), ex, ex.getSQLState(), ex.getErrorCode(), sqlString, -1); + } + return null; + } + + private void handleRow() throws SQLException { + checkCanceled(); + try (RowColumn row = new RowOperation.RowColumn(this)) { + collector.accumulator().accept(accumulator, row); + } + } + + private T completeQuery() { + try { + resultSet.close(); + jdbcStatement.close(); + checkCanceled(); + return (T) collector.finisher().apply(accumulator); + } + catch (SQLException ex) { + throw new SqlException(ex.getMessage(), ex, ex.getSQLState(), ex.getErrorCode(), sqlString, -1); + } + } + + private String[] getIdentifiers() { + if (identifiers == null) { + try { + if (resultSet == null) { + throw new IllegalStateException("TODO"); + } + group.logger.log(Level.FINE, () -> "ResultSet.getMetaData()"); //DEBUG + ResultSetMetaData md = resultSet.getMetaData(); + int count = md.getColumnCount(); + identifiers = new String[count]; + for (int i = 0; i < count; i++) { + identifiers[i] = md.getColumnLabel(i + 1); + } + } + catch (SQLException ex) { + throw new SqlException(ex.getMessage(), ex, ex.getSQLState(), ex.getErrorCode(), sqlString, -1); + } + } + return identifiers; + } + + String enquoteIdentifier(String id) { + try { + return jdbcStatement.enquoteIdentifier(id, false); + } + catch (SQLException ex) { + throw new SqlException(ex.getMessage(), ex, ex.getSQLState(), ex.getErrorCode(), sqlString, -1); + } + } + + @Override + public ParameterizedRowOperation fetchSize(long rows) throws IllegalArgumentException { + if (isImmutable() || fetchSize != NOT_SET) throw new IllegalStateException("TODO"); + if (rows < 1) throw new IllegalArgumentException("TODO"); + fetchSize = (int)rows; + return this; + } + + @Override + public ParameterizedRowOperation collect(Collector c) { + if (isImmutable() || collector != DEFAULT_COLLECTOR) throw new IllegalStateException("TODO"); + if (c == null) throw new IllegalArgumentException("TODO"); + collector = c; + return this; + } + + + @Override + public RowOperation onError(Consumer handler) { + return (RowOperation)super.onError(handler); + } + + @Override + public RowOperation timeout(Duration minTime) { + return (RowOperation)super.timeout(minTime); + } + + @Override + public RowOperation set(String id, Object value, SqlType type) { + return (RowOperation)super.set(id, value, type); + } + + @Override + public RowOperation set(String id, CompletionStage source, SqlType type) { + return (RowOperation)super.set(id, source, type); + } + + @Override + public RowOperation set(String id, CompletionStage source) { + return (RowOperation)super.set(id, source); + } + + @Override + public RowOperation set(String id, Object value) { + return (RowOperation)super.set(id, value); + } + + static final class RowColumn implements jdk.incubator.sql2.Result.RowColumn, AutoCloseable { + + static RowOperation.RowColumn newRowColumn(RowOperation op) { + return new RowOperation.RowColumn(op); + } + + private final AtomicBoolean isClosed; // all slices and clones share this + private final RowOperation op; + private int columnIndex = -1; + private int columnOffset = 0; // used by slices + private int lastColumn = Integer.MAX_VALUE; + + // use this only to construct de novo RowColumns. Do not use for slice or clone + // use clone() for that. + private RowColumn(RowOperation op) { + isClosed = new AtomicBoolean(false); + this.op = op; + columnIndex = 1; + columnOffset = 0; + lastColumn = op.getIdentifiers().length + 1; + } + + /** make a clone into a slice + * + * @param numValues number of columns in the slice + * @return this RowColumn as a slice + */ + private RowColumn asSlice(int numValues) { + columnOffset = columnOffset + columnIndex; + columnIndex = 1; + lastColumn = numValues; + return this; + } + + @Override + public void close() { + isClosed.set(true); + } + + @Override + public long rowNumber() { + if (isClosed.get()) throw new IllegalStateException("TODO"); + return op.rowCount; // keep an independent count because ResultSet.row is limited to int + } + + @Override + public void cancel() { + if (isClosed.get()) throw new IllegalStateException("TODO"); + throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. + } + + @Override + public T get(Class type) { + if (isClosed.get()) throw new IllegalStateException("TODO"); + try { + return op.resultSet.getObject(columnIndex + columnOffset, type); + } + catch (SQLException ex) { + throw new SqlException(ex.getMessage(), ex, ex.getSQLState(), ex.getErrorCode(), op.sqlString, -1); + } + } + + @Override + public String identifier() { + if (isClosed.get()) throw new IllegalStateException("TODO"); + return op.getIdentifiers()[columnIndex + columnOffset - 1]; + } + + @Override + public int index() { + if (isClosed.get()) throw new IllegalStateException("TODO"); + return columnIndex; + } + + @Override + public int absoluteIndex() { + if (isClosed.get()) throw new IllegalStateException("TODO"); + return columnIndex + columnOffset; + } + + @Override + public SqlType sqlType() { + if (isClosed.get()) throw new IllegalStateException("TODO"); + throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. + } + + @Override + public Class javaType() { + if (isClosed.get()) throw new IllegalStateException("TODO"); + return sqlType().getJavaType(); + } + + @Override + public long length() { + if (isClosed.get()) throw new IllegalStateException("TODO"); + throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. + } + + @Override + public int numberOfValuesRemaining() { + if (isClosed.get()) throw new IllegalStateException("TODO"); + return lastColumn - columnIndex; + } + + @Override + public Column at(String id) { + if (isClosed.get()) throw new IllegalStateException("TODO"); + String canonical = op.enquoteIdentifier(id); + String[] ids = op.getIdentifiers(); + int index = 1; + for(; index <= lastColumn && !ids[index + columnOffset - 1].equals(canonical); index++) { } + if (index > lastColumn) throw new IllegalArgumentException("TODO"); + else columnIndex = index; + return this; + } + + @Override + public Column at(int index) { + if (isClosed.get()) throw new IllegalStateException("TODO"); + if (index < 1 || lastColumn < index) throw new IllegalArgumentException("TODO"); + columnIndex = index; + return this; + } + + @Override + public RowColumn slice(int numValues) { + if (isClosed.get()) throw new IllegalStateException("TODO"); + return this.clone().asSlice(numValues); + } + + @Override + public RowOperation.RowColumn clone() { + if (isClosed.get()) throw new IllegalStateException("TODO"); + try { + return (RowOperation.RowColumn)super.clone(); + } + catch (CloneNotSupportedException ex) { + throw new RuntimeException("TODO", ex); + } + } + + } // RowColumn + +} diff --git a/java/AoJ/src/com/oracle/adbaoverjdbc/com/oracle/adbaoverjdbc/SimpleOperation.java b/java/AoJ/src/com/oracle/adbaoverjdbc/com/oracle/adbaoverjdbc/SimpleOperation.java new file mode 100755 index 00000000..64df935d --- /dev/null +++ b/java/AoJ/src/com/oracle/adbaoverjdbc/com/oracle/adbaoverjdbc/SimpleOperation.java @@ -0,0 +1,68 @@ +/* + * Copyright (c) 2018 Oracle and/or its affiliates. All rights reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.oracle.adbaoverjdbc; + +import java.util.concurrent.CompletionStage; +import java.util.concurrent.Executor; +import java.util.function.Function; +import java.util.function.Supplier; +import jdk.incubator.sql2.SqlSkippedException; + +/** + * + * @param + */ +class SimpleOperation extends Operation implements Supplier { + + static SimpleOperation newOperation(Connection conn, + OperationGroup group, + Function, S> act) { + return new SimpleOperation<>(conn, group, act); + } + + private final Function, T> action; + + protected SimpleOperation(Connection conn, + OperationGroup operationGroup, + Function, T> act) { + super(conn, operationGroup); + action = act; + } + + @Override + CompletionStage follows(CompletionStage tail, Executor executor) { + return tail.thenApplyAsync(x -> get(), executor); + } + + /** + * Computes the value of this Operation by calling the action. If this + * Operation has been canceled throws SqlSkippedException. If the action + * throws a checked exception, wrap that checked exception in a SqlException. + * SqlException is unchecked as required by Supplier, and can be handled by + * CompletionStage. + */ + @Override + public T get() { + checkCanceled(); + try { + return action.apply(this); + } + finally { + operationLifecycle = OperationLifecycle.COMPLETED; + } + } + +} diff --git a/java/AoJ/src/com/oracle/adbaoverjdbc/com/oracle/adbaoverjdbc/SqlOperation.java b/java/AoJ/src/com/oracle/adbaoverjdbc/com/oracle/adbaoverjdbc/SqlOperation.java new file mode 100755 index 00000000..a606fbea --- /dev/null +++ b/java/AoJ/src/com/oracle/adbaoverjdbc/com/oracle/adbaoverjdbc/SqlOperation.java @@ -0,0 +1,30 @@ +/* + * Copyright (c) 2018 Oracle and/or its affiliates. All rights reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.oracle.adbaoverjdbc; + +/** + * + */ +class SqlOperation extends SimpleOperation { + + static SqlOperation newOperation(Connection conn, OperationGroup group, String sql) { + return new SqlOperation<>(conn, group, sql); + } + + protected SqlOperation(Connection conn, OperationGroup group, String sql) { + super(conn, group, op -> (T)conn.jdbcExecute(op, sql)); + } +} diff --git a/java/AoJ/src/com/oracle/adbaoverjdbc/com/oracle/adbaoverjdbc/Submission.java b/java/AoJ/src/com/oracle/adbaoverjdbc/com/oracle/adbaoverjdbc/Submission.java new file mode 100755 index 00000000..4f8e065d --- /dev/null +++ b/java/AoJ/src/com/oracle/adbaoverjdbc/com/oracle/adbaoverjdbc/Submission.java @@ -0,0 +1,51 @@ +/* + * Copyright (c) 2018 Oracle and/or its affiliates. All rights reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.oracle.adbaoverjdbc; + +import java.util.concurrent.CompletableFuture; +import java.util.concurrent.CompletionStage; +import java.util.function.Supplier; + +/** + * + */ +class Submission implements jdk.incubator.sql2.Submission { + + final private Supplier cancel; + final private CompletionStage stage; + private CompletionStage publicStage; + + static Submission submit(Supplier cancel, CompletionStage s) { + return new Submission<>(cancel, s); + } + + protected Submission(Supplier can, CompletionStage stg) { + cancel = can; + stage = stg; + } + + @Override + public CompletionStage cancel() { + return new CompletableFuture().completeAsync(cancel); + } + + @Override + public CompletionStage getCompletionStage() { + if (publicStage == null) publicStage = ((CompletableFuture)stage).minimalCompletionStage(); + return publicStage; + } + +} diff --git a/java/AoJ/src/com/oracle/adbaoverjdbc/com/oracle/adbaoverjdbc/Transaction.java b/java/AoJ/src/com/oracle/adbaoverjdbc/com/oracle/adbaoverjdbc/Transaction.java new file mode 100755 index 00000000..98b14bce --- /dev/null +++ b/java/AoJ/src/com/oracle/adbaoverjdbc/com/oracle/adbaoverjdbc/Transaction.java @@ -0,0 +1,64 @@ +/* + * Copyright (c) 2018 Oracle and/or its affiliates. All rights reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.oracle.adbaoverjdbc; + +/** + * + */ +class Transaction implements jdk.incubator.sql2.Transaction { + + private boolean isRollbackOnly = false; + private boolean isInFlight = true; + private final Connection connection; + + static Transaction createTransaction(Connection conn) { + return new Transaction(conn); + } + + private Transaction(Connection conn) { + connection = conn; + } + + /** + * + * @param conn + * @return true iff transaction should be committed. false otherwise + */ + synchronized boolean endWithCommit(Connection conn) { + if (conn != connection) throw new IllegalArgumentException("TODO"); + if (!isInFlight) throw new IllegalStateException("TODO"); + isInFlight = false; + return !isRollbackOnly; + } + + @Override + public synchronized boolean setRollbackOnly() { + if (!connection.getConnectionLifecycle().isActive()) throw new IllegalStateException("TODO"); + if (isInFlight) { + isRollbackOnly = true; + return true; + } + else { + return false; + } + } + + @Override + public boolean isRollbackOnly() { + return isRollbackOnly; + } + +} diff --git a/java/AoJ/src/com/oracle/adbaoverjdbc/com/oracle/adbaoverjdbc/UnskippableOperation.java b/java/AoJ/src/com/oracle/adbaoverjdbc/com/oracle/adbaoverjdbc/UnskippableOperation.java new file mode 100755 index 00000000..c56765be --- /dev/null +++ b/java/AoJ/src/com/oracle/adbaoverjdbc/com/oracle/adbaoverjdbc/UnskippableOperation.java @@ -0,0 +1,54 @@ +/* + * Copyright (c) 2018 Oracle and/or its affiliates. All rights reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.oracle.adbaoverjdbc; + +import java.util.concurrent.CompletionStage; +import java.util.concurrent.Executor; +import java.util.function.Function; + +/** + * + */ +class UnskippableOperation extends SimpleOperation { + + static UnskippableOperation newOperation(Connection conn, + OperationGroup group, + Function, S> action) { + return new UnskippableOperation<>(conn, group, action); + } + + protected UnskippableOperation(Connection conn, + OperationGroup operationGroup, + Function, T> action) { + super(conn, operationGroup, (Function, T>)action); + } + + @Override + CompletionStage follows(CompletionStage tail, Executor executor) { + return tail.handleAsync( + (Object v, Throwable t) -> { + try { + return get(); + } + catch (Throwable ex) { + if (errorHandler != null) errorHandler.accept(ex); + throw ex; + } + }, + executor); + } + +} diff --git a/java/AoJ/src/com/oracle/adbaoverjdbc/module-info.java b/java/AoJ/src/com/oracle/adbaoverjdbc/module-info.java new file mode 100755 index 00000000..c9b0ce26 --- /dev/null +++ b/java/AoJ/src/com/oracle/adbaoverjdbc/module-info.java @@ -0,0 +1,22 @@ +/* + * Copyright (c) 2018 Oracle and/or its affiliates. All rights reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +module com.oracle.adbaoverjdbc { + requires jdk.incubator.adba; + requires java.sql; + exports com.oracle.adbaoverjdbc; + provides jdk.incubator.sql2.DataSourceFactory with com.oracle.adbaoverjdbc.DataSourceFactory; +} From d174ed50eabef3d6474cb364ac85a85dd3d7b582 Mon Sep 17 00:00:00 2001 From: Kuassim Date: Thu, 21 Jun 2018 11:53:31 -0700 Subject: [PATCH 10/16] Updated the Readme with reference to additioal code samples. --- java/AoJ/README.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/java/AoJ/README.md b/java/AoJ/README.md index 369749e9..e7942635 100644 --- a/java/AoJ/README.md +++ b/java/AoJ/README.md @@ -116,6 +116,8 @@ introduction to ADBA see the [JavaOne 2017 presentation](http://www.oracle.com/t } ``` +The following new sample code have been added: HellowWorld.java and NewEmptyUnitTest.java. + ## AoJ Design Spec in 100 words or less The methods called by the user thread create a network From 42efb789252ae5ab0957a632cac894cde1565888 Mon Sep 17 00:00:00 2001 From: Kuassim Date: Thu, 21 Jun 2018 11:54:38 -0700 Subject: [PATCH 11/16] Fixed typo. --- java/AoJ/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/java/AoJ/README.md b/java/AoJ/README.md index e7942635..82daef08 100644 --- a/java/AoJ/README.md +++ b/java/AoJ/README.md @@ -116,7 +116,7 @@ introduction to ADBA see the [JavaOne 2017 presentation](http://www.oracle.com/t } ``` -The following new sample code have been added: HellowWorld.java and NewEmptyUnitTest.java. +The following new sample code have been added: HellowWorld.java and NewEmptyJUnitTest.java. ## AoJ Design Spec in 100 words or less From 6cd6c556e2728f8656f71dbab5636fa400fb3df8 Mon Sep 17 00:00:00 2001 From: Gerald Venzl Date: Thu, 21 Jun 2018 16:47:23 -0700 Subject: [PATCH 12/16] Add Exadata Express Python example (#43) Signed-off-by: Gerald Venzl --- README.md | 1 + exadata-express/Query.py | 37 +++++++++++++++++++++++++++++++++++++ 2 files changed, 38 insertions(+) create mode 100644 exadata-express/Query.py diff --git a/README.md b/README.md index eb82be72..46f0efe6 100644 --- a/README.md +++ b/README.md @@ -5,6 +5,7 @@ This repository stores a variety of examples demonstrating how to use the Oracle | ------------- | ------------- | | [db-sample-schemas](https://github.com/oracle/db-sample-schemas) | Git submodule of the Oracle Database Sample Schemas | | [dotnet](./dotnet) | .NET based examples | +| [exadata-express](./exadata-express) | Exadata Express examples | | [java](./java) | Java based examples | | [javascript](./javascript) | JavaScript based examples | | [optimizer](./optimizer) | Oracle Optmizer and Optimizer Stats examples | diff --git a/exadata-express/Query.py b/exadata-express/Query.py new file mode 100644 index 00000000..f446717b --- /dev/null +++ b/exadata-express/Query.py @@ -0,0 +1,37 @@ +#------------------------------------------------------------------------------ +# Query.py +# +# Demonstrate how to perform a query of a database schema, configured with Oracle's sample HR Schema, in your Exadata Express +# Cloud Service. +# +# Before running this app: +# 1. From the Exadata Express Cloud Service Console, click on Develop, then click on Python. Follow displayed instructions to: +# - Install instant client. +# - Enable client access and download your Exadata Express Cloud Service credentials. +# - Install the Python Extension module (cx_Oracle) to enable access to your cloud service. +# 2. Create a schema using the Exadata Express Cloud Service Console. Remember the schema name and password for step 4. +# 3. Configure the schema with Oracle's Sample HR Schema. Scripts to configure this schema can be found on GitHub. +# See github.com/oracle/db-sample-schemas for scripts and instructions. +# 4. Modify cx_Oracle.connect to connect to the HR schema you created in step 2: +# - The first value is the name of your HR schema. +# - The second value is the password for your HR schema. +# - The third value is "dbaccess", which is defined in the wallet downloaded from the Exadata Express Cloud Service +#------------------------------------------------------------------------------ + +from __future__ import print_function + +import cx_Oracle + + +connection = cx_Oracle.connect('HR',password,'dbaccess') + +sql = """ +select * from employees where department_id = 90""" + + +print("Get all rows via iterator") +cursor = connection.cursor() +for result in cursor.execute(sql): + print(result) +print() + From 9d4ad7118f08a0df238d37ce6e1644d4f23b434a Mon Sep 17 00:00:00 2001 From: Kuassim Date: Tue, 3 Jul 2018 14:57:54 -0700 Subject: [PATCH 13/16] Reactive stream, Column navigation --- .../oracle/adbaoverjdbc/CountOperation.java | 12 +- .../com/oracle/adbaoverjdbc/DataSource.java | 38 +- .../adbaoverjdbc/DataSourceBuilder.java | 50 ++- .../JdbcConnectionProperties.java | 6 +- .../com/oracle/adbaoverjdbc/Operation.java | 19 +- .../oracle/adbaoverjdbc/OperationGroup.java | 33 +- .../adbaoverjdbc/ParameterizedOperation.java | 4 +- .../com/oracle/adbaoverjdbc/RowOperation.java | 10 +- .../com/oracle/adbaoverjdbc/Session.java | 355 ++++++++++++++++++ .../oracle/adbaoverjdbc/SessionBuilder.java | 100 +++++ .../oracle/adbaoverjdbc/SimpleOperation.java | 8 +- .../com/oracle/adbaoverjdbc/SqlOperation.java | 8 +- .../oracle/adbaoverjdbc/TransactionEnd.java | 64 ++++ .../adbaoverjdbc/UnskippableOperation.java | 8 +- 14 files changed, 632 insertions(+), 83 deletions(-) create mode 100755 java/AoJ/src/com/oracle/adbaoverjdbc/com/oracle/adbaoverjdbc/Session.java create mode 100755 java/AoJ/src/com/oracle/adbaoverjdbc/com/oracle/adbaoverjdbc/SessionBuilder.java create mode 100755 java/AoJ/src/com/oracle/adbaoverjdbc/com/oracle/adbaoverjdbc/TransactionEnd.java diff --git a/java/AoJ/src/com/oracle/adbaoverjdbc/com/oracle/adbaoverjdbc/CountOperation.java b/java/AoJ/src/com/oracle/adbaoverjdbc/com/oracle/adbaoverjdbc/CountOperation.java index 8bb75581..7ef59922 100755 --- a/java/AoJ/src/com/oracle/adbaoverjdbc/com/oracle/adbaoverjdbc/CountOperation.java +++ b/java/AoJ/src/com/oracle/adbaoverjdbc/com/oracle/adbaoverjdbc/CountOperation.java @@ -42,13 +42,13 @@ class CountOperation extends ParameterizedOperation * Factory method to create CountOperations. * * @param the type of the value of the CountOperation - * @param conn the Connection the CountOperation belongs to + * @param session the Session the CountOperation belongs to * @param grp the GroupOperation the CountOperation is a member of * @param sql the SQL string to execute. Must return a count. * @return a new CountOperation that will execute sql. */ - static CountOperation newCountOperation(Connection conn, OperationGroup grp, String sql) { - return new CountOperation<>(conn, grp, sql); + static CountOperation newCountOperation(Session session, OperationGroup grp, String sql) { + return new CountOperation<>(session, grp, sql); } // attributes @@ -57,8 +57,8 @@ static CountOperation newCountOperation(Connection conn, OperationGroup g PreparedStatement jdbcStatement; - CountOperation(Connection conn, OperationGroup operationGroup, String sql) { - super(conn, operationGroup); + CountOperation(Session session, OperationGroup operationGroup, String sql) { + super(session, operationGroup); countProcessor = DEFAULT_PROCESSOR; sqlString = sql; } @@ -93,7 +93,7 @@ CompletionStage follows(CompletionStage predecessor, Executor executor) { private T executeQuery(Object ignore) { checkCanceled(); try { - jdbcStatement = connection.prepareStatement(sqlString); + jdbcStatement = session.prepareStatement(sqlString); setParameters.forEach((String k, ParameterValue v) -> { v.set(jdbcStatement, k); }); diff --git a/java/AoJ/src/com/oracle/adbaoverjdbc/com/oracle/adbaoverjdbc/DataSource.java b/java/AoJ/src/com/oracle/adbaoverjdbc/com/oracle/adbaoverjdbc/DataSource.java index 0543d9ae..42fb269b 100755 --- a/java/AoJ/src/com/oracle/adbaoverjdbc/com/oracle/adbaoverjdbc/DataSource.java +++ b/java/AoJ/src/com/oracle/adbaoverjdbc/com/oracle/adbaoverjdbc/DataSource.java @@ -15,53 +15,53 @@ */ package com.oracle.adbaoverjdbc; -import jdk.incubator.sql2.ConnectionProperty; +import jdk.incubator.sql2.SessionProperty; import java.util.HashSet; import java.util.Map; import java.util.Set; /** - * Bare bones DataSource. No support for Connection caching. + * Bare bones DataSource. No support for Session caching. * */ class DataSource implements jdk.incubator.sql2.DataSource { - static DataSource newDataSource(Map defaultConnectionProperties, - Map requiredConnectionProperties) { - return new DataSource(defaultConnectionProperties, requiredConnectionProperties); + static DataSource newDataSource(Map defaultSessionProperties, + Map requiredSessionProperties) { + return new DataSource(defaultSessionProperties, requiredSessionProperties); } - protected final Map defaultConnectionProperties; - protected final Map requiredConnectionProperties; + protected final Map defaultSessionProperties; + protected final Map requiredSessionProperties; - protected final Set openConnections = new HashSet<>(); + protected final Set openSessions = new HashSet<>(); - protected DataSource(Map defaultProps, - Map requiredProps) { + protected DataSource(Map defaultProps, + Map requiredProps) { super(); - defaultConnectionProperties = defaultProps; - requiredConnectionProperties = requiredProps; + defaultSessionProperties = defaultProps; + requiredSessionProperties = requiredProps; } @Override - public Connection.Builder builder() { - return ConnectionBuilder.newConnectionBuilder(this, defaultConnectionProperties, requiredConnectionProperties); + public Session.Builder builder() { + return SessionBuilder.newSessionBuilder(this, defaultSessionProperties, requiredSessionProperties); } @Override public void close() { - openConnections.stream().forEach( c -> c.close() ); + openSessions.stream().forEach( c -> c.close() ); } - DataSource registerConnection(Connection c) { - openConnections.add(c); + DataSource registerSession(Session c) { + openSessions.add(c); return this; } - DataSource deregisterConnection(Connection c) { - openConnections.remove(c); + DataSource deregisterSession(Session c) { + openSessions.remove(c); return this; } diff --git a/java/AoJ/src/com/oracle/adbaoverjdbc/com/oracle/adbaoverjdbc/DataSourceBuilder.java b/java/AoJ/src/com/oracle/adbaoverjdbc/com/oracle/adbaoverjdbc/DataSourceBuilder.java index d72f9eb9..3e96f988 100755 --- a/java/AoJ/src/com/oracle/adbaoverjdbc/com/oracle/adbaoverjdbc/DataSourceBuilder.java +++ b/java/AoJ/src/com/oracle/adbaoverjdbc/com/oracle/adbaoverjdbc/DataSourceBuilder.java @@ -15,10 +15,11 @@ */ package com.oracle.adbaoverjdbc; -import jdk.incubator.sql2.ConnectionProperty; +import jdk.incubator.sql2.SessionProperty; import java.util.HashMap; import java.util.Map; -import java.util.function.Consumer; +import java.util.function.LongConsumer; +import jdk.incubator.sql2.DataSourceProperty; /** * @@ -31,54 +32,71 @@ static DataSourceBuilder newDataSourceBuilder() { protected boolean isBuilt = false; + Map dataSourceProperties = new HashMap<>(); + /** - * defaultConnectionProperties can be overridden by a ConnectionBuilder + * defaultSessionProperties can be overridden by a SessionBuilder */ - Map defaultConnectionProperties = new HashMap<>(); + Map defaultSessionProperties = new HashMap<>(); /** - * it is an error if a ConnectionBuilder tries to override requiredConnectionProperties + * it is an error if a SessionBuilder tries to override requiredSessionProperties */ - Map requiredConnectionProperties = new HashMap<>(); + Map requiredSessionProperties = new HashMap<>(); + + @Override + public jdk.incubator.sql2.DataSource.Builder property(DataSourceProperty property, Object value) { + if (isBuilt) { + throw new IllegalStateException("TODO"); + } + if (dataSourceProperties.containsKey(property)) { + throw new IllegalArgumentException("cannot set a property multiple times"); + } + if (!property.validate(value)) { + throw new IllegalArgumentException("TODO"); + } + dataSourceProperties.put(property, value); + return this; + } @Override - public jdk.incubator.sql2.DataSource.Builder defaultConnectionProperty(ConnectionProperty property, Object value) { + public jdk.incubator.sql2.DataSource.Builder defaultSessionProperty(SessionProperty property, Object value) { if (isBuilt) { throw new IllegalStateException("TODO"); } - if (defaultConnectionProperties.containsKey(property)) { + if (defaultSessionProperties.containsKey(property)) { throw new IllegalArgumentException("cannot set a default multiple times"); } - if (requiredConnectionProperties.containsKey(property)) { + if (requiredSessionProperties.containsKey(property)) { throw new IllegalArgumentException("cannot set a default that is already required"); } if (!property.validate(value)) { throw new IllegalArgumentException("TODO"); } - defaultConnectionProperties.put(property, value); + defaultSessionProperties.put(property, value); return this; } @Override - public jdk.incubator.sql2.DataSource.Builder connectionProperty(ConnectionProperty property, Object value) { + public jdk.incubator.sql2.DataSource.Builder sessionProperty(SessionProperty property, Object value) { if (isBuilt) { throw new IllegalStateException("TODO"); } - if (defaultConnectionProperties.containsKey(property)) { + if (defaultSessionProperties.containsKey(property)) { throw new IllegalArgumentException("cannot set a required prop that has a default"); } - if (requiredConnectionProperties.containsKey(property)) { + if (requiredSessionProperties.containsKey(property)) { throw new IllegalArgumentException("cannot set a required prop multiple times"); } if (!property.validate(value)) { throw new IllegalArgumentException("TODO"); } - requiredConnectionProperties.put(property, value); + requiredSessionProperties.put(property, value); return this; } @Override - public jdk.incubator.sql2.DataSource.Builder requestHook(Consumer request) { + public jdk.incubator.sql2.DataSource.Builder requestHook(LongConsumer request) { throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. } @@ -88,7 +106,7 @@ public jdk.incubator.sql2.DataSource build() { throw new IllegalStateException("cannot build more than once. All objects are use-once"); } isBuilt = true; - return DataSource.newDataSource(defaultConnectionProperties, requiredConnectionProperties); + return DataSource.newDataSource(defaultSessionProperties, requiredSessionProperties); } } diff --git a/java/AoJ/src/com/oracle/adbaoverjdbc/com/oracle/adbaoverjdbc/JdbcConnectionProperties.java b/java/AoJ/src/com/oracle/adbaoverjdbc/com/oracle/adbaoverjdbc/JdbcConnectionProperties.java index d285e279..4f6fff5c 100755 --- a/java/AoJ/src/com/oracle/adbaoverjdbc/com/oracle/adbaoverjdbc/JdbcConnectionProperties.java +++ b/java/AoJ/src/com/oracle/adbaoverjdbc/com/oracle/adbaoverjdbc/JdbcConnectionProperties.java @@ -18,12 +18,12 @@ import java.util.Properties; /** - * An ADBA ConnectionProperty that specifies a set of JDBC connection properties. + * An ADBA SessionProperty that specifies a set of JDBC Connection properties. * Its value is a java.util.Properties. This value is passed as the info argument * when creating a java.sql.Connection. * */ -public class JdbcConnectionProperties implements jdk.incubator.sql2.ConnectionProperty { +public class JdbcConnectionProperties implements jdk.incubator.sql2.SessionProperty { public static final JdbcConnectionProperties JDBC_CONNECTION_PROPERTIES = new JdbcConnectionProperties(); @@ -33,7 +33,7 @@ private JdbcConnectionProperties() { @Override public String name() { - return "JDBC_CONNECTION_PROPERTIES"; + return "JDBC_SESSION_PROPERTIES"; } @Override diff --git a/java/AoJ/src/com/oracle/adbaoverjdbc/com/oracle/adbaoverjdbc/Operation.java b/java/AoJ/src/com/oracle/adbaoverjdbc/com/oracle/adbaoverjdbc/Operation.java index 6d7d982d..16f57056 100755 --- a/java/AoJ/src/com/oracle/adbaoverjdbc/com/oracle/adbaoverjdbc/Operation.java +++ b/java/AoJ/src/com/oracle/adbaoverjdbc/com/oracle/adbaoverjdbc/Operation.java @@ -146,16 +146,19 @@ static Throwable unwrapException(Throwable ex) { protected Consumer errorHandler = null; // internal state - protected final Connection connection; + protected final Session session; protected final OperationGroup group; protected OperationLifecycle operationLifecycle = OperationLifecycle.MUTABLE; + + // used only by Session + protected Operation() { + session = (Session)this; + group = (OperationGroup)this; + } - Operation(Connection conn, OperationGroup operationGroup) { - // passing null for connection and operationGroup is a hack. It is not - // possible to pass _this_ to a super constructor so we define null to mean - // _this_. Yuck. Only used by Connection. - connection = conn == null ? (Connection) this : conn; - group = operationGroup == null ? (OperationGroup) this : operationGroup; + Operation(Session session, OperationGroup operationGroup) { + this.session = session; + group = operationGroup; } @Override @@ -216,7 +219,7 @@ long getTimeoutMillis() { } protected Executor getExecutor() { - return connection.getExecutor(); + return session.getExecutor(); } /** diff --git a/java/AoJ/src/com/oracle/adbaoverjdbc/com/oracle/adbaoverjdbc/OperationGroup.java b/java/AoJ/src/com/oracle/adbaoverjdbc/com/oracle/adbaoverjdbc/OperationGroup.java index 4da94bbf..275c3821 100755 --- a/java/AoJ/src/com/oracle/adbaoverjdbc/com/oracle/adbaoverjdbc/OperationGroup.java +++ b/java/AoJ/src/com/oracle/adbaoverjdbc/com/oracle/adbaoverjdbc/OperationGroup.java @@ -20,7 +20,6 @@ import jdk.incubator.sql2.OutOperation; import jdk.incubator.sql2.ParameterizedRowOperation; import jdk.incubator.sql2.Submission; -import jdk.incubator.sql2.Transaction; import jdk.incubator.sql2.TransactionOutcome; import java.time.Duration; import java.util.concurrent.CompletableFuture; @@ -33,6 +32,7 @@ import jdk.incubator.sql2.ParameterizedRowCountOperation; import jdk.incubator.sql2.ParameterizedRowPublisherOperation; import jdk.incubator.sql2.ArrayRowCountOperation; +import jdk.incubator.sql2.TransactionEnd; /** * Only sequential, dependent, unconditional supported. @@ -77,8 +77,8 @@ class OperationGroup extends com.oracle.adbaoverjdbc.Operation (a, b) -> null, a -> null); - static OperationGroup newOperationGroup(Connection conn) { - return new OperationGroup(conn, conn); + static OperationGroup newOperationGroup(Session session) { + return new OperationGroup(session, session); } static final Logger NULL_LOGGER = Logger.getAnonymousLogger(); @@ -118,8 +118,17 @@ static OperationGroup newOperationGroup(Connection conn) { */ private CompletionStage memberTail; - protected OperationGroup(Connection conn, OperationGroup group) { - super(conn, group); + // used only by Session. Will break if used by any other class. + protected OperationGroup() { + super(); + held = new CompletableFuture(); + head = new CompletableFuture(); + memberTail = head; + collector = DEFAULT_COLLECTOR; + } + + protected OperationGroup(Session session, OperationGroup group) { + super(session, group); held = new CompletableFuture(); head = new CompletableFuture(); memberTail = head; @@ -174,7 +183,7 @@ public OperationGroup collect(Collector c) { @Override public Operation catchOperation() { if (! isHeld() ) throw new IllegalStateException("TODO"); - return UnskippableOperation.newOperation(connection, this, op -> null); + return UnskippableOperation.newOperation(session, this, op -> null); } @Override @@ -187,13 +196,13 @@ public ArrayRowCountOperation arrayRowCountOperation(String sql public ParameterizedRowCountOperation rowCountOperation(String sql) { if ( ! isHeld() ) throw new IllegalStateException("TODO"); if (sql == null) throw new IllegalArgumentException("TODO"); - return CountOperation.newCountOperation(connection, this, sql); + return CountOperation.newCountOperation(session, this, sql); } @Override public SqlOperation operation(String sql) { if ( !isHeld() ) throw new IllegalStateException("TODO"); - return SqlOperation.newOperation(connection, this, sql); + return SqlOperation.newOperation(session, this, sql); } @Override @@ -206,7 +215,7 @@ public OutOperation outOperation(String sql) { public ParameterizedRowOperation rowOperation(String sql) { if ( ! isHeld() ) throw new IllegalStateException("TODO"); if (sql == null) throw new IllegalArgumentException("TODO"); - return RowOperation.newRowOperation(connection, this, sql); + return RowOperation.newRowOperation(session, this, sql); } @Override @@ -222,12 +231,12 @@ public MultiOperation multiOperation(String sql) { } @Override - public SimpleOperation endTransactionOperation(Transaction trans) { + public SimpleOperation endTransactionOperation(TransactionEnd trans) { if ( ! isHeld() ) throw new IllegalStateException("TODO"); return com.oracle.adbaoverjdbc.SimpleOperation.newOperation( - connection, + session, (OperationGroup)this, - op -> connection.jdbcEndTransaction(op, (com.oracle.adbaoverjdbc.Transaction)trans)); + op -> session.jdbcEndTransaction(op, (com.oracle.adbaoverjdbc.TransactionEnd)trans)); } @Override diff --git a/java/AoJ/src/com/oracle/adbaoverjdbc/com/oracle/adbaoverjdbc/ParameterizedOperation.java b/java/AoJ/src/com/oracle/adbaoverjdbc/com/oracle/adbaoverjdbc/ParameterizedOperation.java index 11b256b3..a4497613 100755 --- a/java/AoJ/src/com/oracle/adbaoverjdbc/com/oracle/adbaoverjdbc/ParameterizedOperation.java +++ b/java/AoJ/src/com/oracle/adbaoverjdbc/com/oracle/adbaoverjdbc/ParameterizedOperation.java @@ -35,8 +35,8 @@ public abstract class ParameterizedOperation extends Operation protected final Map setParameters; protected CompletionStage futureParameters; - ParameterizedOperation(Connection conn, OperationGroup operationGroup) { - super(conn, operationGroup); + ParameterizedOperation(Session session, OperationGroup operationGroup) { + super(session, operationGroup); setParameters = new HashMap<>(); } diff --git a/java/AoJ/src/com/oracle/adbaoverjdbc/com/oracle/adbaoverjdbc/RowOperation.java b/java/AoJ/src/com/oracle/adbaoverjdbc/com/oracle/adbaoverjdbc/RowOperation.java index c422e7f0..2de3f296 100755 --- a/java/AoJ/src/com/oracle/adbaoverjdbc/com/oracle/adbaoverjdbc/RowOperation.java +++ b/java/AoJ/src/com/oracle/adbaoverjdbc/com/oracle/adbaoverjdbc/RowOperation.java @@ -49,8 +49,8 @@ class RowOperation extends ParameterizedOperation (a, v) -> {}, (a, b) -> null, a -> null); - static RowOperation newRowOperation(Connection conn, OperationGroup grp, String sql) { - return new RowOperation<>(conn, grp, sql); + static RowOperation newRowOperation(Session session, OperationGroup grp, String sql) { + return new RowOperation<>(session, grp, sql); } // attributes @@ -67,8 +67,8 @@ static RowOperation newRowOperation(Connection conn, OperationGroup grp, private long rowCount; private String[] identifiers; - protected RowOperation(Connection conn, OperationGroup grp, String sql) { - super(conn, grp); + protected RowOperation(Session session, OperationGroup grp, String sql) { + super(session, grp); fetchSize = NOT_SET; collector = DEFAULT_COLLECTOR; sqlString = sql; @@ -126,7 +126,7 @@ private void initFetchSize() throws SQLException { private void executeQuery() { checkCanceled(); try { - jdbcStatement = connection.prepareStatement(sqlString); + jdbcStatement = session.prepareStatement(sqlString); initFetchSize(); setParameters.forEach((String k, ParameterValue v) -> { v.set(jdbcStatement, k); diff --git a/java/AoJ/src/com/oracle/adbaoverjdbc/com/oracle/adbaoverjdbc/Session.java b/java/AoJ/src/com/oracle/adbaoverjdbc/com/oracle/adbaoverjdbc/Session.java new file mode 100755 index 00000000..d165492a --- /dev/null +++ b/java/AoJ/src/com/oracle/adbaoverjdbc/com/oracle/adbaoverjdbc/Session.java @@ -0,0 +1,355 @@ +/* + * Copyright (c) 2018 Oracle and/or its affiliates. All rights reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.oracle.adbaoverjdbc; + +import jdk.incubator.sql2.AdbaSessionProperty; +import jdk.incubator.sql2.Session.Lifecycle; +import jdk.incubator.sql2.SessionProperty; +import jdk.incubator.sql2.Operation; +import jdk.incubator.sql2.ParameterizedRowPublisherOperation; +import jdk.incubator.sql2.ShardingKey; +import jdk.incubator.sql2.SqlException; +import jdk.incubator.sql2.TransactionOutcome; +import java.sql.DriverManager; +import java.sql.PreparedStatement; +import java.sql.SQLException; +import java.util.HashMap; +import java.util.HashSet; +import java.util.Map; +import java.util.Properties; +import java.util.Set; +import java.util.concurrent.CompletableFuture; +import java.util.concurrent.CompletionStage; +import java.util.concurrent.Executor; +import java.util.function.LongConsumer; +import java.util.logging.Level; + +/** + * Session is a subclass of OperationGroup. The member Operation stuff is mostly + * inherited from OperationGroup. There are a couple of differences. First the + * predecessor for all Sessions is an already completed CompletableFuture, + * ROOT. Since ROOT is completed a Session will begin executing as soon as it + * is submitted. Second, a Session is not really a member of an OperationGroup + * so the code that handles submitting the Session is a little different from + * OperationGroup. + * + * A Session is also contains a java.sql.Session and has methods to execute + * some JDBC actions. It might be a good idea to move the java.sql.Session and + * associated actions to a separate class. + */ +class Session extends OperationGroup implements jdk.incubator.sql2.Session { + + // STATIC + protected static final CompletionStage ROOT = CompletableFuture.completedFuture(null); + + static jdk.incubator.sql2.Session newSession(DataSource ds, + Map properties) { + return new Session(ds, properties); + } + + // FIELDS + private Lifecycle sessionLifecycle = Lifecycle.NEW; + private final Set lifecycleListeners; + private final DataSource dataSource; + private final Map properties; + + private java.sql.Connection jdbcConnection; + + private final Executor executor; + private CompletableFuture sessionCF; + + // CONSTRUCTORS + private Session(DataSource ds, + Map properties) { + super(); + this.lifecycleListeners = new HashSet<>(); + dataSource = ds; + this.properties = properties; + SessionProperty execProp = AdbaSessionProperty.EXECUTOR; + executor = (Executor) properties.getOrDefault(execProp, execProp.defaultValue()); + } + + // PUBLIC + @Override + public Operation attachOperation() { + if (! isHeld()) { + throw new IllegalStateException("TODO"); + } + return com.oracle.adbaoverjdbc.SimpleOperation.newOperation(this, this, this::jdbcConnect); + } + + @Override + public Operation validationOperation(Validation depth) { + if (! isHeld()) { + throw new IllegalStateException("TODO"); + } + return com.oracle.adbaoverjdbc.SimpleOperation.newOperation(this, this, op -> jdbcValidate(op, depth)); + } + + @Override + public Operation closeOperation() { + if (! isHeld()) { + throw new IllegalStateException("TODO"); + } + return com.oracle.adbaoverjdbc.UnskippableOperation.newOperation(this, this, this::jdbcClose); //TODO cannot be skipped + } + + @Override + public jdk.incubator.sql2.OperationGroup operationGroup() { + if (!isHeld()) { + throw new IllegalStateException("TODO"); + } + throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. + } + + @Override + public TransactionEnd transactionEnd() { + if (! isHeld()) { + throw new IllegalStateException("TODO"); + } + return TransactionEnd.createTransaction(this); + } + + @Override + public Session registerLifecycleListener(SessionLifecycleListener listener) { + if (!sessionLifecycle.isActive()) { + throw new IllegalStateException("TODO"); + } + lifecycleListeners.add(listener); + return this; + } + + @Override + public Session deregisterLifecycleListener(SessionLifecycleListener listener) { + if (!sessionLifecycle.isActive()) { + throw new IllegalStateException("TODO"); + } + lifecycleListeners.remove(listener); + return this; + } + + @Override + public Lifecycle getSessionLifecycle() { + return sessionLifecycle; + } + + @Override + public jdk.incubator.sql2.Session abort() { + setLifecycle(sessionLifecycle.abort()); + this.closeImmediate(); + return this; + } + + @Override + public Map getProperties() { + Map map = new HashMap<>(properties.size()); + properties.forEach((k, v) -> { + if (!k.isSensitive()) { + map.put(k, v); + } + }); + return map; + } + + @Override + public ShardingKey.Builder shardingKeyBuilder() { + throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. + } + + @Override + public jdk.incubator.sql2.Session requestHook(LongConsumer request) { + throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. + } + + @Override + public jdk.incubator.sql2.Session activate() { + setLifecycle(sessionLifecycle.activate()); + throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. + } + + @Override + public jdk.incubator.sql2.Session deactivate() { + setLifecycle(sessionLifecycle.deactivate()); + throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. + } + + + + + // INTERNAL + protected Session setLifecycle(Lifecycle next) { + Lifecycle previous = sessionLifecycle; + sessionLifecycle = next; + if (previous != next) { + lifecycleListeners.stream().forEach(l -> l.lifecycleEvent(this, previous, next)); + } + return this; + } + + Session closeImmediate() { + try { + if (jdbcConnection != null && !jdbcConnection.isClosed()) { + setLifecycle(sessionLifecycle.abort()); + jdbcConnection.abort(executor); // Session.abort is not supposed to hang + //TODO should call sessionLifecycle.close() when abort completes. + } + } + catch (SQLException ex) { + throw new SqlException(ex.getMessage(), ex, ex.getSQLState(), ex.getErrorCode(), null, -1); + } + finally { + dataSource.deregisterSession(this); + } + return this; + } + + @Override + protected Executor getExecutor() { + return executor; + } + + @Override + jdk.incubator.sql2.Submission submit(com.oracle.adbaoverjdbc.Operation op) { + if (op == this) { + // submitting the Session OperationGroup + sessionCF = (CompletableFuture)attachErrorHandler(op.follows(ROOT, getExecutor())); + return com.oracle.adbaoverjdbc.Submission.submit(this::cancel, sessionCF); + } + else { + return super.submit(op); + } + } + + protected V sessionPropertyValue(SessionProperty prop) { + V value = (V)properties.get(prop); + if (value == null) return (V)prop.defaultValue(); + else return value; + } + + + + + // JDBC operations. These are all blocking + + private Void jdbcConnect(com.oracle.adbaoverjdbc.Operation op) { + try { + Properties info = (Properties)properties.get(JdbcConnectionProperties.JDBC_CONNECTION_PROPERTIES); + info = (Properties)(info == null ? JdbcConnectionProperties.JDBC_CONNECTION_PROPERTIES.defaultValue() + : info.clone()); + info.setProperty("user", (String) properties.get(AdbaSessionProperty.USER)); + info.setProperty("password", (String) properties.get(AdbaSessionProperty.PASSWORD)); + String url = (String) properties.get(AdbaSessionProperty.URL); + Properties p = info; + group.logger.log(Level.FINE, () -> "DriverManager.getSession(\"" + url + "\", " + p +")"); + jdbcConnection = DriverManager.getConnection(url, info); + jdbcConnection.setAutoCommit(false); + setLifecycle(Session.Lifecycle.OPEN); + return null; + } + catch (SQLException ex) { + throw new SqlException(ex.getMessage(), ex, ex.getSQLState(), ex.getErrorCode(), null, -1); + } + } + + private Void jdbcValidate(com.oracle.adbaoverjdbc.Operation op, + Validation depth) { + try { + switch (depth) { + case COMPLETE: + case SERVER: + int timeoutSeconds = (int) (op.getTimeoutMillis() / 1000L); + group.logger.log(Level.FINE, () -> "Session.isValid(" + timeoutSeconds + ")"); //DEBUG + if (!jdbcConnection.isValid(timeoutSeconds)) { + throw new SqlException("validation failure", null, null, -1, null, -1); + } + break; + case NETWORK: + case SOCKET: + case LOCAL: + case NONE: + group.logger.log(Level.FINE, () -> "Session.isClosed"); //DEBUG + if (jdbcConnection.isClosed()) { + throw new SqlException("validation failure", null, null, -1, null, -1); + } + } + return null; + } + catch (SQLException ex) { + throw new SqlException(ex.getMessage(), ex, ex.getSQLState(), ex.getErrorCode(), null, -1); + } + } + + + protected T jdbcExecute(com.oracle.adbaoverjdbc.Operation op, String sql) { + try (java.sql.Statement stmt = jdbcConnection.createStatement()) { + int timeoutSeconds = (int) (op.getTimeoutMillis() / 1000L); + if (timeoutSeconds < 0) stmt.setQueryTimeout(timeoutSeconds); + group.logger.log(Level.FINE, () -> "Statement.execute(\"" + sql + "\")"); //DEBUG + stmt.execute(sql); + } + catch (SQLException ex) { + throw new SqlException(ex.getMessage(), ex, ex.getSQLState(), ex.getErrorCode(), sql, -1); + } + return null; + } + + private Void jdbcClose(com.oracle.adbaoverjdbc.Operation op) { + try { + setLifecycle(sessionLifecycle.close()); + if (jdbcConnection != null) { + group.logger.log(Level.FINE, () -> "Session.close"); //DEBUG + jdbcConnection.close(); + } + } + catch (SQLException ex) { + throw new SqlException(ex.getMessage(), ex, ex.getSQLState(), ex.getErrorCode(), null, -1); + } + finally { + closeImmediate(); + setLifecycle(sessionLifecycle.closed()); + } + return null; + } + + PreparedStatement prepareStatement(String sqlString) throws SQLException { + logger.log(Level.FINE, () -> "Session.prepareStatement(\"" + sqlString + "\")"); //DEBUG + return jdbcConnection.prepareStatement(sqlString); + } + + TransactionOutcome jdbcEndTransaction(SimpleOperation op, TransactionEnd trans) { + try { + if (trans.endWithCommit(this)) { + group.logger.log(Level.FINE, () -> "commit"); //DEBUG + jdbcConnection.commit(); + return TransactionOutcome.COMMIT; + } + else { + group.logger.log(Level.FINE, () -> "rollback"); //DEBUG + jdbcConnection.rollback(); + return TransactionOutcome.ROLLBACK; + } + } + catch (SQLException ex) { + throw new SqlException(ex.getMessage(), ex, ex.getSQLState(), ex.getErrorCode(), null, -1); + } + } + + @Override + public ParameterizedRowPublisherOperation rowPublisherOperation(String sql) { + throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. + } + +} diff --git a/java/AoJ/src/com/oracle/adbaoverjdbc/com/oracle/adbaoverjdbc/SessionBuilder.java b/java/AoJ/src/com/oracle/adbaoverjdbc/com/oracle/adbaoverjdbc/SessionBuilder.java new file mode 100755 index 00000000..ed3b3063 --- /dev/null +++ b/java/AoJ/src/com/oracle/adbaoverjdbc/com/oracle/adbaoverjdbc/SessionBuilder.java @@ -0,0 +1,100 @@ +/* + * Copyright (c) 2018 Oracle and/or its affiliates. All rights reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.oracle.adbaoverjdbc; + +import jdk.incubator.sql2.SessionProperty; +import java.util.HashMap; +import java.util.Map; + +/** + * A builder to create an AoJ session. The AoJ session creates a JDBC + * Connection by calling {@link java.sql.DriverManager#getConnection} with the following + * user provided SessionProperty values: + * + *
+ *
URL
+ *
passed as the url argument to getSession
+ *
USER
+ *
added to the JDBC_CONNECTION_PROPERTIES as the "user" property.
+ *
PASSWORD
+ *
added to the JDBC_CONNECTION_PROPERTIES as the "password" property
+ *
JDBC_CONNECTION_PROPERTIES
+ *
a java.util.Properties passed as the info argument to getConnection
+ *
+ */ +class SessionBuilder implements jdk.incubator.sql2.Session.Builder { + + /** + * + * @param ds + * @param defaultProperties. Captured + * @param requiredProperties. Captured + * @return + */ + static SessionBuilder newSessionBuilder(DataSource ds, + Map defaultProperties, + Map requiredProperties) { + return new SessionBuilder(ds, defaultProperties, requiredProperties); + } + + private boolean isBuilt = false; + private final DataSource dataSource; + private final Map defaultProperties; + private final Map requiredProperties; + + /** + * + * @param ds + * @param defaultSessionProperties + * @param specifiedSessionProperties + */ + private SessionBuilder(DataSource ds, + Map defaultSessionProperties, + Map specifiedSessionProperties) { + super(); + dataSource = ds; + defaultProperties = new HashMap(defaultSessionProperties); + requiredProperties = new HashMap(specifiedSessionProperties); + } + + @Override + public jdk.incubator.sql2.Session.Builder property(SessionProperty property, Object value) { + if (isBuilt) { + throw new IllegalStateException("TODO"); + } + if (requiredProperties.containsKey(property)) { + throw new IllegalArgumentException("cannot override required properties"); + } + if (!property.validate(value)) { + throw new IllegalArgumentException("TODO"); + } + requiredProperties.put(property, value); + return this; + } + + @Override + public jdk.incubator.sql2.Session build() { + if (isBuilt) { + throw new IllegalStateException("TODO"); + } + isBuilt = true; + // replace default values with specified values where provided + // otherwise use defaults + defaultProperties.putAll(requiredProperties); + return Session.newSession(dataSource, defaultProperties); + } + +} diff --git a/java/AoJ/src/com/oracle/adbaoverjdbc/com/oracle/adbaoverjdbc/SimpleOperation.java b/java/AoJ/src/com/oracle/adbaoverjdbc/com/oracle/adbaoverjdbc/SimpleOperation.java index 64df935d..61cbc8e0 100755 --- a/java/AoJ/src/com/oracle/adbaoverjdbc/com/oracle/adbaoverjdbc/SimpleOperation.java +++ b/java/AoJ/src/com/oracle/adbaoverjdbc/com/oracle/adbaoverjdbc/SimpleOperation.java @@ -27,18 +27,18 @@ */ class SimpleOperation extends Operation implements Supplier { - static SimpleOperation newOperation(Connection conn, + static SimpleOperation newOperation(Session session, OperationGroup group, Function, S> act) { - return new SimpleOperation<>(conn, group, act); + return new SimpleOperation<>(session, group, act); } private final Function, T> action; - protected SimpleOperation(Connection conn, + protected SimpleOperation(Session session, OperationGroup operationGroup, Function, T> act) { - super(conn, operationGroup); + super(session, operationGroup); action = act; } diff --git a/java/AoJ/src/com/oracle/adbaoverjdbc/com/oracle/adbaoverjdbc/SqlOperation.java b/java/AoJ/src/com/oracle/adbaoverjdbc/com/oracle/adbaoverjdbc/SqlOperation.java index a606fbea..c27ba4cd 100755 --- a/java/AoJ/src/com/oracle/adbaoverjdbc/com/oracle/adbaoverjdbc/SqlOperation.java +++ b/java/AoJ/src/com/oracle/adbaoverjdbc/com/oracle/adbaoverjdbc/SqlOperation.java @@ -20,11 +20,11 @@ */ class SqlOperation extends SimpleOperation { - static SqlOperation newOperation(Connection conn, OperationGroup group, String sql) { - return new SqlOperation<>(conn, group, sql); + static SqlOperation newOperation(Session session, OperationGroup group, String sql) { + return new SqlOperation<>(session, group, sql); } - protected SqlOperation(Connection conn, OperationGroup group, String sql) { - super(conn, group, op -> (T)conn.jdbcExecute(op, sql)); + protected SqlOperation(Session session, OperationGroup group, String sql) { + super(session, group, op -> (T)session.jdbcExecute(op, sql)); } } diff --git a/java/AoJ/src/com/oracle/adbaoverjdbc/com/oracle/adbaoverjdbc/TransactionEnd.java b/java/AoJ/src/com/oracle/adbaoverjdbc/com/oracle/adbaoverjdbc/TransactionEnd.java new file mode 100755 index 00000000..ddc8c0a6 --- /dev/null +++ b/java/AoJ/src/com/oracle/adbaoverjdbc/com/oracle/adbaoverjdbc/TransactionEnd.java @@ -0,0 +1,64 @@ +/* + * Copyright (c) 2018 Oracle and/or its affiliates. All rights reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.oracle.adbaoverjdbc; + +/** + * + */ +class TransactionEnd implements jdk.incubator.sql2.TransactionEnd { + + private boolean isRollbackOnly = false; + private boolean isInFlight = true; + private final Session session; + + static TransactionEnd createTransaction(Session session) { + return new TransactionEnd(session); + } + + private TransactionEnd(Session session) { + this.session = session; + } + + /** + * + * @param session + * @return true iff transaction should be committed. false otherwise + */ + synchronized boolean endWithCommit(Session session) { + if (session != session) throw new IllegalArgumentException("TODO"); + if (!isInFlight) throw new IllegalStateException("TODO"); + isInFlight = false; + return !isRollbackOnly; + } + + @Override + public synchronized boolean setRollbackOnly() { + if (!session.getSessionLifecycle().isActive()) throw new IllegalStateException("TODO"); + if (isInFlight) { + isRollbackOnly = true; + return true; + } + else { + return false; + } + } + + @Override + public boolean isRollbackOnly() { + return isRollbackOnly; + } + +} diff --git a/java/AoJ/src/com/oracle/adbaoverjdbc/com/oracle/adbaoverjdbc/UnskippableOperation.java b/java/AoJ/src/com/oracle/adbaoverjdbc/com/oracle/adbaoverjdbc/UnskippableOperation.java index c56765be..73f43137 100755 --- a/java/AoJ/src/com/oracle/adbaoverjdbc/com/oracle/adbaoverjdbc/UnskippableOperation.java +++ b/java/AoJ/src/com/oracle/adbaoverjdbc/com/oracle/adbaoverjdbc/UnskippableOperation.java @@ -24,16 +24,16 @@ */ class UnskippableOperation extends SimpleOperation { - static UnskippableOperation newOperation(Connection conn, + static UnskippableOperation newOperation(Session session, OperationGroup group, Function, S> action) { - return new UnskippableOperation<>(conn, group, action); + return new UnskippableOperation<>(session, group, action); } - protected UnskippableOperation(Connection conn, + protected UnskippableOperation(Session session, OperationGroup operationGroup, Function, T> action) { - super(conn, operationGroup, (Function, T>)action); + super(session, operationGroup, (Function, T>)action); } @Override From 0b03f0fb2d8c474b11e794460b29f369a9de0015 Mon Sep 17 00:00:00 2001 From: Kuassim Date: Wed, 11 Jul 2018 16:08:56 -0700 Subject: [PATCH 14/16] Updates to AoJ to reflect the changes in ADBA --- java/AoJ/src/README.md | 22 +- .../com/oracle/adbaoverjdbc/Connection.java | 355 ------------------ .../adbaoverjdbc/ConnectionBuilder.java | 100 ----- .../oracle/adbaoverjdbc/OperationGroup.java | 6 +- .../com/oracle/adbaoverjdbc/Session.java | 6 +- .../com/oracle/adbaoverjdbc/Transaction.java | 64 ---- .../oracle/adbaoverjdbc/TransactionEnd.java | 8 +- 7 files changed, 26 insertions(+), 535 deletions(-) mode change 100755 => 100644 java/AoJ/src/README.md delete mode 100755 java/AoJ/src/com/oracle/adbaoverjdbc/com/oracle/adbaoverjdbc/Connection.java delete mode 100755 java/AoJ/src/com/oracle/adbaoverjdbc/com/oracle/adbaoverjdbc/ConnectionBuilder.java delete mode 100755 java/AoJ/src/com/oracle/adbaoverjdbc/com/oracle/adbaoverjdbc/Transaction.java diff --git a/java/AoJ/src/README.md b/java/AoJ/src/README.md old mode 100755 new mode 100644 index 155341c1..82daef08 --- a/java/AoJ/src/README.md +++ b/java/AoJ/src/README.md @@ -36,8 +36,15 @@ better to get it to the community as soon as we could. We hope that you agree. ## Building AoJ AoJ and ADBA require JDK 9 or later. Download ADBA from the -[OpenJDK sandbox](http://hg.openjdk.java.net/jdk/sandbox/file/9d3b0eb749a9/src/jdk.incubator.adba). -It does not have any dependencies outside of Java SE. Download AoJ from +[OpenJDK sandbox](http://hg.openjdk.java.net/jdk/sandbox/file/JDK-8188051-branch/src/jdk.incubator.adba/share/classes). It does not have any dependencies outside of Java SE. + +For building the API modules: +``` +$ mkdir -p mods/jdk.incubator.adba +$ javac -d mods/jdk.incubator.adba/ $(find jdk.incubator.adba -name "*.java") +$ jar --create --file=mlib/jdk.incubator.adba.jar --module-version=1.0 -C mods/jdk.incubator.adba/ . +```` +Download AoJ from [GitHub](https://github.com/oracle/oracle-db-examples/tree/master/java/AoJ). Both are modularized so be sure to include the module-info.java files. AoJ depends on ADBA. The AoJ sample file depends on JUnit which is included with most IDEs but is @@ -63,8 +70,8 @@ run with any JDBC driver connecting to a database with the scott schema. This is the last test in ```com.oracle.adbaoverjdbc.test.FirstLight.java```. For an introduction to ADBA see the [JavaOne 2017 presentation](http://www.oracle.com/technetwork/database/application-development/jdbc/con1491-3961036.pdf). -``` - public void transactionSample() { + +```public void transactionSample() { // get the AoJ DataSourceFactory DataSourceFactory factory = DataSourceFactory.forName("com.oracle.adbaoverjdbc.DataSourceFactory"); // get a DataSource and a Connection @@ -106,12 +113,15 @@ introduction to ADBA see the [JavaOne 2017 presentation](http://www.oracle.com/t } // wait for the async tasks to complete before exiting ForkJoinPool.commonPool().awaitQuiescence(1, TimeUnit.MINUTES); - }``` + } +``` + +The following new sample code have been added: HellowWorld.java and NewEmptyJUnitTest.java. ## AoJ Design Spec in 100 words or less The methods called by the user thread create a network -([DAG](https://en.wikipedia.org/wiki/Directed_acyclic_graph)) of +(i.e., [DAG](https://en.wikipedia.org/wiki/Directed_acyclic_graph)) of ```CompletableFuture```s. These ```CompleteableFuture```s asynchronously execute the synchronous JDBC calls and the result processing code provided by the user code. By default AoJ uses ```ForkJoinPool.commonPool()``` to execute diff --git a/java/AoJ/src/com/oracle/adbaoverjdbc/com/oracle/adbaoverjdbc/Connection.java b/java/AoJ/src/com/oracle/adbaoverjdbc/com/oracle/adbaoverjdbc/Connection.java deleted file mode 100755 index 3c588d15..00000000 --- a/java/AoJ/src/com/oracle/adbaoverjdbc/com/oracle/adbaoverjdbc/Connection.java +++ /dev/null @@ -1,355 +0,0 @@ -/* - * Copyright (c) 2018 Oracle and/or its affiliates. All rights reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.oracle.adbaoverjdbc; - -import jdk.incubator.sql2.AdbaConnectionProperty; -import jdk.incubator.sql2.Connection.Lifecycle; -import jdk.incubator.sql2.ConnectionProperty; -import jdk.incubator.sql2.Operation; -import jdk.incubator.sql2.ShardingKey; -import jdk.incubator.sql2.SqlException; -import jdk.incubator.sql2.TransactionOutcome; -import java.sql.DriverManager; -import java.sql.PreparedStatement; -import java.sql.SQLException; -import java.util.HashMap; -import java.util.HashSet; -import java.util.Map; -import java.util.Properties; -import java.util.Set; -import java.util.concurrent.CompletableFuture; -import java.util.concurrent.CompletionStage; -import java.util.concurrent.Executor; -import java.util.function.Consumer; -import java.util.logging.Level; -import jdk.incubator.sql2.ParameterizedRowPublisherOperation; - -/** - * Connection is a subclass of OperationGroup. The member Operation stuff is mostly - * inherited from OperationGroup. There are a couple of differences. First the - * predecessor for all Connections is an already completed CompletableFuture, - * ROOT. Since ROOT is completed a Connection will begin executing as soon as it - * is submitted. Second, a Connection is not really a member of an OperationGroup - * so the code that handles submitting the Connection is a little different from - * OperationGroup. - * - * A Connection is also contains a java.sql.Connection and has methods to execute - * some JDBC actions. It might be a good idea to move the java.sql.Connection and - * associated actions to a separate class. - */ -class Connection extends OperationGroup implements jdk.incubator.sql2.Connection { - - // STATIC - protected static final CompletionStage ROOT = CompletableFuture.completedFuture(null); - - static jdk.incubator.sql2.Connection newConnection(DataSource ds, - Map properties) { - return new Connection(ds, properties); - } - - // FIELDS - private Lifecycle connectionLifecycle = Lifecycle.NEW; - private final Set lifecycleListeners; - private final DataSource dataSource; - private final Map properties; - - private java.sql.Connection jdbcConnection; - - private final Executor executor; - private CompletableFuture connectionCF; - - // CONSTRUCTORS - private Connection(DataSource ds, - Map properties) { - super(null, null); // hack as _this_ not allowed. See SimpleOperation constructor - this.lifecycleListeners = new HashSet<>(); - dataSource = ds; - this.properties = properties; - ConnectionProperty execProp = AdbaConnectionProperty.EXECUTOR; - executor = (Executor) properties.getOrDefault(execProp, execProp.defaultValue()); - } - - // PUBLIC - @Override - public Operation connectOperation() { - if (! isHeld()) { - throw new IllegalStateException("TODO"); - } - return com.oracle.adbaoverjdbc.SimpleOperation.newOperation(this, this, this::jdbcConnect); - } - - @Override - public Operation validationOperation(Validation depth) { - if (! isHeld()) { - throw new IllegalStateException("TODO"); - } - return com.oracle.adbaoverjdbc.SimpleOperation.newOperation(this, this, op -> jdbcValidate(op, depth)); - } - - @Override - public Operation closeOperation() { - if (! isHeld()) { - throw new IllegalStateException("TODO"); - } - return com.oracle.adbaoverjdbc.UnskippableOperation.newOperation(this, this, this::jdbcClose); //TODO cannot be skipped - } - - @Override - public jdk.incubator.sql2.OperationGroup operationGroup() { - if (!isHeld()) { - throw new IllegalStateException("TODO"); - } - throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. - } - - @Override - public Transaction transaction() { - if (! isHeld()) { - throw new IllegalStateException("TODO"); - } - return Transaction.createTransaction(this); - } - - @Override - public Connection registerLifecycleListener(ConnectionLifecycleListener listener) { - if (!connectionLifecycle.isActive()) { - throw new IllegalStateException("TODO"); - } - lifecycleListeners.add(listener); - return this; - } - - @Override - public Connection deregisterLifecycleListener(ConnectionLifecycleListener listener) { - if (!connectionLifecycle.isActive()) { - throw new IllegalStateException("TODO"); - } - lifecycleListeners.remove(listener); - return this; - } - - @Override - public Lifecycle getConnectionLifecycle() { - return connectionLifecycle; - } - - @Override - public jdk.incubator.sql2.Connection abort() { - setLifecycle(connectionLifecycle.abort()); - this.closeImmediate(); - return this; - } - - @Override - public Map getProperties() { - Map map = new HashMap<>(properties.size()); - properties.forEach((k, v) -> { - if (!k.isSensitive()) { - map.put(k, v); - } - }); - return map; - } - - @Override - public ShardingKey.Builder shardingKeyBuilder() { - throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. - } - - @Override - public jdk.incubator.sql2.Connection requestHook(Consumer request) { - throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. - } - - @Override - public jdk.incubator.sql2.Connection activate() { - setLifecycle(connectionLifecycle.activate()); - throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. - } - - @Override - public jdk.incubator.sql2.Connection deactivate() { - setLifecycle(connectionLifecycle.deactivate()); - throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. - } - - - - - // INTERNAL - protected Connection setLifecycle(Lifecycle next) { - Lifecycle previous = connectionLifecycle; - connectionLifecycle = next; - if (previous != next) { - lifecycleListeners.stream().forEach(l -> l.lifecycleEvent(this, previous, next)); - } - return this; - } - - Connection closeImmediate() { - try { - if (jdbcConnection != null && !jdbcConnection.isClosed()) { - setLifecycle(connectionLifecycle.abort()); - jdbcConnection.abort(executor); // Connection.abort is not supposed to hang - //TODO should call connectionLifecycle.close() when abort completes. - } - } - catch (SQLException ex) { - throw new SqlException(ex.getMessage(), ex, ex.getSQLState(), ex.getErrorCode(), null, -1); - } - finally { - dataSource.deregisterConnection(this); - } - return this; - } - - @Override - protected Executor getExecutor() { - return executor; - } - - @Override - jdk.incubator.sql2.Submission submit(com.oracle.adbaoverjdbc.Operation op) { - if (op == this) { - // submitting the Connection OperationGroup - connectionCF = (CompletableFuture)attachErrorHandler(op.follows(ROOT, getExecutor())); - return com.oracle.adbaoverjdbc.Submission.submit(this::cancel, connectionCF); - } - else { - return super.submit(op); - } - } - - protected V connectionPropertyValue(ConnectionProperty prop) { - V value = (V)properties.get(prop); - if (value == null) return (V)prop.defaultValue(); - else return value; - } - - - - - // JDBC operations. These are all blocking - - private Void jdbcConnect(com.oracle.adbaoverjdbc.Operation op) { - try { - Properties info = (Properties)properties.get(JdbcConnectionProperties.JDBC_CONNECTION_PROPERTIES); - info = (Properties)(info == null ? JdbcConnectionProperties.JDBC_CONNECTION_PROPERTIES.defaultValue() - : info.clone()); - info.setProperty("user", (String) properties.get(AdbaConnectionProperty.USER)); - info.setProperty("password", (String) properties.get(AdbaConnectionProperty.PASSWORD)); - String url = (String) properties.get(AdbaConnectionProperty.URL); - Properties p = info; - group.logger.log(Level.FINE, () -> "DriverManager.getConnection(\"" + url + "\", " + p +")"); - jdbcConnection = DriverManager.getConnection(url, info); - jdbcConnection.setAutoCommit(false); - setLifecycle(Connection.Lifecycle.OPEN); - return null; - } - catch (SQLException ex) { - throw new SqlException(ex.getMessage(), ex, ex.getSQLState(), ex.getErrorCode(), null, -1); - } - } - - private Void jdbcValidate(com.oracle.adbaoverjdbc.Operation op, - Validation depth) { - try { - switch (depth) { - case COMPLETE: - case SERVER: - int timeoutSeconds = (int) (op.getTimeoutMillis() / 1000L); - group.logger.log(Level.FINE, () -> "Connection.isValid(" + timeoutSeconds + ")"); //DEBUG - if (!jdbcConnection.isValid(timeoutSeconds)) { - throw new SqlException("validation failure", null, null, -1, null, -1); - } - break; - case NETWORK: - case SOCKET: - case LOCAL: - case NONE: - group.logger.log(Level.FINE, () -> "Connection.isClosed"); //DEBUG - if (jdbcConnection.isClosed()) { - throw new SqlException("validation failure", null, null, -1, null, -1); - } - } - return null; - } - catch (SQLException ex) { - throw new SqlException(ex.getMessage(), ex, ex.getSQLState(), ex.getErrorCode(), null, -1); - } - } - - - protected T jdbcExecute(com.oracle.adbaoverjdbc.Operation op, String sql) { - try (java.sql.Statement stmt = jdbcConnection.createStatement()) { - int timeoutSeconds = (int) (op.getTimeoutMillis() / 1000L); - if (timeoutSeconds < 0) stmt.setQueryTimeout(timeoutSeconds); - group.logger.log(Level.FINE, () -> "Statement.execute(\"" + sql + "\")"); //DEBUG - stmt.execute(sql); - } - catch (SQLException ex) { - throw new SqlException(ex.getMessage(), ex, ex.getSQLState(), ex.getErrorCode(), sql, -1); - } - return null; - } - - private Void jdbcClose(com.oracle.adbaoverjdbc.Operation op) { - try { - setLifecycle(connectionLifecycle.close()); - if (jdbcConnection != null) { - group.logger.log(Level.FINE, () -> "Connection.close"); //DEBUG - jdbcConnection.close(); - } - } - catch (SQLException ex) { - throw new SqlException(ex.getMessage(), ex, ex.getSQLState(), ex.getErrorCode(), null, -1); - } - finally { - closeImmediate(); - setLifecycle(connectionLifecycle.closed()); - } - return null; - } - - PreparedStatement prepareStatement(String sqlString) throws SQLException { - logger.log(Level.FINE, () -> "Connection.prepareStatement(\"" + sqlString + "\")"); //DEBUG - return jdbcConnection.prepareStatement(sqlString); - } - - TransactionOutcome jdbcEndTransaction(SimpleOperation op, Transaction trans) { - try { - if (trans.endWithCommit(this)) { - group.logger.log(Level.FINE, () -> "commit"); //DEBUG - jdbcConnection.commit(); - return TransactionOutcome.COMMIT; - } - else { - group.logger.log(Level.FINE, () -> "rollback"); //DEBUG - jdbcConnection.rollback(); - return TransactionOutcome.ROLLBACK; - } - } - catch (SQLException ex) { - throw new SqlException(ex.getMessage(), ex, ex.getSQLState(), ex.getErrorCode(), null, -1); - } - } - - @Override - public ParameterizedRowPublisherOperation rowPublisherOperation(String sql) { - throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. - } - -} diff --git a/java/AoJ/src/com/oracle/adbaoverjdbc/com/oracle/adbaoverjdbc/ConnectionBuilder.java b/java/AoJ/src/com/oracle/adbaoverjdbc/com/oracle/adbaoverjdbc/ConnectionBuilder.java deleted file mode 100755 index 639fe58c..00000000 --- a/java/AoJ/src/com/oracle/adbaoverjdbc/com/oracle/adbaoverjdbc/ConnectionBuilder.java +++ /dev/null @@ -1,100 +0,0 @@ -/* - * Copyright (c) 2018 Oracle and/or its affiliates. All rights reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.oracle.adbaoverjdbc; - -import jdk.incubator.sql2.ConnectionProperty; -import java.util.HashMap; -import java.util.Map; - -/** - * A builder to create an AoJ connection. The AoJ connection creates a JDBC - * connection by calling java.sql.DriverManager.getConnection with the following - * user provided ConnectionProperty values: - * - *
- *
URL
- *
passed as the url argument to getConnection
- *
USER
- *
added to the JDBC_CONNECTION_PROPERTIES as the "user" property.
- *
PASSWORD
- *
added to the JDBC_CONNECTION_PROPERTIES as the "password" property
- *
JDBC_CONNECTION_PROPERTIES
- *
a java.util.Properties passed as the info argument to getConnection
- *
- */ -class ConnectionBuilder implements jdk.incubator.sql2.Connection.Builder { - - /** - * - * @param ds - * @param defaultProperties. Captured - * @param requiredProperties. Captured - * @return - */ - static ConnectionBuilder newConnectionBuilder(DataSource ds, - Map defaultProperties, - Map requiredProperties) { - return new ConnectionBuilder(ds, defaultProperties, requiredProperties); - } - - private boolean isBuilt = false; - private final DataSource dataSource; - private final Map defaultProperties; - private final Map requiredProperties; - - /** - * - * @param ds - * @param defaultConnectionProperties - * @param specifiedConnectionProperties - */ - private ConnectionBuilder(DataSource ds, - Map defaultConnectionProperties, - Map specifiedConnectionProperties) { - super(); - dataSource = ds; - defaultProperties = new HashMap(defaultConnectionProperties); - requiredProperties = new HashMap(specifiedConnectionProperties); - } - - @Override - public jdk.incubator.sql2.Connection.Builder property(ConnectionProperty property, Object value) { - if (isBuilt) { - throw new IllegalStateException("TODO"); - } - if (requiredProperties.containsKey(property)) { - throw new IllegalArgumentException("cannot override required properties"); - } - if (!property.validate(value)) { - throw new IllegalArgumentException("TODO"); - } - requiredProperties.put(property, value); - return this; - } - - @Override - public jdk.incubator.sql2.Connection build() { - if (isBuilt) { - throw new IllegalStateException("TODO"); - } - isBuilt = true; - // replace default values with specified values where provided - // otherwise use defaults - defaultProperties.putAll(requiredProperties); - return Connection.newConnection(dataSource, defaultProperties); - } - -} diff --git a/java/AoJ/src/com/oracle/adbaoverjdbc/com/oracle/adbaoverjdbc/OperationGroup.java b/java/AoJ/src/com/oracle/adbaoverjdbc/com/oracle/adbaoverjdbc/OperationGroup.java index 275c3821..4ac53e78 100755 --- a/java/AoJ/src/com/oracle/adbaoverjdbc/com/oracle/adbaoverjdbc/OperationGroup.java +++ b/java/AoJ/src/com/oracle/adbaoverjdbc/com/oracle/adbaoverjdbc/OperationGroup.java @@ -32,7 +32,7 @@ import jdk.incubator.sql2.ParameterizedRowCountOperation; import jdk.incubator.sql2.ParameterizedRowPublisherOperation; import jdk.incubator.sql2.ArrayRowCountOperation; -import jdk.incubator.sql2.TransactionEnd; +import jdk.incubator.sql2.TransactionCompletion; /** * Only sequential, dependent, unconditional supported. @@ -231,12 +231,12 @@ public MultiOperation multiOperation(String sql) { } @Override - public SimpleOperation endTransactionOperation(TransactionEnd trans) { + public SimpleOperation endTransactionOperation(TransactionCompletion trans) { if ( ! isHeld() ) throw new IllegalStateException("TODO"); return com.oracle.adbaoverjdbc.SimpleOperation.newOperation( session, (OperationGroup)this, - op -> session.jdbcEndTransaction(op, (com.oracle.adbaoverjdbc.TransactionEnd)trans)); + op -> session.jdbcEndTransaction(op, (com.oracle.adbaoverjdbc.TransactionCompletion)trans)); } @Override diff --git a/java/AoJ/src/com/oracle/adbaoverjdbc/com/oracle/adbaoverjdbc/Session.java b/java/AoJ/src/com/oracle/adbaoverjdbc/com/oracle/adbaoverjdbc/Session.java index d165492a..518c80dc 100755 --- a/java/AoJ/src/com/oracle/adbaoverjdbc/com/oracle/adbaoverjdbc/Session.java +++ b/java/AoJ/src/com/oracle/adbaoverjdbc/com/oracle/adbaoverjdbc/Session.java @@ -116,11 +116,11 @@ public jdk.incubator.sql2.OperationGroup operationGroup() { } @Override - public TransactionEnd transactionEnd() { + public TransactionCompletion transactionCompletion() { if (! isHeld()) { throw new IllegalStateException("TODO"); } - return TransactionEnd.createTransaction(this); + return TransactionCompletion.createTransaction(this); } @Override @@ -329,7 +329,7 @@ PreparedStatement prepareStatement(String sqlString) throws SQLException { return jdbcConnection.prepareStatement(sqlString); } - TransactionOutcome jdbcEndTransaction(SimpleOperation op, TransactionEnd trans) { + TransactionOutcome jdbcEndTransaction(SimpleOperation op, TransactionCompletion trans) { try { if (trans.endWithCommit(this)) { group.logger.log(Level.FINE, () -> "commit"); //DEBUG diff --git a/java/AoJ/src/com/oracle/adbaoverjdbc/com/oracle/adbaoverjdbc/Transaction.java b/java/AoJ/src/com/oracle/adbaoverjdbc/com/oracle/adbaoverjdbc/Transaction.java deleted file mode 100755 index 98b14bce..00000000 --- a/java/AoJ/src/com/oracle/adbaoverjdbc/com/oracle/adbaoverjdbc/Transaction.java +++ /dev/null @@ -1,64 +0,0 @@ -/* - * Copyright (c) 2018 Oracle and/or its affiliates. All rights reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.oracle.adbaoverjdbc; - -/** - * - */ -class Transaction implements jdk.incubator.sql2.Transaction { - - private boolean isRollbackOnly = false; - private boolean isInFlight = true; - private final Connection connection; - - static Transaction createTransaction(Connection conn) { - return new Transaction(conn); - } - - private Transaction(Connection conn) { - connection = conn; - } - - /** - * - * @param conn - * @return true iff transaction should be committed. false otherwise - */ - synchronized boolean endWithCommit(Connection conn) { - if (conn != connection) throw new IllegalArgumentException("TODO"); - if (!isInFlight) throw new IllegalStateException("TODO"); - isInFlight = false; - return !isRollbackOnly; - } - - @Override - public synchronized boolean setRollbackOnly() { - if (!connection.getConnectionLifecycle().isActive()) throw new IllegalStateException("TODO"); - if (isInFlight) { - isRollbackOnly = true; - return true; - } - else { - return false; - } - } - - @Override - public boolean isRollbackOnly() { - return isRollbackOnly; - } - -} diff --git a/java/AoJ/src/com/oracle/adbaoverjdbc/com/oracle/adbaoverjdbc/TransactionEnd.java b/java/AoJ/src/com/oracle/adbaoverjdbc/com/oracle/adbaoverjdbc/TransactionEnd.java index ddc8c0a6..17654f56 100755 --- a/java/AoJ/src/com/oracle/adbaoverjdbc/com/oracle/adbaoverjdbc/TransactionEnd.java +++ b/java/AoJ/src/com/oracle/adbaoverjdbc/com/oracle/adbaoverjdbc/TransactionEnd.java @@ -18,17 +18,17 @@ /** * */ -class TransactionEnd implements jdk.incubator.sql2.TransactionEnd { +class TransactionCompletion implements jdk.incubator.sql2.TransactionCompletion { private boolean isRollbackOnly = false; private boolean isInFlight = true; private final Session session; - static TransactionEnd createTransaction(Session session) { - return new TransactionEnd(session); + static TransactionCompletion createTransaction(Session session) { + return new TransactionCompletion(session); } - private TransactionEnd(Session session) { + private TransactionCompletion(Session session) { this.session = session; } From c045c22807752a1b5cfb1316bd0de40500b7bf28 Mon Sep 17 00:00:00 2001 From: Kuassim Date: Wed, 11 Jul 2018 20:28:52 -0700 Subject: [PATCH 15/16] Re-posting (network falure) --- java/AoJ/README.md | 58 +++++++------- java/AoJ/src/README.md | 58 +++++++------- java/AoJ/src/ReadMe.java | 79 +++++++++++++++++++ .../JdbcConnectionProperties.java | 2 +- .../test/DataSourceFactoryTest.java | 63 +++++++++++++++ .../test/DataSourceFactoryTest2.java | 40 ++++++++++ .../adbaoverjdbc/test/DataSourceTest.java | 36 +++++++++ .../oracle/adbaoverjdbc/test/FirstLight.java | 62 +++++++-------- .../oracle/adbaoverjdbc/test/HelloWorld.java | 8 +- .../test/SessionPropertyTest.java | 73 +++++++++++++++++ .../oracle/adbaoverjdbc/test/TestConfig.java | 30 +++++++ 11 files changed, 411 insertions(+), 98 deletions(-) mode change 100644 => 100755 java/AoJ/README.md mode change 100644 => 100755 java/AoJ/src/README.md create mode 100755 java/AoJ/src/ReadMe.java create mode 100755 java/AoJ/test/com/oracle/adbaoverjdbc/test/DataSourceFactoryTest.java create mode 100755 java/AoJ/test/com/oracle/adbaoverjdbc/test/DataSourceFactoryTest2.java create mode 100755 java/AoJ/test/com/oracle/adbaoverjdbc/test/DataSourceTest.java create mode 100755 java/AoJ/test/com/oracle/adbaoverjdbc/test/SessionPropertyTest.java create mode 100755 java/AoJ/test/com/oracle/adbaoverjdbc/test/TestConfig.java diff --git a/java/AoJ/README.md b/java/AoJ/README.md old mode 100644 new mode 100755 index 82daef08..79ea671d --- a/java/AoJ/README.md +++ b/java/AoJ/README.md @@ -3,9 +3,12 @@ ADBA is Asynchronous Database Access, a non-blocking database access api that Oracle is proposing as a Java standard. ADBA was announced at [JavaOne 2016](https://static.rainfocus.com/oracle/oow16/sess/1461693351182001EmRq/ppt/CONF1578%2020160916.pdf) -and presented again at [JavaOne 2017](http://www.oracle.com/technetwork/database/application-development/jdbc/con1491-3961036.pdf). -The ADBA source is available for download from the [OpenJDK sandbox](http://hg.openjdk.java.net/jdk/sandbox/file/9d3b0eb749a9/src/jdk.incubator.adba) -as part of the OpenJDK project and the JavaDoc is available [here](http://cr.openjdk.java.net/~lancea/8188051/apidoc/jdk.incubator.adba-summary.html). +and presented again at +[JavaOne 2017](http://www.oracle.com/technetwork/database/application-development/jdbc/con1491-3961036.pdf). +The ADBA source is available for download from the +[OpenJDK sandbox](http://hg.openjdk.java.net/jdk/sandbox/file/JDK-8188051-branch/src/jdk.incubator.adba/share/classes) +as part of the OpenJDK project and the JavaDoc is available +[here](http://cr.openjdk.java.net/~lancea/8188051/apidoc/jdk.incubator.adba-summary.html). You can get involved in the ADBA specification effort by following the [JDBC Expert Group mailing list](http://mail.openjdk.java.net/pipermail/jdbc-spec-discuss/). @@ -18,7 +21,7 @@ JDBC driver. AoJ implements only a small part of ADBA, but it is enough to write interesting code. It provides partial implementations of ```DataSourceFactory```, ```DataSource```, -```Connection```, ```OperationGroup```, ```RowOperation```, ```CountOperation```, +```Session```, ```OperationGroup```, ```RowOperation```, ```CountOperation```, ```Transaction``` and others. These implementations are not complete but there is enough there to write interesting database programs. The code that is there is untested, but it does work to some extent. The saving grace is that you can @@ -36,15 +39,8 @@ better to get it to the community as soon as we could. We hope that you agree. ## Building AoJ AoJ and ADBA require JDK 9 or later. Download ADBA from the -[OpenJDK sandbox](http://hg.openjdk.java.net/jdk/sandbox/file/JDK-8188051-branch/src/jdk.incubator.adba/share/classes). It does not have any dependencies outside of Java SE. - -For building the API modules: -``` -$ mkdir -p mods/jdk.incubator.adba -$ javac -d mods/jdk.incubator.adba/ $(find jdk.incubator.adba -name "*.java") -$ jar --create --file=mlib/jdk.incubator.adba.jar --module-version=1.0 -C mods/jdk.incubator.adba/ . -```` -Download AoJ from +[OpenJDK sandbox](http://hg.openjdk.java.net/jdk/sandbox/file/JDK-8188051-branch/src/jdk.incubator.adba/share/classes). +It does not have any dependencies outside of Java SE 9. Download AoJ from [GitHub](https://github.com/oracle/oracle-db-examples/tree/master/java/AoJ). Both are modularized so be sure to include the module-info.java files. AoJ depends on ADBA. The AoJ sample file depends on JUnit which is included with most IDEs but is @@ -59,7 +55,7 @@ driver. The sample file uses the scott/tiger schema available Start the database and load ```scott.sql```. Edit ```com.oracle.adbaoverjdbc.test.FirstLight.java``` and set the constant ```URL``` to an appropriate value. AoJ will pass this value -to ```java.sql.DriverManager.getConnection```. If you are using a database other +to ```java.sql.DriverManager.getSession```. If you are using a database other than Oracle you should change the value of the constant ```TRIVIAL``` to some very trivial ```SELECT``` query. @@ -68,34 +64,36 @@ very trivial ```SELECT``` query. The following test case should give you some idea of what AoJ can do. It should run with any JDBC driver connecting to a database with the scott schema. This is the last test in ```com.oracle.adbaoverjdbc.test.FirstLight.java```. For an -introduction to ADBA see the [JavaOne 2017 presentation](http://www.oracle.com/technetwork/database/application-development/jdbc/con1491-3961036.pdf). +introduction to ADBA see the +[JavaOne 2017 presentation](http://www.oracle.com/technetwork/database/application-development/jdbc/con1491-3961036.pdf). -```public void transactionSample() { +``` + public void readme(String url, String user, String password) { // get the AoJ DataSourceFactory - DataSourceFactory factory = DataSourceFactory.forName("com.oracle.adbaoverjdbc.DataSourceFactory"); - // get a DataSource and a Connection + DataSourceFactory factory = DataSourceFactory.newFactory("com.oracle.adbaoverjdbc.DataSourceFactory"); + // get a DataSource and a Session try (DataSource ds = factory.builder() - .url(URL) - .username(“scott") - .password(“tiger") + .url(url) + .username(user) + .password(password) .build(); - Connection conn = ds.getConnection(t -> System.out.println("ERROR: " + t.getMessage()))) { - // get a Transaction - Transaction trans = conn.transaction(); + Session conn = ds.getSession(t -> System.out.println("ERROR: " + t.getMessage()))) { + // get a TransactionCompletion + TransactionCompletion trans = conn.transactionCompletion(); // select the EMPNO of CLARK CompletionStage idF = conn.rowOperation("select empno, ename from emp where ename = ? for update") .set("1", "CLARK", AdbaType.VARCHAR) .collect(Collector.of( () -> new int[1], - (a, r) -> {a[0] = r.get("empno", Integer.class); }, + (a, r) -> {a[0] = r.at("empno").get(Integer.class); }, (l, r) -> null, a -> a[0]) ) .submit() .getCompletionStage(); // update CLARK to work in department 50 - conn.countOperation("update emp set deptno = ? where empno = ?") + conn.rowCountOperation("update emp set deptno = ? where empno = ?") .set("1", 50, AdbaType.INTEGER) .set("2", idF, AdbaType.INTEGER) .apply(c -> { @@ -114,17 +112,15 @@ introduction to ADBA see the [JavaOne 2017 presentation](http://www.oracle.com/t // wait for the async tasks to complete before exiting ForkJoinPool.commonPool().awaitQuiescence(1, TimeUnit.MINUTES); } -``` - -The following new sample code have been added: HellowWorld.java and NewEmptyJUnitTest.java. +``` ## AoJ Design Spec in 100 words or less The methods called by the user thread create a network -(i.e., [DAG](https://en.wikipedia.org/wiki/Directed_acyclic_graph)) of +([DAG](https://en.wikipedia.org/wiki/Directed_acyclic_graph)) of ```CompletableFuture```s. These ```CompleteableFuture```s asynchronously execute the synchronous JDBC calls and the result processing code provided by the user code. By default AoJ uses ```ForkJoinPool.commonPool()``` to execute ```CompletableFuture```s but the user code can provide another ```Executor```. -When the ```Connection``` is submitted the root of the ```CompleteableFuture``` +When the ```Session``` is submitted the root of the ```CompleteableFuture``` network is completed triggering execution of the rest of the network. diff --git a/java/AoJ/src/README.md b/java/AoJ/src/README.md old mode 100644 new mode 100755 index 82daef08..79ea671d --- a/java/AoJ/src/README.md +++ b/java/AoJ/src/README.md @@ -3,9 +3,12 @@ ADBA is Asynchronous Database Access, a non-blocking database access api that Oracle is proposing as a Java standard. ADBA was announced at [JavaOne 2016](https://static.rainfocus.com/oracle/oow16/sess/1461693351182001EmRq/ppt/CONF1578%2020160916.pdf) -and presented again at [JavaOne 2017](http://www.oracle.com/technetwork/database/application-development/jdbc/con1491-3961036.pdf). -The ADBA source is available for download from the [OpenJDK sandbox](http://hg.openjdk.java.net/jdk/sandbox/file/9d3b0eb749a9/src/jdk.incubator.adba) -as part of the OpenJDK project and the JavaDoc is available [here](http://cr.openjdk.java.net/~lancea/8188051/apidoc/jdk.incubator.adba-summary.html). +and presented again at +[JavaOne 2017](http://www.oracle.com/technetwork/database/application-development/jdbc/con1491-3961036.pdf). +The ADBA source is available for download from the +[OpenJDK sandbox](http://hg.openjdk.java.net/jdk/sandbox/file/JDK-8188051-branch/src/jdk.incubator.adba/share/classes) +as part of the OpenJDK project and the JavaDoc is available +[here](http://cr.openjdk.java.net/~lancea/8188051/apidoc/jdk.incubator.adba-summary.html). You can get involved in the ADBA specification effort by following the [JDBC Expert Group mailing list](http://mail.openjdk.java.net/pipermail/jdbc-spec-discuss/). @@ -18,7 +21,7 @@ JDBC driver. AoJ implements only a small part of ADBA, but it is enough to write interesting code. It provides partial implementations of ```DataSourceFactory```, ```DataSource```, -```Connection```, ```OperationGroup```, ```RowOperation```, ```CountOperation```, +```Session```, ```OperationGroup```, ```RowOperation```, ```CountOperation```, ```Transaction``` and others. These implementations are not complete but there is enough there to write interesting database programs. The code that is there is untested, but it does work to some extent. The saving grace is that you can @@ -36,15 +39,8 @@ better to get it to the community as soon as we could. We hope that you agree. ## Building AoJ AoJ and ADBA require JDK 9 or later. Download ADBA from the -[OpenJDK sandbox](http://hg.openjdk.java.net/jdk/sandbox/file/JDK-8188051-branch/src/jdk.incubator.adba/share/classes). It does not have any dependencies outside of Java SE. - -For building the API modules: -``` -$ mkdir -p mods/jdk.incubator.adba -$ javac -d mods/jdk.incubator.adba/ $(find jdk.incubator.adba -name "*.java") -$ jar --create --file=mlib/jdk.incubator.adba.jar --module-version=1.0 -C mods/jdk.incubator.adba/ . -```` -Download AoJ from +[OpenJDK sandbox](http://hg.openjdk.java.net/jdk/sandbox/file/JDK-8188051-branch/src/jdk.incubator.adba/share/classes). +It does not have any dependencies outside of Java SE 9. Download AoJ from [GitHub](https://github.com/oracle/oracle-db-examples/tree/master/java/AoJ). Both are modularized so be sure to include the module-info.java files. AoJ depends on ADBA. The AoJ sample file depends on JUnit which is included with most IDEs but is @@ -59,7 +55,7 @@ driver. The sample file uses the scott/tiger schema available Start the database and load ```scott.sql```. Edit ```com.oracle.adbaoverjdbc.test.FirstLight.java``` and set the constant ```URL``` to an appropriate value. AoJ will pass this value -to ```java.sql.DriverManager.getConnection```. If you are using a database other +to ```java.sql.DriverManager.getSession```. If you are using a database other than Oracle you should change the value of the constant ```TRIVIAL``` to some very trivial ```SELECT``` query. @@ -68,34 +64,36 @@ very trivial ```SELECT``` query. The following test case should give you some idea of what AoJ can do. It should run with any JDBC driver connecting to a database with the scott schema. This is the last test in ```com.oracle.adbaoverjdbc.test.FirstLight.java```. For an -introduction to ADBA see the [JavaOne 2017 presentation](http://www.oracle.com/technetwork/database/application-development/jdbc/con1491-3961036.pdf). +introduction to ADBA see the +[JavaOne 2017 presentation](http://www.oracle.com/technetwork/database/application-development/jdbc/con1491-3961036.pdf). -```public void transactionSample() { +``` + public void readme(String url, String user, String password) { // get the AoJ DataSourceFactory - DataSourceFactory factory = DataSourceFactory.forName("com.oracle.adbaoverjdbc.DataSourceFactory"); - // get a DataSource and a Connection + DataSourceFactory factory = DataSourceFactory.newFactory("com.oracle.adbaoverjdbc.DataSourceFactory"); + // get a DataSource and a Session try (DataSource ds = factory.builder() - .url(URL) - .username(“scott") - .password(“tiger") + .url(url) + .username(user) + .password(password) .build(); - Connection conn = ds.getConnection(t -> System.out.println("ERROR: " + t.getMessage()))) { - // get a Transaction - Transaction trans = conn.transaction(); + Session conn = ds.getSession(t -> System.out.println("ERROR: " + t.getMessage()))) { + // get a TransactionCompletion + TransactionCompletion trans = conn.transactionCompletion(); // select the EMPNO of CLARK CompletionStage idF = conn.rowOperation("select empno, ename from emp where ename = ? for update") .set("1", "CLARK", AdbaType.VARCHAR) .collect(Collector.of( () -> new int[1], - (a, r) -> {a[0] = r.get("empno", Integer.class); }, + (a, r) -> {a[0] = r.at("empno").get(Integer.class); }, (l, r) -> null, a -> a[0]) ) .submit() .getCompletionStage(); // update CLARK to work in department 50 - conn.countOperation("update emp set deptno = ? where empno = ?") + conn.rowCountOperation("update emp set deptno = ? where empno = ?") .set("1", 50, AdbaType.INTEGER) .set("2", idF, AdbaType.INTEGER) .apply(c -> { @@ -114,17 +112,15 @@ introduction to ADBA see the [JavaOne 2017 presentation](http://www.oracle.com/t // wait for the async tasks to complete before exiting ForkJoinPool.commonPool().awaitQuiescence(1, TimeUnit.MINUTES); } -``` - -The following new sample code have been added: HellowWorld.java and NewEmptyJUnitTest.java. +``` ## AoJ Design Spec in 100 words or less The methods called by the user thread create a network -(i.e., [DAG](https://en.wikipedia.org/wiki/Directed_acyclic_graph)) of +([DAG](https://en.wikipedia.org/wiki/Directed_acyclic_graph)) of ```CompletableFuture```s. These ```CompleteableFuture```s asynchronously execute the synchronous JDBC calls and the result processing code provided by the user code. By default AoJ uses ```ForkJoinPool.commonPool()``` to execute ```CompletableFuture```s but the user code can provide another ```Executor```. -When the ```Connection``` is submitted the root of the ```CompleteableFuture``` +When the ```Session``` is submitted the root of the ```CompleteableFuture``` network is completed triggering execution of the rest of the network. diff --git a/java/AoJ/src/ReadMe.java b/java/AoJ/src/ReadMe.java new file mode 100755 index 00000000..45fb9406 --- /dev/null +++ b/java/AoJ/src/ReadMe.java @@ -0,0 +1,79 @@ +/* + * Copyright (c) 2018 Oracle and/or its affiliates. All rights reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package ReadMe; + +import java.util.concurrent.CompletionStage; +import java.util.concurrent.ForkJoinPool; +import java.util.concurrent.TimeUnit; +import java.util.stream.Collector; +import jdk.incubator.sql2.AdbaType; +import jdk.incubator.sql2.DataSource; +import jdk.incubator.sql2.DataSourceFactory; +import jdk.incubator.sql2.Session; +import jdk.incubator.sql2.SqlException; +import jdk.incubator.sql2.TransactionCompletion; + +/** + * + */ +public class ReadMe { + + public void readme(String url, String user, String password) { + // get the AoJ DataSourceFactory + DataSourceFactory factory = DataSourceFactory.newFactory("com.oracle.adbaoverjdbc.DataSourceFactory"); + // get a DataSource and a Session + try (DataSource ds = factory.builder() + .url(url) + .username(user) + .password(password) + .build(); + Session conn = ds.getSession(t -> System.out.println("ERROR: " + t.getMessage()))) { + // get a TransactionCompletion + TransactionCompletion trans = conn.transactionCompletion(); + // select the EMPNO of CLARK + CompletionStage idF = conn.rowOperation("select empno, ename from emp where ename = ? for update") + .set("1", "CLARK", AdbaType.VARCHAR) + .collect(Collector.of( + () -> new int[1], + (a, r) -> {a[0] = r.at("empno").get(Integer.class); }, + (l, r) -> null, + a -> a[0]) + ) + .submit() + .getCompletionStage(); + // update CLARK to work in department 50 + conn.rowCountOperation("update emp set deptno = ? where empno = ?") + .set("1", 50, AdbaType.INTEGER) + .set("2", idF, AdbaType.INTEGER) + .apply(c -> { + if (c.getCount() != 1L) { + trans.setRollbackOnly(); + throw new SqlException("updated wrong number of rows", null, null, -1, null, -1); + } + return c.getCount(); + }) + .onError(t -> t.printStackTrace()) + .submit(); + + conn.catchErrors(); // resume normal execution if there were any errors + conn.commitMaybeRollback(trans); // commit (or rollback) the transaction + } + // wait for the async tasks to complete before exiting + ForkJoinPool.commonPool().awaitQuiescence(1, TimeUnit.MINUTES); + } + +} diff --git a/java/AoJ/src/com/oracle/adbaoverjdbc/com/oracle/adbaoverjdbc/JdbcConnectionProperties.java b/java/AoJ/src/com/oracle/adbaoverjdbc/com/oracle/adbaoverjdbc/JdbcConnectionProperties.java index 4f6fff5c..6205fca5 100755 --- a/java/AoJ/src/com/oracle/adbaoverjdbc/com/oracle/adbaoverjdbc/JdbcConnectionProperties.java +++ b/java/AoJ/src/com/oracle/adbaoverjdbc/com/oracle/adbaoverjdbc/JdbcConnectionProperties.java @@ -33,7 +33,7 @@ private JdbcConnectionProperties() { @Override public String name() { - return "JDBC_SESSION_PROPERTIES"; + return "JDBC_CONNECTION_PROPERTIES"; } @Override diff --git a/java/AoJ/test/com/oracle/adbaoverjdbc/test/DataSourceFactoryTest.java b/java/AoJ/test/com/oracle/adbaoverjdbc/test/DataSourceFactoryTest.java new file mode 100755 index 00000000..446fd74e --- /dev/null +++ b/java/AoJ/test/com/oracle/adbaoverjdbc/test/DataSourceFactoryTest.java @@ -0,0 +1,63 @@ +/* + * Copyright (c) 2018 Oracle and/or its affiliates. All rights reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.oracle.adbaoverjdbc.test; + +import static com.oracle.adbaoverjdbc.test.TestConfig.*; +import static org.junit.Assert.*; +import org.junit.Test; + +import jdk.incubator.sql2.DataSource; +import jdk.incubator.sql2.DataSourceFactory; + +/** + * Verifies the public API of DataSourceFactory functions as described in the + * ADBA javadoc. + */ +public class DataSourceFactoryTest { + + /** + * Assert DataSourceFactory.newFactory(String) returns null if the input + * is not the name of a factory class. + */ + @Test + public void testNewFactoryNegative() { + DataSourceFactory factory = + DataSourceFactory.newFactory("NOT A FACTORY NAME"); + assertNull(factory); + } + + /** + * Assert DataSourceFactory.newFactory(String) returns a DataSourceFactory + * instance if the input is the name of a factory class. + */ + @Test + public void testNewFactory() { + DataSourceFactory factory = DataSourceFactory.newFactory(TEST_DS_FACTORY_NAME); + assertNotNull(factory); + assertEquals(TEST_DS_FACTORY_NAME, factory.getClass().getName()); + } + + /** + * Assert DataSourceFactory.builder() returns a DataSource.Builder instance. + */ + @Test + public void testBuilder() { + DataSourceFactory factory = DataSourceFactory.newFactory(TEST_DS_FACTORY_NAME); + DataSource.Builder builder = factory.builder(); + assertNotNull(builder); + } +} diff --git a/java/AoJ/test/com/oracle/adbaoverjdbc/test/DataSourceFactoryTest2.java b/java/AoJ/test/com/oracle/adbaoverjdbc/test/DataSourceFactoryTest2.java new file mode 100755 index 00000000..68476d12 --- /dev/null +++ b/java/AoJ/test/com/oracle/adbaoverjdbc/test/DataSourceFactoryTest2.java @@ -0,0 +1,40 @@ +/* + * Copyright (c) 2018 Oracle and/or its affiliates. All rights reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.oracle.adbaoverjdbc.test; + +import jdk.incubator.sql2.DataSourceFactory; +import org.junit.Test; +import static org.junit.Assert.*; + +public class DataSourceFactoryTest2 { + + /** + * Verify that when DataSourceFactory name is null then it throws an + * exception. + */ + @Test + public void nullDataSourceFactory() { + try { + DataSourceFactory.newFactory(null); + } catch (IllegalArgumentException ex) { + // Exception expected + System.out.println(ex.getMessage()); + return; + } + + fail(); + } +} diff --git a/java/AoJ/test/com/oracle/adbaoverjdbc/test/DataSourceTest.java b/java/AoJ/test/com/oracle/adbaoverjdbc/test/DataSourceTest.java new file mode 100755 index 00000000..f583821a --- /dev/null +++ b/java/AoJ/test/com/oracle/adbaoverjdbc/test/DataSourceTest.java @@ -0,0 +1,36 @@ +/* + * Copyright (c) 2018 Oracle and/or its affiliates. All rights reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.oracle.adbaoverjdbc.test; + +import jdk.incubator.sql2.DataSourceFactory; + +import static com.oracle.adbaoverjdbc.test.TestConfig.*; + +/** + * Verifies the public API of DataSource functions as described in the ADBA + * javadoc. + */ +public class DataSourceTest { + + final DataSourceFactory dsFactory = + DataSourceFactory.newFactory(TEST_DS_FACTORY_NAME); + + + // Instances of this type are used to build DataSources. + // This type is immutable once configured. No property can be set more than once. + // No property can be set after build() is called. +} diff --git a/java/AoJ/test/com/oracle/adbaoverjdbc/test/FirstLight.java b/java/AoJ/test/com/oracle/adbaoverjdbc/test/FirstLight.java index 76051d61..9debe331 100755 --- a/java/AoJ/test/com/oracle/adbaoverjdbc/test/FirstLight.java +++ b/java/AoJ/test/com/oracle/adbaoverjdbc/test/FirstLight.java @@ -16,11 +16,9 @@ package com.oracle.adbaoverjdbc.test; import jdk.incubator.sql2.AdbaType; -import jdk.incubator.sql2.Connection; import jdk.incubator.sql2.DataSourceFactory; import jdk.incubator.sql2.DataSource; import jdk.incubator.sql2.SqlException; -import jdk.incubator.sql2.Transaction; import java.util.Properties; import java.util.concurrent.CompletionStage; import java.util.concurrent.ForkJoinPool; @@ -34,6 +32,8 @@ import static org.junit.Assert.*; import static com.oracle.adbaoverjdbc.JdbcConnectionProperties.JDBC_CONNECTION_PROPERTIES; import jdk.incubator.sql2.Result; +import jdk.incubator.sql2.Session; +import jdk.incubator.sql2.TransactionCompletion; /** * This is a quick and dirty test to check if anything at all is working. @@ -48,7 +48,7 @@ public class FirstLight { // // Define these three constants with the appropriate values for the database // and JDBC driver you want to use. Should work with ANY reasonably standard - // JDBC driver. These values are passed to DriverManager.getConnection. + // JDBC driver. These values are passed to DriverManager.getSession. public static final String URL = "jdbc:oracle:thin:@//den03cll.us.oracle.com:5521/main2.regress.rdbms.dev.us.oracle.com"; //""; public static final String USER = "scott"; //"; public static final String PASSWORD = "tiger"; //"; @@ -87,7 +87,7 @@ public void firstLight() { } /** - * Verify that can create a DataSource, though not a Connection. Should work + * Verify that can create a DataSource, though not a Session. Should work * even if there is no database. */ @Test @@ -102,7 +102,7 @@ public void createDataSource() { } /** - * create a Connection and send a SQL to the database + * create a Session and send a SQL to the database */ @Test public void sqlOperation() { @@ -113,12 +113,12 @@ public void sqlOperation() { .url(URL) .username(USER) .password(PASSWORD) - .connectionProperty(JDBC_CONNECTION_PROPERTIES, props) + .sessionProperty(JDBC_CONNECTION_PROPERTIES, props) .build(); - Connection conn = ds.getConnection(t -> System.out.println("ERROR: " + t.getMessage())); - try (conn) { - assertNotNull(conn); - conn.operation(TRIVIAL).submit(); + Session session = ds.getSession(t -> System.out.println("ERROR: " + t.getMessage())); + try (session) { + assertNotNull(session); + session.operation(TRIVIAL).submit(); } ForkJoinPool.commonPool().awaitQuiescence(1, TimeUnit.MINUTES); } @@ -135,18 +135,18 @@ public void rowOperation() { .url(URL) .username(USER) .password(PASSWORD) - .connectionProperty(JDBC_CONNECTION_PROPERTIES, props) + .sessionProperty(JDBC_CONNECTION_PROPERTIES, props) .build(); - Connection conn = ds.getConnection(t -> System.out.println("ERROR: " + t.getMessage()))) { - assertNotNull(conn); - conn.rowOperation(TRIVIAL) + Session session = ds.getSession(t -> System.out.println("ERROR: " + t.getMessage()))) { + assertNotNull(session); + session.rowOperation(TRIVIAL) .collect(Collector.of(() -> null, (a, r) -> { System.out.println("Trivial: " + r.at(1).get(String.class)); }, (x, y) -> null)) .submit(); - conn.rowOperation("select * from emp") + session.rowOperation("select * from emp") .collect(Collector.of(() -> new int[1], (int[] a, Result.RowColumn r) -> { a[0] = a[0]+r.at("sal").get(Integer.class); @@ -157,7 +157,7 @@ public void rowOperation() { .getCompletionStage() .thenAccept( n -> {System.out.println("labor cost: " + n);}) .toCompletableFuture(); - conn.rowOperation("select * from emp where empno = ?") + session.rowOperation("select * from emp where empno = ?") .set("1", 7782) .collect(Collector.of( () -> null, @@ -173,7 +173,7 @@ public void rowOperation() { /** * check does error handling do anything */ - @Test + //@Test public void errorHandling() { Properties props = new Properties(); props.setProperty("oracle.jdbc.implicitStatementCacheSize", "10"); @@ -182,10 +182,10 @@ public void errorHandling() { .url(URL) .username(USER) .password("invalid password") - .connectionProperty(JDBC_CONNECTION_PROPERTIES, props) + .sessionProperty(JDBC_CONNECTION_PROPERTIES, props) .build(); - Connection conn = ds.getConnection(t -> System.out.println("ERROR: " + t.toString()))) { - conn.rowOperation(TRIVIAL) + Session session = ds.getSession(t -> System.out.println("ERROR: " + t.toString()))) { + session.rowOperation(TRIVIAL) .collect(Collector.of(() -> null, (a, r) -> { System.out.println("Trivial: " + r.at(1).get(String.class)); @@ -199,10 +199,10 @@ public void errorHandling() { .url(URL) .username(USER) .password(PASSWORD) - .connectionProperty(JDBC_CONNECTION_PROPERTIES, props) + .sessionProperty(JDBC_CONNECTION_PROPERTIES, props) .build(); - Connection conn = ds.getConnection(t -> System.out.println("ERROR: " + t.toString()))) { - conn.rowOperation("select * from emp where empno = ?") + Session session = ds.getSession(t -> System.out.println("ERROR: " + t.toString()))) { + session.rowOperation("select * from emp where empno = ?") .set("1", 7782) .collect(Collector.of( () -> null, @@ -218,7 +218,7 @@ public void errorHandling() { /** * Do something that approximates real work. Do a transaction. Uses - * Transaction, CompletionStage args, and catch Operation. + * TransactionCompletion, CompletionStage args, and catch Operation. */ @Test public void transaction() { @@ -229,11 +229,11 @@ public void transaction() { .url(URL) .username(USER) .password(PASSWORD) - .connectionProperty(JDBC_CONNECTION_PROPERTIES, props) + .sessionProperty(JDBC_CONNECTION_PROPERTIES, props) .build(); - Connection conn = ds.getConnection(t -> System.out.println("ERROR: " + t.toString()))) { - Transaction trans = conn.transaction(); - CompletionStage idF = conn.rowOperation("select empno, ename from emp where ename = ? for update") + Session session = ds.getSession(t -> System.out.println("ERROR: " + t.toString()))) { + TransactionCompletion trans = session.transactionCompletion(); + CompletionStage idF = session.rowOperation("select empno, ename from emp where ename = ? for update") .set("1", "CLARK", AdbaType.VARCHAR) .collect(Collector.of( () -> new int[1], @@ -244,7 +244,7 @@ public void transaction() { .submit() .getCompletionStage(); idF.thenAccept( id -> { System.out.println("id: " + id); } ); - conn.rowCountOperation("update emp set deptno = ? where empno = ?") + session.rowCountOperation("update emp set deptno = ? where empno = ?") .set("1", 50, AdbaType.INTEGER) .set("2", idF, AdbaType.INTEGER) .apply(c -> { @@ -258,8 +258,8 @@ public void transaction() { .submit() .getCompletionStage() .thenAccept( c -> { System.out.println("updated rows: " + c); } ); - conn.catchErrors(); - conn.commitMaybeRollback(trans); + session.catchErrors(); + session.commitMaybeRollback(trans); } ForkJoinPool.commonPool().awaitQuiescence(1, TimeUnit.MINUTES); } diff --git a/java/AoJ/test/com/oracle/adbaoverjdbc/test/HelloWorld.java b/java/AoJ/test/com/oracle/adbaoverjdbc/test/HelloWorld.java index c89a7baa..a6e3e4c4 100755 --- a/java/AoJ/test/com/oracle/adbaoverjdbc/test/HelloWorld.java +++ b/java/AoJ/test/com/oracle/adbaoverjdbc/test/HelloWorld.java @@ -18,10 +18,10 @@ import java.util.concurrent.ForkJoinPool; import java.util.concurrent.TimeUnit; import java.util.stream.Collector; -import jdk.incubator.sql2.Connection; import jdk.incubator.sql2.DataSourceFactory; import jdk.incubator.sql2.DataSource; import org.junit.Test; +import jdk.incubator.sql2.Session; public class HelloWorld { @@ -42,9 +42,9 @@ public static void main(String[] args) { .username(USER) .password(PASSWORD) .build(); - Connection conn = ds.getConnection()) { - System.out.println("Connected! DataSource: " + ds + " Connection: " + conn); - conn.rowOperation("SELECT 1") + Session session = ds.getSession()) { + System.out.println("Connected! DataSource: " + ds + " Session: " + session); + session.rowOperation("SELECT 1") .collect(Collector.of(() -> null, (a, r) -> { System.out.println(r.at(1).get(String.class)); }, (l, r) -> null, diff --git a/java/AoJ/test/com/oracle/adbaoverjdbc/test/SessionPropertyTest.java b/java/AoJ/test/com/oracle/adbaoverjdbc/test/SessionPropertyTest.java new file mode 100755 index 00000000..810dd22b --- /dev/null +++ b/java/AoJ/test/com/oracle/adbaoverjdbc/test/SessionPropertyTest.java @@ -0,0 +1,73 @@ +/* + * Copyright (c) 2018 Oracle and/or its affiliates. All rights reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.oracle.adbaoverjdbc.test; + +import static jdk.incubator.sql2.AdbaSessionProperty.*; +import static org.junit.Assert.*; + +import java.util.Properties; + +import org.junit.Test; + +import com.oracle.adbaoverjdbc.JdbcConnectionProperties; + +import jdk.incubator.sql2.SessionProperty; + +/** + * Verifies the public API of SessionProperty functions as described in the + * ADBA javadoc. + */ +public class SessionPropertyTest { + + @Test + public void testUser() { + assertEquals("USER", USER.name()); + assertEquals(String.class, USER.range()); + assertFalse(USER.validate(1234)); + assertTrue(USER.validate("SCOTT")); + assertNull(USER.defaultValue()); + assertFalse(USER.isSensitive()); + } + + @Test + public void testPassword() { + assertEquals("PASSWORD", PASSWORD.name()); + assertEquals(String.class, PASSWORD.range()); + assertFalse(PASSWORD.validate(1234)); + assertTrue(PASSWORD.validate("tiger")); + assertNull(PASSWORD.defaultValue()); + assertTrue(PASSWORD.isSensitive()); + } + + @Test + public void testJdbcConnectionProperties() { + SessionProperty jdbcProps = + JdbcConnectionProperties.JDBC_CONNECTION_PROPERTIES; + + assertEquals("JDBC_CONNECTION_PROPERTIES", jdbcProps.name()); + assertEquals(Properties.class, jdbcProps.range()); + assertFalse(jdbcProps.validate(1234)); + assertTrue(jdbcProps.validate(new Properties())); + assertNotNull(jdbcProps.defaultValue()); + assertTrue(jdbcProps.validate(jdbcProps.defaultValue())); + + // Expect true because password is a JDBC connection property + assertTrue(jdbcProps.isSensitive()); + } + + // TODO: Test the configureOperation API +} diff --git a/java/AoJ/test/com/oracle/adbaoverjdbc/test/TestConfig.java b/java/AoJ/test/com/oracle/adbaoverjdbc/test/TestConfig.java new file mode 100755 index 00000000..dc98adb7 --- /dev/null +++ b/java/AoJ/test/com/oracle/adbaoverjdbc/test/TestConfig.java @@ -0,0 +1,30 @@ +/* + * Copyright (c) 2018 Oracle and/or its affiliates. All rights reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.oracle.adbaoverjdbc.test; + +public class TestConfig { + + static final String TEST_DS_FACTORY_NAME = + System.getProperty("test.DATA_SOURCE_FACTORY", + com.oracle.adbaoverjdbc.DataSourceFactory.class.getName()); + + static final String TEST_USER = System.getProperty("test.USER"); + + static final String TEST_PASSWORD = System.getProperty("test.PASSWORD"); + + static final String TEST_URL = System.getProperty("test.URL"); +} From d4a072baacff6fbb6bd1f195457d903b5acb4796 Mon Sep 17 00:00:00 2001 From: Dan McGhan Date: Mon, 16 Jul 2018 12:04:43 -0400 Subject: [PATCH 16/16] Added missing result.rowsAffected check --- .../hr_app/db_apis/employees.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/javascript/rest-api/part-4-handling-post-put-and-delete-requests/hr_app/db_apis/employees.js b/javascript/rest-api/part-4-handling-post-put-and-delete-requests/hr_app/db_apis/employees.js index 5e02d3f6..4bf56ef9 100644 --- a/javascript/rest-api/part-4-handling-post-put-and-delete-requests/hr_app/db_apis/employees.js +++ b/javascript/rest-api/part-4-handling-post-put-and-delete-requests/hr_app/db_apis/employees.js @@ -93,7 +93,7 @@ async function update(emp) { const employee = Object.assign({}, emp); const result = await database.simpleExecute(updateSql, employee); - if (result.rowsAffected === 1) { + if (result.rowsAffected && result.rowsAffected === 1) { return employee; } else { return null;