From 45eb56e4678953a6a5bf78dd1614bb90bcb60a61 Mon Sep 17 00:00:00 2001 From: Nguyen Nguyen Date: Fri, 6 Oct 2023 13:45:30 +1000 Subject: [PATCH 01/17] Oracle DB support workflow test --- .github/workflows/maven.yml | 63 ++++- config/oracle/sample_auctionmark_config.xml | 57 ++++ config/oracle/sample_chbenchmark_config.xml | 167 ++++++++++++ config/oracle/sample_epinions_config.xml | 57 ++++ config/oracle/sample_hyadapt_config.xml | 121 +++++++++ config/oracle/sample_noop_config.xml | 34 +++ config/oracle/sample_otmetrics_config.xml | 32 +++ .../oracle/sample_resourcestresser_config.xml | 49 ++++ config/oracle/sample_seats_config.xml | 48 ++++ config/oracle/sample_sibench_config.xml | 35 +++ config/oracle/sample_smallbank_config.xml | 47 ++++ config/oracle/sample_tatp_config.xml | 51 ++++ config/oracle/sample_tpcc_config.xml | 57 ++++ config/oracle/sample_tpch_config.xml | 141 ++++++++++ config/oracle/sample_twitter_config.xml | 51 ++++ config/oracle/sample_voter_config.xml | 32 +++ config/oracle/sample_wikipedia_config.xml | 46 ++++ config/oracle/sample_ycsb_config.xml | 49 ++++ docker/oracle/docker-compose.yml | 18 ++ docker/oracle/down.sh | 8 + docker/oracle/prune.sh | 8 + docker/oracle/setup/01_user.sql | 8 + docker/oracle/up.sh | 8 + pom.xml | 17 ++ .../java/com/oltpbenchmark/DBWorkload.java | 21 ++ .../oltpbenchmark/api/BenchmarkModule.java | 10 +- .../java/com/oltpbenchmark/api/Procedure.java | 11 +- .../auctionmark/AuctionMarkLoader.java | 6 +- .../auctionmark/AuctionMarkProfile.java | 5 +- .../auctionmark/procedures/LoadConfig.java | 8 + .../otmetrics/procedures/GetSessionRange.java | 3 + .../resourcestresser/procedures/CPU1.java | 4 +- .../resourcestresser/procedures/CPU2.java | 4 +- .../seats/procedures/LoadConfig.java | 13 + .../benchmarks/voter/procedures/Vote.java | 11 +- .../benchmarks/wikipedia/WikipediaLoader.java | 18 +- .../java/com/oltpbenchmark/util/SQLUtil.java | 37 +++ .../benchmarks/auctionmark/ddl-oracle.sql | 207 +++++++------- .../benchmarks/auctionmark/dialect-oracle.xml | 104 ++++--- .../benchmarks/chbenchmark/ddl-oracle.sql | 35 +++ .../benchmarks/chbenchmark/dialect-oracle.xml | 206 ++++++++++++++ .../gather_schema_stats_oracle.sql | 2 + .../benchmarks/epinions/ddl-oracle.sql | 48 ++-- .../benchmarks/epinions/dialect-oracle.xml | 27 +- .../benchmarks/hyadapt/ddl-oracle.sql | 256 ++++++++++++++++++ .../resources/benchmarks/noop/ddl-oracle.sql | 7 + .../benchmarks/noop/dialect-oracle.xml | 11 + .../otmetrics/ddl-oracle-trimmed.sql | 34 +++ .../benchmarks/otmetrics/ddl-oracle.sql | 40 +++ .../resourcestresser/ddl-oracle.sql | 39 ++- .../resources/benchmarks/seats/ddl-oracle.sql | 33 +-- .../benchmarks/sibench/ddl-oracle.sql | 7 + .../benchmarks/sibench/dialect-oracle.xml | 11 + .../benchmarks/smallbank/ddl-oracle.sql | 25 ++ .../resources/benchmarks/tpch/ddl-oracle.sql | 128 +++++++++ .../benchmarks/tpch/dialect-oracle.xml | 117 ++++++++ .../tpch/gather_schema_stats_oracle.sql | 2 + .../benchmarks/twitter/ddl-oracle.sql | 43 +-- .../benchmarks/twitter/dialect-oracle.xml | 17 +- .../resources/benchmarks/voter/ddl-oracle.sql | 38 +++ .../benchmarks/voter/dialect-oracle.xml | 11 + .../benchmarks/wikipedia/ddl-oracle.sql | 90 ++---- .../benchmarks/wikipedia/dialect-oracle.xml | 58 +--- 63 files changed, 2563 insertions(+), 388 deletions(-) create mode 100644 config/oracle/sample_auctionmark_config.xml create mode 100644 config/oracle/sample_chbenchmark_config.xml create mode 100644 config/oracle/sample_epinions_config.xml create mode 100644 config/oracle/sample_hyadapt_config.xml create mode 100644 config/oracle/sample_noop_config.xml create mode 100644 config/oracle/sample_otmetrics_config.xml create mode 100644 config/oracle/sample_resourcestresser_config.xml create mode 100644 config/oracle/sample_seats_config.xml create mode 100644 config/oracle/sample_sibench_config.xml create mode 100644 config/oracle/sample_smallbank_config.xml create mode 100644 config/oracle/sample_tatp_config.xml create mode 100644 config/oracle/sample_tpcc_config.xml create mode 100644 config/oracle/sample_tpch_config.xml create mode 100644 config/oracle/sample_twitter_config.xml create mode 100644 config/oracle/sample_voter_config.xml create mode 100644 config/oracle/sample_wikipedia_config.xml create mode 100644 config/oracle/sample_ycsb_config.xml create mode 100644 docker/oracle/docker-compose.yml create mode 100755 docker/oracle/down.sh create mode 100755 docker/oracle/prune.sh create mode 100644 docker/oracle/setup/01_user.sql create mode 100755 docker/oracle/up.sh create mode 100644 src/main/resources/benchmarks/chbenchmark/ddl-oracle.sql create mode 100644 src/main/resources/benchmarks/chbenchmark/dialect-oracle.xml create mode 100644 src/main/resources/benchmarks/chbenchmark/gather_schema_stats_oracle.sql create mode 100644 src/main/resources/benchmarks/hyadapt/ddl-oracle.sql create mode 100644 src/main/resources/benchmarks/noop/ddl-oracle.sql create mode 100644 src/main/resources/benchmarks/noop/dialect-oracle.xml create mode 100644 src/main/resources/benchmarks/otmetrics/ddl-oracle-trimmed.sql create mode 100644 src/main/resources/benchmarks/otmetrics/ddl-oracle.sql create mode 100644 src/main/resources/benchmarks/sibench/ddl-oracle.sql create mode 100644 src/main/resources/benchmarks/sibench/dialect-oracle.xml create mode 100644 src/main/resources/benchmarks/smallbank/ddl-oracle.sql create mode 100644 src/main/resources/benchmarks/tpch/ddl-oracle.sql create mode 100644 src/main/resources/benchmarks/tpch/dialect-oracle.xml create mode 100644 src/main/resources/benchmarks/tpch/gather_schema_stats_oracle.sql create mode 100644 src/main/resources/benchmarks/voter/ddl-oracle.sql create mode 100644 src/main/resources/benchmarks/voter/dialect-oracle.xml diff --git a/.github/workflows/maven.yml b/.github/workflows/maven.yml index 4036e97bf..f14fc4278 100644 --- a/.github/workflows/maven.yml +++ b/.github/workflows/maven.yml @@ -10,6 +10,8 @@ # - One job to build/test the docker images. # - One job to publish the docker image. +# Copyright (c) 2023, Oracle and/or its affiliates. + name: BenchBase (Java with Maven) on: @@ -58,7 +60,7 @@ jobs: runs-on: ubuntu-latest strategy: matrix: - profile: [ 'cockroachdb', 'mariadb', 'mysql', 'postgres', 'spanner', 'phoenix', 'sqlserver', 'sqlite' ] + profile: [ 'cockroachdb', 'mariadb', 'mysql', 'postgres', 'spanner', 'phoenix', 'sqlserver', 'sqlite' , 'oracle' ] steps: - name: Checkout repo uses: actions/checkout@v4 @@ -271,6 +273,65 @@ jobs: fi ./scripts/check_histogram_results.sh results/histograms.json $ERRORS_THRESHOLD + ## ---------------------------------------------------------------------------------- + ## ORACLE + ## ---------------------------------------------------------------------------------- + oracle: + needs: package-and-upload + runs-on: ubuntu-latest + strategy: + fail-fast: false + matrix: + benchmark: [ 'auctionmark', 'epinions', 'hyadapt', 'otmetrics', 'resourcestresser', 'seats', 'sibench', 'smallbank', 'tatp', 'tpcc', 'twitter', 'voter', 'wikipedia', 'ycsb' ] + services: + oracle: + image: container-registry.oracle.com/database/free:23.2.0.0 + ports: + - "1521:1521" + - "5500:5500" + env: + ORACLE_PWD: password + ORACLE_CHARACTERSET: AL32UTF8 + steps: + - name: Download artifact + uses: actions/download-artifact@v3 + with: + name: benchbase-oracle + + - name: Extract artifact + run: | + tar xvzf benchbase-oracle.tgz --strip-components=1 + + - name: Delete artifact + run: | + rm -rf benchbase-oracle.tgz + + - name: Set up non-DBA user + run: | + printf "create user benchbase identified by password;\nGRANT CONNECT, RESOURCE TO benchbase;" | docker exec oracle sqlplus "system/password@freepdb1" + + - name: Set up JDK + uses: actions/setup-java@v3 + with: + java-version: ${{env.JAVA_VERSION}} + distribution: 'temurin' + + - name: Run benchmark + run: | + printf "DROP USER benchbase CASCADE; create user benchbase identified by password;\nGRANT CONNECT, RESOURCE, UNLIMITED TABLESPACE TO benchbase; GRANT EXECUTE ON DBMS_CRYPTO TO benchbase; GRANT EXECUTE ON DBMS_LOCK TO benchbase;" | docker exec oracle sqlplus "sys/password@freepdb1 as sysdba" + java -jar benchbase.jar -b ${{matrix.benchmark}} -c config/oracle/sample_${{matrix.benchmark}}_config.xml --create=true --load=true --execute=true --json-histograms results/histograms.json + # FIXME: Reduce the error rate so we don't need these overrides. + if [ ${{matrix.benchmark}} == auctionmark ]; then + ERRORS_THRESHOLD=0.04 + elif [ ${{matrix.benchmark}} == tatp ]; then + ERRORS_THRESHOLD=0.05 + elif [ ${{matrix.benchmark}} == tpcc ]; then + ERRORS_THRESHOLD=0.02 + elif [ ${{matrix.benchmark}} == wikipedia ]; then + ERRORS_THRESHOLD=0.02 + fi + ./scripts/check_histogram_results.sh results/histograms.json $ERRORS_THRESHOLD + ## ---------------------------------------------------------------------------------- ## POSTGRESQL ## ---------------------------------------------------------------------------------- diff --git a/config/oracle/sample_auctionmark_config.xml b/config/oracle/sample_auctionmark_config.xml new file mode 100644 index 000000000..bfe909d0f --- /dev/null +++ b/config/oracle/sample_auctionmark_config.xml @@ -0,0 +1,57 @@ + + + + + + ORACLE + oracle.jdbc.OracleDriver + jdbc:oracle:thin:@localhost:1521/freepdb1 + benchbase + password + TRANSACTION_SERIALIZABLE + 128 + + + 1 + + + 1 + + + + 10000 + 45, 10, 20, 2, 1, 4, 10, 5, 3 + + + + + + + GetItem + + + GetUserInfo + + + NewBid + + + NewComment + + + NewCommentResponse + + + NewFeedback + + + NewItem + + + NewPurchase + + + UpdateItem + + + \ No newline at end of file diff --git a/config/oracle/sample_chbenchmark_config.xml b/config/oracle/sample_chbenchmark_config.xml new file mode 100644 index 000000000..ee165747e --- /dev/null +++ b/config/oracle/sample_chbenchmark_config.xml @@ -0,0 +1,167 @@ + + + + + + ORACLE + oracle.jdbc.OracleDriver + jdbc:oracle:thin:@localhost:1521/freepdb1 + benchbase + password + TRANSACTION_SERIALIZABLE + 128 + + + 1 + + + + 1 + + + + /benchmarks/chbenchmark/gather_schema_stats_oracle.sql + + + + + + + + + + + + + + + + + 200 + + + 45,43,4,4,4 + 3, 2, 3, 2, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5 + + + + + + + + + + + + + + + + + + + + + + + + + + + + Q1 + + + Q2 + + + Q3 + + + Q4 + + + Q5 + + + Q6 + + + Q7 + + + Q8 + + + Q9 + + + Q10 + + + Q11 + + + Q12 + + + Q13 + + + Q14 + + + Q15 + + + Q16 + + + Q17 + + + Q18 + + + Q19 + + + Q20 + + + Q21 + + + Q22 + + + + + + + NewOrder + + + Payment + + + OrderStatus + + + Delivery + + + StockLevel + + + diff --git a/config/oracle/sample_epinions_config.xml b/config/oracle/sample_epinions_config.xml new file mode 100644 index 000000000..1b4c9e91f --- /dev/null +++ b/config/oracle/sample_epinions_config.xml @@ -0,0 +1,57 @@ + + + + + + ORACLE + oracle.jdbc.OracleDriver + jdbc:oracle:thin:@localhost:1521/freepdb1 + benchbase + password + TRANSACTION_SERIALIZABLE + 128 + + + 1 + + + 1 + + + + 10000 + 10,10,10,10,10,10,10,10,20 + + + + + + + GetReviewItemById + + + GetReviewsByUser + + + GetAverageRatingByTrustedUser + + + GetItemAverageRating + + + GetItemReviewsByTrustedUser + + + UpdateUserName + + + UpdateItemTitle + + + UpdateReviewRating + + + UpdateTrustRating + + + diff --git a/config/oracle/sample_hyadapt_config.xml b/config/oracle/sample_hyadapt_config.xml new file mode 100644 index 000000000..fa35a658e --- /dev/null +++ b/config/oracle/sample_hyadapt_config.xml @@ -0,0 +1,121 @@ + + + + + + ORACLE + oracle.jdbc.OracleDriver + jdbc:oracle:thin:@localhost:1521/freepdb1 + benchbase + password + TRANSACTION_SERIALIZABLE + 128 + + 1 + + 1 + + + + 10000 + 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1 + + + + + + MaxRecord1 + + + MaxRecord2 + + + MaxRecord3 + + + MaxRecord4 + + + MaxRecord5 + + + MaxRecord6 + + + MaxRecord7 + + + MaxRecord8 + + + MaxRecord9 + + + MaxRecord10 + + + + ReadRecord1 + + + ReadRecord2 + + + ReadRecord3 + + + ReadRecord4 + + + ReadRecord5 + + + ReadRecord6 + + + ReadRecord7 + + + ReadRecord8 + + + ReadRecord9 + + + ReadRecord10 + + + + + SumRecord1 + + + SumRecord2 + + + SumRecord3 + + + SumRecord4 + + + SumRecord5 + + + SumRecord6 + + + SumRecord7 + + + SumRecord8 + + + SumRecord9 + + + SumRecord10 + + + + diff --git a/config/oracle/sample_noop_config.xml b/config/oracle/sample_noop_config.xml new file mode 100644 index 000000000..ac9d9b331 --- /dev/null +++ b/config/oracle/sample_noop_config.xml @@ -0,0 +1,34 @@ + + + + + + ORACLE + oracle.jdbc.OracleDriver + jdbc:oracle:thin:@localhost:1521/freepdb1 + system + password + TRANSACTION_SERIALIZABLE + 128 + + + + 1 + + + 1 + + + + 1000 + 100 + + + + + + + NoOp + + + diff --git a/config/oracle/sample_otmetrics_config.xml b/config/oracle/sample_otmetrics_config.xml new file mode 100644 index 000000000..43b50e166 --- /dev/null +++ b/config/oracle/sample_otmetrics_config.xml @@ -0,0 +1,32 @@ + + + + + + ORACLE + oracle.jdbc.OracleDriver + jdbc:oracle:thin:@localhost:1521/freepdb1 + benchbase + password + TRANSACTION_SERIALIZABLE + + 2048 + 0.1 + + + 1 + + + + 10000 + 100 + + + + + + + GetSessionRange + + + diff --git a/config/oracle/sample_resourcestresser_config.xml b/config/oracle/sample_resourcestresser_config.xml new file mode 100644 index 000000000..f6309f26a --- /dev/null +++ b/config/oracle/sample_resourcestresser_config.xml @@ -0,0 +1,49 @@ + + + + + + ORACLE + oracle.jdbc.OracleDriver + jdbc:oracle:thin:@localhost:1521/freepdb1 + benchbase + password + TRANSACTION_SERIALIZABLE + 128 + + + 1 + + + 1 + + + + 10000 + 16.66,16.66,16.66,16.66,16.66,16.7 + + + + + + + CPU1 + + + CPU2 + + + IO1 + + + IO2 + + + Contention1 + + + Contention2 + + + + diff --git a/config/oracle/sample_seats_config.xml b/config/oracle/sample_seats_config.xml new file mode 100644 index 000000000..035e99638 --- /dev/null +++ b/config/oracle/sample_seats_config.xml @@ -0,0 +1,48 @@ + + + + + + ORACLE + oracle.jdbc.OracleDriver + jdbc:oracle:thin:@localhost:1521/freepdb1 + benchbase + password + TRANSACTION_SERIALIZABLE + 128 + + + 1 + + + 1 + + + + 10000 + 10, 10, 35, 20, 10, 15 + + + + + + + DeleteReservation + + + FindFlights + + + FindOpenSeats + + + NewReservation + + + UpdateCustomer + + + UpdateReservation + + + diff --git a/config/oracle/sample_sibench_config.xml b/config/oracle/sample_sibench_config.xml new file mode 100644 index 000000000..ca4b90ce5 --- /dev/null +++ b/config/oracle/sample_sibench_config.xml @@ -0,0 +1,35 @@ + + + + + + ORACLE + oracle.jdbc.OracleDriver + jdbc:oracle:thin:@localhost:1521/freepdb1 + benchbase + password + TRANSACTION_SERIALIZABLE + 128 + + 1 + + + 1 + + + + unlimited + 50,50 + + + + + + + MinRecord + + + UpdateRecord + + + diff --git a/config/oracle/sample_smallbank_config.xml b/config/oracle/sample_smallbank_config.xml new file mode 100644 index 000000000..236677cad --- /dev/null +++ b/config/oracle/sample_smallbank_config.xml @@ -0,0 +1,47 @@ + + + + + + ORACLE + oracle.jdbc.OracleDriver + jdbc:oracle:thin:@localhost:1521/freepdb1 + benchbase + password + TRANSACTION_SERIALIZABLE + 128 + + 1 + + + 1 + + + + 100 + 15,15,15,25,15,15 + + + + + + + Amalgamate + + + Balance + + + DepositChecking + + + SendPayment + + + TransactSavings + + + WriteCheck + + + diff --git a/config/oracle/sample_tatp_config.xml b/config/oracle/sample_tatp_config.xml new file mode 100644 index 000000000..233f4ccc5 --- /dev/null +++ b/config/oracle/sample_tatp_config.xml @@ -0,0 +1,51 @@ + + + + + + ORACLE + oracle.jdbc.OracleDriver + jdbc:oracle:thin:@localhost:1521/freepdb1 + benchbase + password + TRANSACTION_SERIALIZABLE + 128 + + + 1 + + + 1 + + + + 10000 + 2, 35, 10, 35, 2, 14, 2 + + + + + + + DeleteCallForwarding + + + GetAccessData + + + GetNewDestination + + + GetSubscriberData + + + InsertCallForwarding + + + UpdateLocation + + + UpdateSubscriberData + + + diff --git a/config/oracle/sample_tpcc_config.xml b/config/oracle/sample_tpcc_config.xml new file mode 100644 index 000000000..6ced76b9c --- /dev/null +++ b/config/oracle/sample_tpcc_config.xml @@ -0,0 +1,57 @@ + + + + + + ORACLE + oracle.jdbc.OracleDriver + jdbc:oracle:thin:@localhost:1521/freepdb1 + benchbase + password + + TRANSACTION_SERIALIZABLE + 128 + 1 + + + 1 + + + 1 + + + + 10000 + 45,43,4,4,4 + + + + + + + NewOrder + + + + + Payment + + + + + OrderStatus + + + + + Delivery + + + + + StockLevel + + + + + diff --git a/config/oracle/sample_tpch_config.xml b/config/oracle/sample_tpch_config.xml new file mode 100644 index 000000000..ab71e0d9e --- /dev/null +++ b/config/oracle/sample_tpch_config.xml @@ -0,0 +1,141 @@ + + + + + + ORACLE + oracle.jdbc.OracleDriver + jdbc:oracle:thin:@localhost:1521/freepdb1 + benchbase + password + TRANSACTION_SERIALIZABLE + 1024 + + + 0.1 + + + + /benchmarks/tpch/gather_schema_stats_oracle.sql + + + 1 + + + true + unlimited + 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1 + + + true + unlimited + 0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1 + + + true + unlimited + 1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0 + + + + + + + odd + 1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0 + + + even + 0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1 + + + + Q1 + 1 + + + Q2 + 2 + + + Q3 + 3 + + + Q4 + 4 + + + Q5 + 5 + + + Q6 + 6 + + + Q7 + 7 + + + Q8 + 8 + + + Q9 + 9 + + + Q10 + 10 + + + Q11 + 11 + + + Q12 + 12 + + + Q13 + 13 + + + Q14 + 14 + + + Q15 + 15 + + + Q16 + 16 + + + Q17 + 17 + + + Q18 + 18 + + + Q19 + 19 + + + Q20 + 20 + + + Q21 + 21 + + + Q22 + 22 + + + diff --git a/config/oracle/sample_twitter_config.xml b/config/oracle/sample_twitter_config.xml new file mode 100644 index 000000000..9f1f1c6c5 --- /dev/null +++ b/config/oracle/sample_twitter_config.xml @@ -0,0 +1,51 @@ + + + + + + ORACLE + oracle.jdbc.OracleDriver + jdbc:oracle:thin:@localhost:1521/freepdb1 + benchbase + password + TRANSACTION_SERIALIZABLE + 128 + + + 1 + + + + data/twitter/twitter_tweetids.txt + data/twitter/twitter_user_ids.txt + 10.1. + + + 1 + + + + 10000 + 1,1,7,90,1 + + + + + + + GetTweet + + + GetTweetsFromFollowing + + + GetFollowers + + + GetUserTweets + + + InsertTweet + + + diff --git a/config/oracle/sample_voter_config.xml b/config/oracle/sample_voter_config.xml new file mode 100644 index 000000000..ce33f3d04 --- /dev/null +++ b/config/oracle/sample_voter_config.xml @@ -0,0 +1,32 @@ + + + + + + ORACLE + oracle.jdbc.OracleDriver + jdbc:oracle:thin:@localhost:1521/freepdb1 + benchbase + password + TRANSACTION_SERIALIZABLE + 128 + + 1 + + + 1 + + + + 10000 + 100 + + + + + + + Vote + + + diff --git a/config/oracle/sample_wikipedia_config.xml b/config/oracle/sample_wikipedia_config.xml new file mode 100644 index 000000000..a0f1e47f4 --- /dev/null +++ b/config/oracle/sample_wikipedia_config.xml @@ -0,0 +1,46 @@ + + + + + + ORACLE + oracle.jdbc.OracleDriver + jdbc:oracle:thin:@localhost:1521/freepdb1 + benchbase + password + + TRANSACTION_SERIALIZABLE + 1 + + + 1 + + + 1 + + + + 1000 + 1,1,7,90,1 + + + + + + + AddWatchList + + + RemoveWatchList + + + UpdatePage + + + GetPageAnonymous + + + GetPageAuthenticated + + + diff --git a/config/oracle/sample_ycsb_config.xml b/config/oracle/sample_ycsb_config.xml new file mode 100644 index 000000000..165d1f36c --- /dev/null +++ b/config/oracle/sample_ycsb_config.xml @@ -0,0 +1,49 @@ + + + + + + ORACLE + oracle.jdbc.OracleDriver + jdbc:oracle:thin:@localhost:1521/freepdb1 + benchbase + password + + TRANSACTION_SERIALIZABLE + 128 + + + 1 + + + 1 + + + + 10000 + 50,5,15,10,10,10 + + + + + + + ReadRecord + + + InsertRecord + + + ScanRecord + + + UpdateRecord + + + DeleteRecord + + + ReadModifyWriteRecord + + + diff --git a/docker/oracle/docker-compose.yml b/docker/oracle/docker-compose.yml new file mode 100644 index 000000000..1ac47285e --- /dev/null +++ b/docker/oracle/docker-compose.yml @@ -0,0 +1,18 @@ +# Copyright (c) 2023, Oracle and/or its affiliates. + +version: '3.5' + +services: + oracle: + image: container-registry.oracle.com/database/free:23.2.0.0 + container_name: oracle + ports: + - "1521:1521" + - "5500:5500" + environment: + - ORACLE_PWD=password + - ORACLE_CHARACTERSET=AL32UTF8 + volumes: + # This should be done at setup, but this image is already expanded for faster startup. The script only sets up + # a user so there is no issue rerunning the script multiple times + - "./setup:/opt/oracle/scripts/startup" \ No newline at end of file diff --git a/docker/oracle/down.sh b/docker/oracle/down.sh new file mode 100755 index 000000000..28a445caa --- /dev/null +++ b/docker/oracle/down.sh @@ -0,0 +1,8 @@ +#!/bin/bash +# Copyright (c) 2023, Oracle and/or its affiliates. + +set -eu +scriptdir=$(dirname "$(readlink -f "$0")") +cd "$scriptdir/" + +docker-compose down --remove-orphans --volumes diff --git a/docker/oracle/prune.sh b/docker/oracle/prune.sh new file mode 100755 index 000000000..1276d2679 --- /dev/null +++ b/docker/oracle/prune.sh @@ -0,0 +1,8 @@ +#!/bin/bash +# Copyright (c) 2023, Oracle and/or its affiliates. + +set -eu +scriptdir=$(dirname "$(readlink -f "$0")") +cd "$scriptdir/" + +docker system prune -a -f --volumes diff --git a/docker/oracle/setup/01_user.sql b/docker/oracle/setup/01_user.sql new file mode 100644 index 000000000..14b18b046 --- /dev/null +++ b/docker/oracle/setup/01_user.sql @@ -0,0 +1,8 @@ +-- Copyright (c) 2023, Oracle and/or its affiliates. +-- Non-DBA user specified in sample config file +alter session set container = FREEPDB1; +create user benchbase identified by password; +GRANT CONNECT, RESOURCE, UNLIMITED TABLESPACE TO benchbase; +-- Resourcestresser benchmark requires these two packages from SYS +GRANT EXECUTE ON DBMS_CRYPTO TO benchbase; +GRANT EXECUTE ON DBMS_LOCK TO benchbase; diff --git a/docker/oracle/up.sh b/docker/oracle/up.sh new file mode 100755 index 000000000..f285b5d1f --- /dev/null +++ b/docker/oracle/up.sh @@ -0,0 +1,8 @@ +#!/bin/bash +# Copyright (c) 2023, Oracle and/or its affiliates. + +set -eu +scriptdir=$(dirname "$(readlink -f "$0")") +cd "$scriptdir/" + +docker-compose up -d diff --git a/pom.xml b/pom.xml index f33d51b32..7e4deb8ce 100644 --- a/pom.xml +++ b/pom.xml @@ -1,4 +1,5 @@ + 4.0.0 @@ -88,6 +89,22 @@ + + + oracle + + oracle + + + + + com.oracle.database.jdbc + ojdbc11 + 21.5.0.0 + runtime + + + mariadb diff --git a/src/main/java/com/oltpbenchmark/DBWorkload.java b/src/main/java/com/oltpbenchmark/DBWorkload.java index 15b05fddc..f28ebbc96 100644 --- a/src/main/java/com/oltpbenchmark/DBWorkload.java +++ b/src/main/java/com/oltpbenchmark/DBWorkload.java @@ -15,6 +15,7 @@ * */ +/* Copyright (c) 2023, Oracle and/or its affiliates. */ package com.oltpbenchmark; @@ -455,6 +456,21 @@ public static void main(String[] args) throws Exception { LOG.debug("Skipping loading benchmark database records"); } + if (xmlConfig.containsKey("afterload")) { + try { + for (BenchmarkModule benchmark : benchList) { + LOG.info("Running script for {} database...", benchmark.getBenchmarkName().toUpperCase()); + runScriptAfterLoad(benchmark, xmlConfig.getString("afterload")); + LOG.info("Finished running script for {} database...", benchmark.getBenchmarkName().toUpperCase()); + } + } catch (Throwable ex) { + LOG.error("Unexpected error when running script", ex); + System.exit(1); + } + } else { + LOG.debug("Skipping script after database loading"); + } + // Execute Workload if (isBooleanOptionSet(argsLine, "execute")) { // Bombs away! @@ -631,6 +647,11 @@ private static void runLoader(BenchmarkModule bench) throws SQLException, Interr bench.loadDatabase(); } + private static void runScriptAfterLoad(BenchmarkModule bench, String scriptPath) throws SQLException, IOException { + LOG.debug(String.format("Running script %s after loading data for %s Database", scriptPath, bench)); + bench.runScript(scriptPath); + } + private static Results runWorkload(List benchList, int intervalMonitor) throws IOException { List> workers = new ArrayList<>(); List workConfs = new ArrayList<>(); diff --git a/src/main/java/com/oltpbenchmark/api/BenchmarkModule.java b/src/main/java/com/oltpbenchmark/api/BenchmarkModule.java index 247546483..d834c28e5 100644 --- a/src/main/java/com/oltpbenchmark/api/BenchmarkModule.java +++ b/src/main/java/com/oltpbenchmark/api/BenchmarkModule.java @@ -15,6 +15,7 @@ * */ +/* Copyright (c) 2023, Oracle and/or its affiliates. */ package com.oltpbenchmark.api; @@ -248,7 +249,14 @@ public final void createDatabase(DatabaseType dbType, Connection conn) throws SQ } } - + public final void runScript(String scriptPath) throws SQLException, IOException { + try (Connection conn = this.makeConnection()) { + DatabaseType dbType = this.workConf.getDatabaseType(); + ScriptRunner runner = new ScriptRunner(conn, true, true); + LOG.debug("Executing script [{}] for database type [{}]", scriptPath, dbType); + runner.runScript(scriptPath); + } + } /** * Invoke this benchmark's database loader */ diff --git a/src/main/java/com/oltpbenchmark/api/Procedure.java b/src/main/java/com/oltpbenchmark/api/Procedure.java index 35357e95f..60c07f723 100644 --- a/src/main/java/com/oltpbenchmark/api/Procedure.java +++ b/src/main/java/com/oltpbenchmark/api/Procedure.java @@ -15,6 +15,7 @@ * */ +/* Copyright (c) 2023, Oracle and/or its affiliates. */ package com.oltpbenchmark.api; import com.oltpbenchmark.jdbc.AutoIncrementPreparedStatement; @@ -36,7 +37,15 @@ public abstract class Procedure { private static final Logger LOG = LoggerFactory.getLogger(Procedure.class); private final String procName; - private DatabaseType dbType; + /** + * LoadConfig procedure in auctionmark and seats benchmark contains CLOB on Oracle config + * + * For other databases, calling SQLUtil.getString(Object) after connection close is fine, but for + * Oracle config, CLOBS needs to be resolved into String when the connection is open. Making this field + * protected allows LoadConfig procedure to determine current database type, and decide if it should perform + * the conversion. + */ + protected DatabaseType dbType; private Map name_stmt_xref; /** diff --git a/src/main/java/com/oltpbenchmark/benchmarks/auctionmark/AuctionMarkLoader.java b/src/main/java/com/oltpbenchmark/benchmarks/auctionmark/AuctionMarkLoader.java index ab373ac77..1491b127f 100644 --- a/src/main/java/com/oltpbenchmark/benchmarks/auctionmark/AuctionMarkLoader.java +++ b/src/main/java/com/oltpbenchmark/benchmarks/auctionmark/AuctionMarkLoader.java @@ -15,6 +15,7 @@ * */ +/* Copyright (c) 2023, Oracle and/or its affiliates. */ package com.oltpbenchmark.benchmarks.auctionmark; import com.oltpbenchmark.api.BenchmarkModule; @@ -40,6 +41,8 @@ import java.util.concurrent.TimeUnit; import java.util.regex.Pattern; +import static com.oltpbenchmark.types.DatabaseType.ORACLE; + /** * @author pavlo * @author visawee @@ -439,7 +442,8 @@ protected int populateRandomColumns(Object[] row) { // STRINGS for (Column catalog_col : this.random_str_cols) { int size = catalog_col.getSize(); - row[catalog_col.getIndex()] = profile.rng.astring(profile.rng.nextInt(size - 1), size); + // This can generate an empty string which is treated as NULL in Oracle DB + row[catalog_col.getIndex()] = profile.rng.astring(profile.rng.nextInt(getDatabaseType() == ORACLE ? 1 : 0, size - 1), size); cols++; } diff --git a/src/main/java/com/oltpbenchmark/benchmarks/auctionmark/AuctionMarkProfile.java b/src/main/java/com/oltpbenchmark/benchmarks/auctionmark/AuctionMarkProfile.java index fb3a38f00..9c6f20197 100644 --- a/src/main/java/com/oltpbenchmark/benchmarks/auctionmark/AuctionMarkProfile.java +++ b/src/main/java/com/oltpbenchmark/benchmarks/auctionmark/AuctionMarkProfile.java @@ -15,6 +15,7 @@ * */ +/* Copyright (c) 2023, Oracle and/or its affiliates. */ package com.oltpbenchmark.benchmarks.auctionmark; @@ -286,7 +287,7 @@ private AuctionMarkProfile copyProfile(AuctionMarkWorker worker, AuctionMarkProf this.items_per_category = other.items_per_category; this.gag_ids = other.gag_ids; - // Initialize the UserIdGenerator so we can figure out whether our + // Initialize the UserIdGenerator so we can figure out whether our // client should even have these ids this.initializeUserIdGenerator(this.client_id); @@ -861,7 +862,7 @@ private ItemInfo getRandomItem(LinkedList itemSet, boolean needCurrent continue; } - // If they want an item that is ending in the future, then we compare it with + // If they want an item that is ending in the future, then we compare it with // the current timestamp if (needFutureEndDate) { boolean compareTo = (temp.getEndDate().compareTo(currentTime) < 0); diff --git a/src/main/java/com/oltpbenchmark/benchmarks/auctionmark/procedures/LoadConfig.java b/src/main/java/com/oltpbenchmark/benchmarks/auctionmark/procedures/LoadConfig.java index 67bf2d14f..3476c899e 100644 --- a/src/main/java/com/oltpbenchmark/benchmarks/auctionmark/procedures/LoadConfig.java +++ b/src/main/java/com/oltpbenchmark/benchmarks/auctionmark/procedures/LoadConfig.java @@ -15,12 +15,14 @@ * */ +/* Copyright (c) 2023, Oracle and/or its affiliates. */ package com.oltpbenchmark.benchmarks.auctionmark.procedures; import com.oltpbenchmark.api.Procedure; import com.oltpbenchmark.api.SQLStmt; import com.oltpbenchmark.benchmarks.auctionmark.AuctionMarkConstants; import com.oltpbenchmark.benchmarks.auctionmark.util.ItemStatus; +import com.oltpbenchmark.types.DatabaseType; import com.oltpbenchmark.util.SQLUtil; import java.sql.Connection; @@ -83,6 +85,12 @@ public Config run(Connection conn) throws SQLException { try (PreparedStatement preparedStatement = this.getPreparedStatement(conn, getConfigProfile)) { try (ResultSet resultSet = preparedStatement.executeQuery()) { configProfile = SQLUtil.toList(resultSet); + // CLOB needs to be done while connection is alive + if (dbType == DatabaseType.ORACLE) { + for (Object[] configProfileInstance: configProfile) { + configProfileInstance[3] = SQLUtil.clobToString(configProfileInstance[3]); + } + } } } diff --git a/src/main/java/com/oltpbenchmark/benchmarks/otmetrics/procedures/GetSessionRange.java b/src/main/java/com/oltpbenchmark/benchmarks/otmetrics/procedures/GetSessionRange.java index 171d543db..832d2ae8f 100644 --- a/src/main/java/com/oltpbenchmark/benchmarks/otmetrics/procedures/GetSessionRange.java +++ b/src/main/java/com/oltpbenchmark/benchmarks/otmetrics/procedures/GetSessionRange.java @@ -15,6 +15,8 @@ * */ +/* Copyright (c) 2023, Oracle and/or its affiliates. */ + package com.oltpbenchmark.benchmarks.otmetrics.procedures; import com.oltpbenchmark.api.Procedure; @@ -70,6 +72,7 @@ public List run(Connection conn, int source_id, int session_low, int s finalResults.add(arr); } } + stmt.close(); return (finalResults); } diff --git a/src/main/java/com/oltpbenchmark/benchmarks/resourcestresser/procedures/CPU1.java b/src/main/java/com/oltpbenchmark/benchmarks/resourcestresser/procedures/CPU1.java index a1f527c53..63dc06e24 100644 --- a/src/main/java/com/oltpbenchmark/benchmarks/resourcestresser/procedures/CPU1.java +++ b/src/main/java/com/oltpbenchmark/benchmarks/resourcestresser/procedures/CPU1.java @@ -15,6 +15,8 @@ * */ +/* Copyright (c) 2023, Oracle and/or its affiliates. */ + package com.oltpbenchmark.benchmarks.resourcestresser.procedures; import com.oltpbenchmark.api.Procedure; @@ -36,7 +38,7 @@ public class CPU1 extends Procedure { for (int i = 1; i <= ResourceStresserWorker.CPU1_nestedLevel; ++i) { complexClause = "md5(concat(" + complexClause + ",?))"; } - cpuSelect = new SQLStmt("SELECT count(*) FROM (SELECT " + complexClause + " FROM " + ResourceStresserConstants.TABLENAME_CPUTABLE + " WHERE empid >= 0 AND empid < 100) AS T1"); + cpuSelect = new SQLStmt("SELECT count(*) FROM (SELECT " + complexClause + " FROM " + ResourceStresserConstants.TABLENAME_CPUTABLE + " WHERE empid >= 0 AND empid < 100) T1"); } public void run(Connection conn, int howManyPerTransaction, int sleepLength, int nestedLevel) throws SQLException { diff --git a/src/main/java/com/oltpbenchmark/benchmarks/resourcestresser/procedures/CPU2.java b/src/main/java/com/oltpbenchmark/benchmarks/resourcestresser/procedures/CPU2.java index 42d67f3e5..49b29541b 100644 --- a/src/main/java/com/oltpbenchmark/benchmarks/resourcestresser/procedures/CPU2.java +++ b/src/main/java/com/oltpbenchmark/benchmarks/resourcestresser/procedures/CPU2.java @@ -15,6 +15,8 @@ * */ +/* Copyright (c) 2023, Oracle and/or its affiliates. */ + package com.oltpbenchmark.benchmarks.resourcestresser.procedures; import com.oltpbenchmark.api.Procedure; @@ -36,7 +38,7 @@ public class CPU2 extends Procedure { for (int i = 1; i <= ResourceStresserWorker.CPU2_nestedLevel; ++i) { complexClause = "md5(concat(" + complexClause + ",?))"; } - cpuSelect = new SQLStmt("SELECT count(*) FROM (SELECT " + complexClause + " FROM " + ResourceStresserConstants.TABLENAME_CPUTABLE + " WHERE empid >= 0 AND empid < 100) AS T2"); + cpuSelect = new SQLStmt("SELECT count(*) FROM (SELECT " + complexClause + " FROM " + ResourceStresserConstants.TABLENAME_CPUTABLE + " WHERE empid >= 0 AND empid < 100) T2"); } public void run(Connection conn, int howManyPerTransaction, int sleepLength, int nestedLevel) throws SQLException { diff --git a/src/main/java/com/oltpbenchmark/benchmarks/seats/procedures/LoadConfig.java b/src/main/java/com/oltpbenchmark/benchmarks/seats/procedures/LoadConfig.java index 1facacd11..fb995aab7 100644 --- a/src/main/java/com/oltpbenchmark/benchmarks/seats/procedures/LoadConfig.java +++ b/src/main/java/com/oltpbenchmark/benchmarks/seats/procedures/LoadConfig.java @@ -20,6 +20,7 @@ import com.oltpbenchmark.api.Procedure; import com.oltpbenchmark.api.SQLStmt; import com.oltpbenchmark.benchmarks.seats.SEATSConstants; +import com.oltpbenchmark.types.DatabaseType; import com.oltpbenchmark.util.SQLUtil; import java.sql.Connection; @@ -67,6 +68,12 @@ public Config run(Connection conn) throws SQLException { try (PreparedStatement preparedStatement = this.getPreparedStatement(conn, getConfigProfile)) { try (ResultSet resultSet = preparedStatement.executeQuery()) { configProfile = SQLUtil.toList(resultSet); + // CLOB needs to be done while connection is alive + if (dbType == DatabaseType.ORACLE) { + for (Object[] configProfileInstance: configProfile) { + configProfileInstance[1] = SQLUtil.clobToString(configProfileInstance[1]); + } + } } } @@ -74,6 +81,12 @@ public Config run(Connection conn) throws SQLException { try (PreparedStatement preparedStatement = this.getPreparedStatement(conn, getConfigHistogram)) { try (ResultSet resultSet = preparedStatement.executeQuery()) { histogram = SQLUtil.toList(resultSet); + // CLOB needs to be done while connection is alive + if (dbType == DatabaseType.ORACLE) { + for (Object[] histogramInstance: histogram) { + histogramInstance[1] = SQLUtil.clobToString(histogramInstance[1]); + } + } } } diff --git a/src/main/java/com/oltpbenchmark/benchmarks/voter/procedures/Vote.java b/src/main/java/com/oltpbenchmark/benchmarks/voter/procedures/Vote.java index 1694fa451..3c726a683 100644 --- a/src/main/java/com/oltpbenchmark/benchmarks/voter/procedures/Vote.java +++ b/src/main/java/com/oltpbenchmark/benchmarks/voter/procedures/Vote.java @@ -44,6 +44,8 @@ // number of allowed votes. // +/* Copyright (c) 2023, Oracle and/or its affiliates. */ + package com.oltpbenchmark.benchmarks.voter.procedures; import com.oltpbenchmark.api.Procedure; @@ -65,25 +67,24 @@ public class Vote extends Procedure { // Checks if the vote is for a valid contestant public final SQLStmt checkContestantStmt = new SQLStmt( - "SELECT contestant_number FROM " + TABLENAME_CONTESTANTS + " WHERE contestant_number = ?;" + "SELECT contestant_number FROM " + TABLENAME_CONTESTANTS + " WHERE contestant_number = ?" ); // Checks if the voter has exceeded their allowed number of votes public final SQLStmt checkVoterStmt = new SQLStmt( - "SELECT COUNT(*) FROM " + TABLENAME_VOTES + " WHERE phone_number = ?;" + "SELECT COUNT(*) FROM " + TABLENAME_VOTES + " WHERE phone_number = ?" ); // Checks an area code to retrieve the corresponding state public final SQLStmt checkStateStmt = new SQLStmt( - "SELECT state FROM " + TABLENAME_LOCATIONS + " WHERE area_code = ?;" + "SELECT state FROM " + TABLENAME_LOCATIONS + " WHERE area_code = ?" ); // Records a vote public final SQLStmt insertVoteStmt = new SQLStmt( "INSERT INTO " + TABLENAME_VOTES + " (vote_id, phone_number, state, contestant_number, created) " + - "VALUES (?, ?, ?, ?, NOW());" + "VALUES (?, ?, ?, ?, NOW())" ); - public long run(Connection conn, long voteId, long phoneNumber, int contestantNumber, long maxVotesPerPhoneNumber) throws SQLException { try (PreparedStatement ps = getPreparedStatement(conn, checkContestantStmt)) { diff --git a/src/main/java/com/oltpbenchmark/benchmarks/wikipedia/WikipediaLoader.java b/src/main/java/com/oltpbenchmark/benchmarks/wikipedia/WikipediaLoader.java index 3509e4012..bd4662ffd 100644 --- a/src/main/java/com/oltpbenchmark/benchmarks/wikipedia/WikipediaLoader.java +++ b/src/main/java/com/oltpbenchmark/benchmarks/wikipedia/WikipediaLoader.java @@ -15,6 +15,8 @@ * */ +/* Copyright (c) 2023, Oracle and/or its affiliates. */ + package com.oltpbenchmark.benchmarks.wikipedia; import com.oltpbenchmark.api.Loader; @@ -104,20 +106,22 @@ public void load(Connection conn) throws SQLException { SQLUtil.setIdentityInsert(conn, getDatabaseType(), catalog_tbl, true); String sql = SQLUtil.getInsertSQL(catalog_tbl, benchmark.getWorkloadConfiguration().getDatabaseType()); + // Empty string which is treated as NULL in Oracle DB + String dummyString = getDatabaseType() == DatabaseType.ORACLE ? " " : ""; // load anonymous user try (PreparedStatement stmt = conn.prepareStatement(sql)) { int param = 1; stmt.setInt(param++, WikipediaConstants.ANONYMOUS_USER_ID); // user_id stmt.setString(param++, "Anonymous"); // user_name - stmt.setString(param++, ""); // user_real_name - stmt.setString(param++, ""); // user_password - stmt.setString(param++, ""); // user_newpassword + stmt.setString(param++, dummyString); // user_real_name + stmt.setString(param++, dummyString); // user_password + stmt.setString(param++, dummyString); // user_newpassword stmt.setNull(param++, JDBCType.VARCHAR.getVendorTypeNumber()); // user_newpass_time - stmt.setString(param++, ""); // user_email - stmt.setString(param++, ""); // user_options - stmt.setString(param++, ""); // user_touched - stmt.setString(param++, ""); // user_token + stmt.setString(param++, dummyString); // user_email + stmt.setString(param++, dummyString); // user_options + stmt.setString(param++, dummyString); // user_touched + stmt.setString(param++, dummyString); // user_token stmt.setNull(param++, JDBCType.VARCHAR.getVendorTypeNumber()); // user_email_authenticated stmt.setNull(param++, JDBCType.VARCHAR.getVendorTypeNumber()); // user_email_token stmt.setNull(param++, JDBCType.VARCHAR.getVendorTypeNumber()); // user_email_token_expires diff --git a/src/main/java/com/oltpbenchmark/util/SQLUtil.java b/src/main/java/com/oltpbenchmark/util/SQLUtil.java index c0cd7e8c9..e984dd4d4 100644 --- a/src/main/java/com/oltpbenchmark/util/SQLUtil.java +++ b/src/main/java/com/oltpbenchmark/util/SQLUtil.java @@ -15,6 +15,8 @@ * */ +/* Copyright (c) 2023, Oracle and/or its affiliates. */ + package com.oltpbenchmark.util; import com.oltpbenchmark.api.BenchmarkModule; @@ -24,6 +26,8 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; +import java.lang.reflect.InvocationTargetException; +import java.lang.reflect.Method; import java.math.BigDecimal; import java.sql.Date; import java.sql.*; @@ -109,6 +113,15 @@ public static Double getDouble(Object obj) { return (null); } + public static String clobToString(Object obj) { + try { + Clob clob = (Clob) obj; + return clob.getSubString(1, (int) clob.length()); + } catch (SQLException e) { + throw new RuntimeException(e); + } + } + public static String getString(Object obj) { if (obj == null) { return (null); @@ -116,6 +129,8 @@ public static String getString(Object obj) { if (obj instanceof String) { return (String) obj; + } else if (obj instanceof BigDecimal bigDecimal) { + return bigDecimal.toString(); } LOG.warn("BAD BAD BAD: returning null because getString does not support {}", obj.getClass()); @@ -123,6 +138,21 @@ public static String getString(Object obj) { return (null); } + private static final Class ORACLE_TIMESTAMP; + private static final Method TIMESTAMP_VALUE_METHOD; + static { + Method timestampValueMethod; + Class oracleTimestamp; + try { + oracleTimestamp = Class.forName("oracle.sql.TIMESTAMP"); + timestampValueMethod = oracleTimestamp.getDeclaredMethod("timestampValue"); + } catch (ClassNotFoundException | NoSuchMethodException e) { + oracleTimestamp = null; + timestampValueMethod = null; + } + TIMESTAMP_VALUE_METHOD = timestampValueMethod; + ORACLE_TIMESTAMP = oracleTimestamp; + } /** * Return a double from the given object * Handles the different cases from the various DBMSs @@ -139,6 +169,12 @@ public static Timestamp getTimestamp(Object obj) { return (Timestamp) obj; } else if (obj instanceof Date) { return new Timestamp(((Date) obj).getTime()); + } else if (ORACLE_TIMESTAMP != null && ORACLE_TIMESTAMP.isInstance(obj)) { + try { + return (Timestamp) TIMESTAMP_VALUE_METHOD.invoke(ORACLE_TIMESTAMP.cast(obj)); + } catch (IllegalAccessException | InvocationTargetException e) { + throw new RuntimeException(e); + } } Long timestamp = SQLUtil.getLong(obj); @@ -286,6 +322,7 @@ public static Object castValue(int sqlType, String value) { } case Types.DECIMAL: case Types.REAL: + case Types.NUMERIC: case Types.DOUBLE: { ret = Double.parseDouble(value); break; diff --git a/src/main/resources/benchmarks/auctionmark/ddl-oracle.sql b/src/main/resources/benchmarks/auctionmark/ddl-oracle.sql index c6fbbe845..4e1f932d9 100644 --- a/src/main/resources/benchmarks/auctionmark/ddl-oracle.sql +++ b/src/main/resources/benchmarks/auctionmark/ddl-oracle.sql @@ -1,4 +1,5 @@ --- Drop all tables +-- Copyright (c) 2023, Oracle and/or its affiliates. + BEGIN EXECUTE IMMEDIATE 'DROP TABLE CONFIG_PROFILE'; EXCEPTION WHEN OTHERS THEN IF SQLCODE != -942 THEN RAISE; END IF; END;; BEGIN EXECUTE IMMEDIATE 'DROP TABLE REGION CASCADE CONSTRAINTS'; EXCEPTION WHEN OTHERS THEN IF SQLCODE != -942 THEN RAISE; END IF; END;; BEGIN EXECUTE IMMEDIATE 'DROP TABLE USERACCT CASCADE CONSTRAINTS'; EXCEPTION WHEN OTHERS THEN IF SQLCODE != -942 THEN RAISE; END IF; END;; @@ -18,7 +19,7 @@ BEGIN EXECUTE IMMEDIATE 'DROP TABLE USERACCT_ITEM CASCADE CONSTRAINTS'; EXCEPTIO BEGIN EXECUTE IMMEDIATE 'DROP TABLE USERACCT_WATCH CASCADE CONSTRAINTS'; EXCEPTION WHEN OTHERS THEN IF SQLCODE != -942 THEN RAISE; END IF; END;; -- Create tables --- ================================================================ +-- ================================================================ -- CONFIG_PROFILE -- ================================================================ CREATE TABLE CONFIG_PROFILE ( @@ -35,14 +36,14 @@ CREATE TABLE CONFIG_PROFILE ( -- r_name Region's name -- ================================================================ CREATE TABLE REGION ( - r_id INT NOT NULL, - r_name VARCHAR(32), + r_id NUMBER(19, 0) NOT NULL, + r_name VARCHAR2(32), PRIMARY KEY (r_id) ); -- ================================================================ -- USERACCT --- Represents user accounts +-- Represents user accounts -- u_id User ID -- u_firstname User's first name -- u_lastname User's last name @@ -54,42 +55,42 @@ CREATE TABLE REGION ( -- u_r_id User's region ID -- ================================================================ CREATE TABLE USERACCT ( - u_id INT NOT NULL, - u_rating INT NOT NULL, + u_id VARCHAR2(128) NOT NULL, + u_rating NUMBER(19, 0) NOT NULL, u_balance FLOAT NOT NULL, u_comments INTEGER DEFAULT 0, - u_r_id INT NOT NULL REFERENCES REGION (r_id), + u_r_id NUMBER(19, 0) NOT NULL REFERENCES REGION (r_id), u_created TIMESTAMP, u_updated TIMESTAMP, - u_sattr0 VARCHAR(64), - u_sattr1 VARCHAR(64), - u_sattr2 VARCHAR(64), - u_sattr3 VARCHAR(64), - u_sattr4 VARCHAR(64), - u_sattr5 VARCHAR(64), - u_sattr6 VARCHAR(64), - u_sattr7 VARCHAR(64), - u_iattr0 INT DEFAULT NULL, - u_iattr1 INT DEFAULT NULL, - u_iattr2 INT DEFAULT NULL, - u_iattr3 INT DEFAULT NULL, - u_iattr4 INT DEFAULT NULL, - u_iattr5 INT DEFAULT NULL, - u_iattr6 INT DEFAULT NULL, - u_iattr7 INT DEFAULT NULL, + u_sattr0 VARCHAR2(64), + u_sattr1 VARCHAR2(64), + u_sattr2 VARCHAR2(64), + u_sattr3 VARCHAR2(64), + u_sattr4 VARCHAR2(64), + u_sattr5 VARCHAR2(64), + u_sattr6 VARCHAR2(64), + u_sattr7 VARCHAR2(64), + u_iattr0 NUMBER(19, 0) DEFAULT NULL, + u_iattr1 NUMBER(19, 0) DEFAULT NULL, + u_iattr2 NUMBER(19, 0) DEFAULT NULL, + u_iattr3 NUMBER(19, 0) DEFAULT NULL, + u_iattr4 NUMBER(19, 0) DEFAULT NULL, + u_iattr5 NUMBER(19, 0) DEFAULT NULL, + u_iattr6 NUMBER(19, 0) DEFAULT NULL, + u_iattr7 NUMBER(19, 0) DEFAULT NULL, PRIMARY KEY (u_id) ); CREATE INDEX IDX_USERACCT_REGION ON USERACCT (u_id, u_r_id); -- ================================================================ -- USERACCT_ATTRIBUTES --- Represents user's attributes +-- Represents user's attributes -- ================================================================ CREATE TABLE USERACCT_ATTRIBUTES ( - ua_id INT NOT NULL, - ua_u_id INT NOT NULL REFERENCES USERACCT (u_id), - ua_name VARCHAR(32) NOT NULL, - ua_value VARCHAR(32) NOT NULL, + ua_id NUMBER(19, 0) NOT NULL, + ua_u_id VARCHAR2(128) NOT NULL REFERENCES USERACCT (u_id), + ua_name VARCHAR2(32) NOT NULL, + ua_value VARCHAR2(32) NOT NULL, u_created TIMESTAMP, PRIMARY KEY (ua_id, ua_u_id) ); @@ -102,9 +103,9 @@ CREATE TABLE USERACCT_ATTRIBUTES ( -- c_parent_id Parent category's ID -- ================================================================ CREATE TABLE CATEGORY ( - c_id INT NOT NULL, - c_name VARCHAR(50), - c_parent_id INT REFERENCES CATEGORY (c_id), + c_id NUMBER(19, 0) NOT NULL, + c_name VARCHAR2(50), + c_parent_id NUMBER(19, 0) REFERENCES CATEGORY (c_id), PRIMARY KEY (c_id) ); @@ -116,9 +117,9 @@ CREATE TABLE CATEGORY ( -- gag_name Global attribute group's name -- ================================================================ CREATE TABLE GLOBAL_ATTRIBUTE_GROUP ( - gag_id INT NOT NULL, - gag_c_id INT NOT NULL REFERENCES CATEGORY (c_id), - gag_name VARCHAR(100) NOT NULL, + gag_id VARCHAR2(128) NOT NULL, + gag_c_id NUMBER(19, 0) NOT NULL REFERENCES CATEGORY (c_id), + gag_name VARCHAR2(100) NOT NULL, PRIMARY KEY (gag_id) ); @@ -131,9 +132,9 @@ CREATE TABLE GLOBAL_ATTRIBUTE_GROUP ( -- gav_name Global attribute value's name -- ================================================================ CREATE TABLE GLOBAL_ATTRIBUTE_VALUE ( - gav_id INT NOT NULL, - gav_gag_id INT NOT NULL REFERENCES GLOBAL_ATTRIBUTE_GROUP (gag_id), - gav_name VARCHAR(100) NOT NULL, + gav_id VARCHAR2(128) NOT NULL, + gav_gag_id VARCHAR2(128) NOT NULL REFERENCES GLOBAL_ATTRIBUTE_GROUP (gag_id), + gav_name VARCHAR2(100) NOT NULL, PRIMARY KEY (gav_id, gav_gag_id) ); @@ -156,31 +157,31 @@ CREATE TABLE GLOBAL_ATTRIBUTE_VALUE ( -- i_status Items' status (0 = open, 1 = wait for purchase, 2 = close) -- ================================================================ CREATE TABLE ITEM ( - i_id INT NOT NULL, - i_u_id INT NOT NULL REFERENCES USERACCT (u_id), - i_c_id INT NOT NULL REFERENCES CATEGORY (c_id), - i_name VARCHAR(100), - i_description VARCHAR(1024), - i_user_attributes VARCHAR(255) DEFAULT NULL, + i_id VARCHAR2(128) NOT NULL, + i_u_id VARCHAR2(128) NOT NULL REFERENCES USERACCT (u_id), + i_c_id NUMBER(19, 0) NOT NULL REFERENCES CATEGORY (c_id), + i_name VARCHAR2(100), + i_description VARCHAR2(1024), + i_user_attributes VARCHAR2(255) DEFAULT NULL, i_initial_price FLOAT NOT NULL, i_current_price FLOAT NOT NULL, - i_num_bids INT, - i_num_images INT, - i_num_global_attrs INT, - i_num_comments INT, + i_num_bids NUMBER(19, 0), + i_num_images NUMBER(19, 0), + i_num_global_attrs NUMBER(19, 0), + i_num_comments NUMBER(19, 0), i_start_date TIMESTAMP, i_end_date TIMESTAMP, i_status INT DEFAULT 0, i_created TIMESTAMP, i_updated TIMESTAMP, - i_iattr0 INT DEFAULT NULL, - i_iattr1 INT DEFAULT NULL, - i_iattr2 INT DEFAULT NULL, - i_iattr3 INT DEFAULT NULL, - i_iattr4 INT DEFAULT NULL, - i_iattr5 INT DEFAULT NULL, - i_iattr6 INT DEFAULT NULL, - i_iattr7 INT DEFAULT NULL, + i_iattr0 NUMBER(19, 0) DEFAULT NULL, + i_iattr1 NUMBER(19, 0) DEFAULT NULL, + i_iattr2 NUMBER(19, 0) DEFAULT NULL, + i_iattr3 NUMBER(19, 0) DEFAULT NULL, + i_iattr4 NUMBER(19, 0) DEFAULT NULL, + i_iattr5 NUMBER(19, 0) DEFAULT NULL, + i_iattr6 NUMBER(19, 0) DEFAULT NULL, + i_iattr7 NUMBER(19, 0) DEFAULT NULL, PRIMARY KEY (i_id, i_u_id) ); CREATE INDEX IDX_ITEM_SELLER ON ITEM (i_u_id); @@ -193,12 +194,12 @@ CREATE INDEX IDX_ITEM_SELLER ON ITEM (i_u_id); -- ia_gav_id Global attribute value's ID -- ================================================================ CREATE TABLE ITEM_ATTRIBUTE ( - ia_id INT NOT NULL, - ia_i_id INT NOT NULL, - ia_u_id INT NOT NULL, - ia_gav_id INT NOT NULL, - ia_gag_id INT NOT NULL, - ia_sattr0 VARCHAR(64) DEFAULT NULL, + ia_id VARCHAR2(128) NOT NULL, + ia_i_id VARCHAR2(128) NOT NULL, + ia_u_id VARCHAR2(128) NOT NULL, + ia_gav_id VARCHAR2(128) NOT NULL, + ia_gag_id VARCHAR2(128) NOT NULL, + ia_sattr0 VARCHAR2(64) DEFAULT NULL, FOREIGN KEY (ia_i_id, ia_u_id) REFERENCES ITEM (i_id, i_u_id), FOREIGN KEY (ia_gav_id, ia_gag_id) REFERENCES GLOBAL_ATTRIBUTE_VALUE (gav_id, gav_gag_id), PRIMARY KEY (ia_id, ia_i_id, ia_u_id) @@ -212,10 +213,10 @@ CREATE TABLE ITEM_ATTRIBUTE ( -- ii_path Image's path -- ================================================================ CREATE TABLE ITEM_IMAGE ( - ii_id INT NOT NULL, - ii_i_id INT NOT NULL, - ii_u_id INT NOT NULL, - ii_sattr0 VARCHAR(128) NOT NULL, + ii_id VARCHAR2(128) NOT NULL, + ii_i_id VARCHAR2(128) NOT NULL, + ii_u_id VARCHAR2(128) NOT NULL, + ii_sattr0 VARCHAR2(128) NOT NULL, FOREIGN KEY (ii_i_id, ii_u_id) REFERENCES ITEM (i_id, i_u_id), PRIMARY KEY (ii_id, ii_i_id, ii_u_id) ); @@ -231,17 +232,17 @@ CREATE TABLE ITEM_IMAGE ( -- ic_response Response from seller -- ================================================================ CREATE TABLE ITEM_COMMENT ( - ic_id INT NOT NULL, - ic_i_id INT NOT NULL, - ic_u_id INT NOT NULL, - ic_buyer_id INT NOT NULL REFERENCES USERACCT (u_id), - ic_question VARCHAR(128) NOT NULL, - ic_response VARCHAR(128) DEFAULT NULL, + ic_id NUMBER(19, 0) NOT NULL, + ic_i_id VARCHAR2(128) NOT NULL, + ic_u_id VARCHAR2(128) NOT NULL, + ic_buyer_id VARCHAR2(128) NOT NULL REFERENCES USERACCT (u_id), + ic_question VARCHAR2(128) NOT NULL, + ic_response VARCHAR2(128) DEFAULT NULL, ic_created TIMESTAMP, ic_updated TIMESTAMP, FOREIGN KEY (ic_i_id, ic_u_id) REFERENCES ITEM (i_id, i_u_id), PRIMARY KEY (ic_id, ic_i_id, ic_u_id) -); +); -- CREATE INDEX IDX_ITEM_COMMENT ON ITEM_COMMENT (ic_i_id, ic_u_id); -- ================================================================ @@ -256,10 +257,10 @@ CREATE TABLE ITEM_COMMENT ( -- ib_date Bid's date -- ================================================================ CREATE TABLE ITEM_BID ( - ib_id INT NOT NULL, - ib_i_id INT NOT NULL, - ib_u_id INT NOT NULL, - ib_buyer_id INT NOT NULL REFERENCES USERACCT (u_id), + ib_id NUMBER(19, 0) NOT NULL, + ib_i_id VARCHAR2(128) NOT NULL, + ib_u_id VARCHAR2(128) NOT NULL, + ib_buyer_id VARCHAR2(128) NOT NULL REFERENCES USERACCT (u_id), ib_bid FLOAT NOT NULL, ib_max_bid FLOAT NOT NULL, ib_created TIMESTAMP, @@ -273,11 +274,11 @@ CREATE TABLE ITEM_BID ( -- Cross-reference table to the current max bid for an auction -- ================================================================ CREATE TABLE ITEM_MAX_BID ( - imb_i_id INT NOT NULL, - imb_u_id INT NOT NULL, - imb_ib_id INT NOT NULL, - imb_ib_i_id INT NOT NULL, - imb_ib_u_id INT NOT NULL, + imb_i_id VARCHAR2(128) NOT NULL, + imb_u_id VARCHAR2(128) NOT NULL, + imb_ib_id NUMBER(19, 0) NOT NULL, + imb_ib_i_id VARCHAR2(128) NOT NULL, + imb_ib_u_id VARCHAR2(128) NOT NULL, imb_created TIMESTAMP, imb_updated TIMESTAMP, FOREIGN KEY (imb_i_id, imb_u_id) REFERENCES ITEM (i_id, i_u_id), @@ -293,15 +294,15 @@ CREATE TABLE ITEM_MAX_BID ( -- ip_date Purchase's date -- ================================================================ CREATE TABLE ITEM_PURCHASE ( - ip_id INT NOT NULL, - ip_ib_id INT NOT NULL, - ip_ib_i_id INT NOT NULL, - ip_ib_u_id INT NOT NULL, + ip_id NUMBER(19, 0) NOT NULL, + ip_ib_id NUMBER(19, 0) NOT NULL, + ip_ib_i_id VARCHAR2(128) NOT NULL, + ip_ib_u_id VARCHAR2(128) NOT NULL, ip_date TIMESTAMP, FOREIGN KEY (ip_ib_id, ip_ib_i_id, ip_ib_u_id) REFERENCES ITEM_BID (ib_id, ib_i_id, ib_u_id), - PRIMARY KEY (ip_id, ip_ib_id, ip_ib_i_id, ip_ib_u_id), - UNIQUE (ip_ib_id, ip_ib_i_id, ip_ib_u_id) + PRIMARY KEY (ip_id, ip_ib_id, ip_ib_i_id, ip_ib_u_id) ); +CREATE UNIQUE INDEX ids_item_purchase ON item_purchase(ip_ib_id, ip_ib_i_id, ip_ib_u_id); -- ================================================================ -- USERACCT_FEEDBACK @@ -315,13 +316,13 @@ CREATE TABLE ITEM_PURCHASE ( -- uf_comment Feedback by other user -- ================================================================ CREATE TABLE USERACCT_FEEDBACK ( - uf_u_id INT NOT NULL REFERENCES USERACCT (u_id), - uf_i_id INT NOT NULL, - uf_i_u_id INT NOT NULL, - uf_from_id INT NOT NULL REFERENCES USERACCT (u_id), + uf_u_id VARCHAR2(128) NOT NULL REFERENCES USERACCT (u_id), + uf_i_id VARCHAR2(128) NOT NULL, + uf_i_u_id VARCHAR2(128) NOT NULL, + uf_from_id VARCHAR2(128) NOT NULL REFERENCES USERACCT (u_id), uf_rating NUMBER(5,0) NOT NULL, uf_date TIMESTAMP, - uf_sattr0 VARCHAR(80) NOT NULL, + uf_sattr0 VARCHAR2(80) NOT NULL, FOREIGN KEY (uf_i_id, uf_i_u_id) REFERENCES ITEM (i_id, i_u_id), PRIMARY KEY (uf_u_id, uf_i_id, uf_i_u_id, uf_from_id), CHECK (uf_u_id <> uf_from_id) @@ -332,13 +333,13 @@ CREATE TABLE USERACCT_FEEDBACK ( -- The items that a user has recently purchased -- ================================================================ CREATE TABLE USERACCT_ITEM ( - ui_u_id INT NOT NULL REFERENCES USERACCT (u_id), - ui_i_id INT NOT NULL, - ui_i_u_id INT NOT NULL, - ui_ip_id INT, - ui_ip_ib_id INT, - ui_ip_ib_i_id INT, - ui_ip_ib_u_id INT, + ui_u_id VARCHAR2(128) NOT NULL REFERENCES USERACCT (u_id), + ui_i_id VARCHAR2(128) NOT NULL, + ui_i_u_id VARCHAR2(128) NOT NULL, + ui_ip_id NUMBER(19, 0), + ui_ip_ib_id NUMBER(19, 0), + ui_ip_ib_i_id VARCHAR2(128), + ui_ip_ib_u_id VARCHAR2(128), ui_created TIMESTAMP, FOREIGN KEY (ui_i_id, ui_i_u_id) REFERENCES ITEM (i_id, i_u_id), FOREIGN KEY (ui_ip_id, ui_ip_ib_id, ui_ip_ib_i_id, ui_ip_ib_u_id) REFERENCES ITEM_PURCHASE (ip_id, ip_ib_id, ip_ib_i_id, ip_ib_u_id), @@ -351,9 +352,9 @@ CREATE TABLE USERACCT_ITEM ( -- The items that a user is watching -- ================================================================ CREATE TABLE USERACCT_WATCH ( - uw_u_id INT NOT NULL REFERENCES USERACCT (u_id), - uw_i_id INT NOT NULL, - uw_i_u_id INT NOT NULL, + uw_u_id VARCHAR2(128) NOT NULL REFERENCES USERACCT (u_id), + uw_i_id VARCHAR2(128) NOT NULL, + uw_i_u_id VARCHAR2(128) NOT NULL, uw_created TIMESTAMP, FOREIGN KEY (uw_i_id, uw_i_u_id) REFERENCES ITEM (i_id, i_u_id), PRIMARY KEY (uw_u_id, uw_i_id, uw_i_u_id) diff --git a/src/main/resources/benchmarks/auctionmark/dialect-oracle.xml b/src/main/resources/benchmarks/auctionmark/dialect-oracle.xml index 983146fca..f3ce35eec 100644 --- a/src/main/resources/benchmarks/auctionmark/dialect-oracle.xml +++ b/src/main/resources/benchmarks/auctionmark/dialect-oracle.xml @@ -1,67 +1,85 @@ + - SELECT i_id, i_current_price, i_end_date, i_num_bids, i_status FROM ITEM, CONFIG_PROFILE WHERE i_status = ? AND i_end_date <= cfp_loader_start AND ROWNUM <= 1000 ORDER BY i_end_date ASC - SELECT i_id, i_current_price, i_end_date, i_num_bids, i_status FROM ITEM, CONFIG_PROFILE WHERE i_status = ? AND i_end_date > cfp_loader_start AND ROWNUM <= 1000 ORDER BY i_end_date ASC + + SELECT i_id, i_current_price, i_end_date, i_num_bids, i_status FROM ITEM, CONFIG_PROFILE + WHERE i_status = ? AND i_end_date <= cfp_loader_start + ORDER BY i_end_date ASC FETCH NEXT 5000 ROWS ONLY + + + SELECT i_id, i_current_price, i_end_date, i_num_bids, i_status FROM ITEM, CONFIG_PROFILE + WHERE i_status = ? AND i_end_date > cfp_loader_start + ORDER BY i_end_date ASC FETCH NEXT 5000 ROWS ONLY + + + + + SELECT * FROM item_bid WHERE imb_i_id = ? AND imb_u_id = ? + ORDER BY ib_bid DESC FETCH NEXT 1 ROWS ONLY + + + + + SELECT i_u_id, i_name, i_current_price, i_num_bids, i_end_date, i_status FROM item + WHERE i_start_date BETWEEN ? AND ? AND i_status = ? + ORDER BY i_id ASC FETCH NEXT 100 ROWS ONLY + - SELECT i_id, i_u_id,i_name,i_current_price,i_num_bids,i_end_date,i_status - uw_u_id, uw_created - FROM USERACCT_WATCH, ITEM - WHERE uw_u_id = ? - AND uw_i_id = i_id AND uw_i_u_id = i_u_id - AND ROWNUM <= 25 - ORDER BY i_end_date DESC + SELECT u_id, u_rating, u_created, u_balance, u_sattr0, u_sattr1, u_sattr2, u_sattr3, u_sattr4, r_name + FROM useracct, region + WHERE u_id = ? AND u_r_id = r_id - SELECT u_id, u_rating, u_sattr0, u_sattr1, uf_rating, uf_date, uf_sattr0 - FROM USERACCT , USERACCT_FEEDBACK - WHERE u_id = ? AND uf_u_id = u_id - AND ROWNUM <= 25 - ORDER BY uf_date DESC + SELECT u_id, u_rating, u_sattr0, u_sattr1, uf_rating, uf_date, uf_sattr0 + FROM USERACCT , USERACCT_FEEDBACK + WHERE u_id = ? AND uf_u_id = u_id + ORDER BY uf_date DESC + FETCH NEXT 25 ROWS ONLY - SELECT i_id, i_u_id,i_name,i_current_price,i_num_bids,i_end_date,i_status, - ic_id, ic_i_id, ic_u_id, ic_buyer_id, ic_question, ic_created - FROM ITEM , ITEM_COMMENT - WHERE i_u_id = ? AND i_status = ? - AND i_id = ic_i_id AND i_u_id = ic_u_id AND ic_response IS NULL - AND ROWNUM <= 25 - ORDER BY ic_created DESC + SELECT i_id, i_u_id,i_name,i_current_price,i_num_bids,i_end_date,i_status, + ic_id, ic_i_id, ic_u_id, ic_buyer_id, ic_question, ic_created + FROM ITEM , ITEM_COMMENT + WHERE i_u_id = ? AND i_status = ? + AND i_id = ic_i_id AND i_u_id = ic_u_id AND ic_response IS NULL + ORDER BY ic_created DESC + FETCH NEXT 25 ROWS ONLY - SELECT i_id, i_u_id,i_name,i_current_price,i_num_bids,i_end_date,i_status - FROM ITEM - WHERE i_u_id = ? - AND ROWNUM <= 25 - ORDER BY i_end_date DESC + SELECT i_id, i_u_id,i_name,i_current_price,i_num_bids,i_end_date,i_status + FROM ITEM + WHERE i_u_id = ? + ORDER BY i_end_date DESC + FETCH NEXT 25 ROWS ONLY - SELECT i_id, i_u_id,i_name,i_current_price,i_num_bids,i_end_date,i_status - FROM USERACCT_ITEM, ITEM - WHERE ui_u_id = ? - AND ui_i_id = i_id AND ui_i_u_id = i_u_id - AND ROWNUM <= 25 - ORDER BY i_end_date DESC + SELECT i_id, i_u_id,i_name,i_current_price,i_num_bids,i_end_date,i_status + FROM USERACCT_ITEM, ITEM + WHERE ui_u_id = ? + AND ui_i_id = i_id AND ui_i_u_id = i_u_id + ORDER BY i_end_date DESC + FETCH NEXT 25 ROWS ONLY - SELECT i_id, i_u_id,i_name,i_current_price,i_num_bids,i_end_date,i_status , uw_u_id, uw_created - FROM USERACCT_WATCH, ITEM - WHERE uw_u_id = ? - AND uw_i_id = i_id AND uw_i_u_id = i_u_id - AND ROWNUM <= 25 - ORDER BY i_end_date DESC + SELECT i_id, i_u_id,i_name,i_current_price,i_num_bids,i_end_date,i_status , uw_u_id, uw_created + FROM USERACCT_WATCH, ITEM + WHERE uw_u_id = ? + AND uw_i_id = i_id AND uw_i_u_id = i_u_id + ORDER BY i_end_date DESC + FETCH NEXT 25 ROWS ONLY - SELECT i_id, i_u_id,i_name,i_current_price,i_num_bids,i_end_date,i_status - FROM ITEM - WHERE (i_start_date BETWEEN ? AND ?) AND i_status = ? - AND ROWNUM <= 25 - ORDER BY i_id ASC + SELECT i_id, i_u_id,i_name,i_current_price,i_num_bids,i_end_date,i_status + FROM ITEM + WHERE (i_start_date BETWEEN ? AND ?) AND i_status = ? + ORDER BY i_id ASC + FETCH NEXT 100 ROWS ONLY diff --git a/src/main/resources/benchmarks/chbenchmark/ddl-oracle.sql b/src/main/resources/benchmarks/chbenchmark/ddl-oracle.sql new file mode 100644 index 000000000..2dc94be55 --- /dev/null +++ b/src/main/resources/benchmarks/chbenchmark/ddl-oracle.sql @@ -0,0 +1,35 @@ +-- Copyright (c) 2023, Oracle and/or its affiliates. + +BEGIN EXECUTE IMMEDIATE 'DROP TABLE supplier CASCADE CONSTRAINTS'; EXCEPTION WHEN OTHERS THEN IF SQLCODE != -942 THEN RAISE; END IF; END;; +BEGIN EXECUTE IMMEDIATE 'DROP TABLE nation CASCADE CONSTRAINTS'; EXCEPTION WHEN OTHERS THEN IF SQLCODE != -942 THEN RAISE; END IF; END;; +BEGIN EXECUTE IMMEDIATE 'DROP TABLE region CASCADE CONSTRAINTS'; EXCEPTION WHEN OTHERS THEN IF SQLCODE != -942 THEN RAISE; END IF; END;; + +CREATE TABLE region ( + r_regionkey int NOT NULL, + r_name char(55) NOT NULL, + r_comment char(152) NOT NULL, + PRIMARY KEY (r_regionkey) +); + +CREATE TABLE nation ( + n_nationkey int NOT NULL, + n_name char(25) NOT NULL, + n_regionkey int NOT NULL, + n_comment char(152) NOT NULL, + FOREIGN KEY (n_regionkey) REFERENCES region (r_regionkey) ON DELETE CASCADE, + PRIMARY KEY (n_nationkey) +); +CREATE INDEX n_rk ON nation (n_regionkey ASC); + +CREATE TABLE supplier ( + su_suppkey int NOT NULL, + su_name char(25) NOT NULL, + su_address varchar(40) NOT NULL, + su_nationkey int NOT NULL, + su_phone char(15) NOT NULL, + su_acctbal numeric(12, 2) NOT NULL, + su_comment char(101) NOT NULL, + FOREIGN KEY (su_nationkey) REFERENCES nation (n_nationkey) ON DELETE CASCADE, + PRIMARY KEY (su_suppkey) +); +CREATE INDEX s_nk ON supplier (su_nationkey ASC); diff --git a/src/main/resources/benchmarks/chbenchmark/dialect-oracle.xml b/src/main/resources/benchmarks/chbenchmark/dialect-oracle.xml new file mode 100644 index 000000000..3515dd771 --- /dev/null +++ b/src/main/resources/benchmarks/chbenchmark/dialect-oracle.xml @@ -0,0 +1,206 @@ + + + + + + + SELECT ol_number, sum(ol_quantity) AS sum_qty, sum(ol_amount) AS sum_amount, avg(ol_quantity) AS avg_qty, + avg(ol_amount) AS avg_amount, count(*) AS count_order + FROM order_line + WHERE ol_delivery_d > TO_DATE('2007-01-02 00:00:00', 'YYYY-MM-DD HH24:MI:SS') + GROUP BY ol_number + ORDER BY ol_number + + + + + SELECT su_suppkey, su_name, n_name, i_id, i_name, su_address, su_phone, su_comment + FROM item, supplier, stock, nation, region, ( + SELECT s_i_id AS m_i_id, MIN(s_quantity) AS m_s_quantity + FROM stock, supplier, nation, region + WHERE MOD((s_w_id*s_i_id), 10000) = su_suppkey AND su_nationkey = n_nationkey + AND n_regionkey = r_regionkey AND r_name LIKE 'Europ%' + GROUP BY s_i_id) m + WHERE i_id = s_i_id AND MOD((s_w_id * s_i_id), 10000) = su_suppkey AND su_nationkey = n_nationkey + AND n_regionkey = r_regionkey AND i_data LIKE '%b' AND r_name LIKE 'Europ%' AND i_id=m_i_id + AND s_quantity = m_s_quantity + ORDER BY n_name, su_name, i_id + + + + + SELECT ol_o_id, ol_w_id, ol_d_id, sum(ol_amount) AS revenue, o_entry_d + FROM customer, new_order, oorder, order_line + WHERE c_state LIKE 'A%' AND c_id = o_c_id AND c_w_id = o_w_id AND c_d_id = o_d_id AND no_w_id = o_w_id + AND no_d_id = o_d_id AND no_o_id = o_id AND ol_w_id = o_w_id AND ol_d_id = o_d_id AND ol_o_id = o_id + AND o_entry_d > TO_DATE('2007-01-02 00:00:00', 'YYYY-MM-DD HH24:MI:SS') + GROUP BY ol_o_id, ol_w_id, ol_d_id, o_entry_d + ORDER BY revenue DESC , o_entry_d + + + + + SELECT n_name, sum(ol_amount) AS revenue + FROM customer, oorder, order_line, stock, supplier, nation, region + WHERE c_id = o_c_id AND c_w_id = o_w_id AND c_d_id = o_d_id AND ol_o_id = o_id AND ol_w_id = o_w_id + AND ol_d_id=o_d_id AND ol_w_id = s_w_id AND ol_i_id = s_i_id + AND MOD((s_w_id * s_i_id), 10000) = su_suppkey + AND ascii(substr(c_state, 1, 1)) = su_nationkey AND su_nationkey = n_nationkey AND n_regionkey = r_regionkey AND r_name = 'Europe' + AND o_entry_d >= TO_DATE('2007-01-02 00:00:00', 'YYYY-MM-DD HH24:MI:SS') + GROUP BY n_name ORDER BY revenue DESC + + + + + SELECT sum(ol_amount) AS revenue FROM order_line WHERE ol_delivery_d >= to_date('1999-01-01 00:00:00', 'YYYY-MM-DD HH24:MI:SS') + AND to_date('2020-01-01 00:00:00', 'YYYY-MM-DD HH24:MI:SS') > ol_delivery_d AND ol_quantity BETWEEN 1 AND 100000 + + + + + SELECT su_nationkey AS supp_nation, substr(c_state, 1, 1) AS cust_nation, extract(YEAR FROM o_entry_d) AS l_year, + sum(ol_amount) AS revenue + FROM supplier, stock, order_line, oorder, customer, nation n1, nation n2 + WHERE ol_supply_w_id = s_w_id AND ol_i_id = s_i_id AND MOD ((s_w_id * s_i_id), 10000) = su_suppkey + AND ol_w_id = o_w_id AND ol_d_id = o_d_id AND ol_o_id = o_id AND c_id = o_c_id AND c_w_id = o_w_id + AND c_d_id = o_d_id AND su_nationkey = n1.n_nationkey AND ascii(substr(c_state, 1, 1)) = n2.n_nationkey + AND ( + (n1.n_name = 'Germany' AND n2.n_name = 'Cambodia') + OR + (n1.n_name = 'Cambodia' AND n2.n_name = 'Germany') + ) + GROUP BY su_nationkey, cust_nation, l_year + ORDER BY su_nationkey, cust_nation, l_year + + + + + SELECT extract(YEAR FROM o_entry_d) AS l_year, sum( + CASE WHEN n2.n_name = 'Germany' THEN ol_amount ELSE 0 END + ) / sum(ol_amount) AS mkt_share + FROM item, supplier, stock, order_line, oorder, customer, nation n1, nation n2, region + WHERE i_id = s_i_id AND ol_i_id = s_i_id AND ol_supply_w_id = s_w_id AND MOD ((s_w_id * s_i_id), 10000) = su_suppkey + AND ol_w_id = o_w_id AND ol_d_id = o_d_id AND ol_o_id = o_id AND c_id = o_c_id AND c_w_id = o_w_id + AND c_d_id = o_d_id AND n1.n_nationkey = ascii(substr(c_state, 1, 1)) AND n1.n_regionkey = r_regionkey + AND 1000 > ol_i_id AND r_name = 'Europe' AND su_nationkey = n2.n_nationkey AND i_data LIKE '%b' AND i_id = ol_i_id + GROUP BY l_year ORDER BY l_year + + + + + SELECT n_name, extract(YEAR FROM o_entry_d) AS l_year, sum(ol_amount) AS sum_profit + FROM item, stock, supplier, order_line, oorder, nation + WHERE ol_i_id = s_i_id AND ol_supply_w_id = s_w_id AND MOD ((s_w_id * s_i_id), 10000) = su_suppkey + AND ol_w_id = o_w_id AND ol_d_id = o_d_id AND ol_o_id = o_id AND ol_i_id = i_id AND su_nationkey = n_nationkey + AND i_data LIKE '%bb' + GROUP BY n_name, l_year ORDER BY n_name, l_year DESC + + + + + SELECT c_id, c_last, sum(ol_amount) AS revenue, c_city, c_phone, n_name + FROM customer, oorder, order_line, nation + WHERE c_id = o_c_id AND c_w_id = o_w_id AND c_d_id = o_d_id AND ol_w_id = o_w_id AND ol_d_id = o_d_id + AND ol_o_id = o_id AND o_entry_d >= TO_DATE('2007-01-02 00:00:00', 'YYYY-MM-DD HH24:MI:SS') + AND ol_delivery_d >= o_entry_d AND n_nationkey = ascii(substr(c_state, 1, 1)) + GROUP BY c_id, c_last, c_city, c_phone, n_name ORDER BY revenue DESC + + + + + SELECT o_ol_cnt, sum(CASE WHEN o_carrier_id = 1 OR o_carrier_id = 2 THEN 1 ELSE 0 END) AS high_line_count, + sum(CASE WHEN o_carrier_id != 1 AND o_carrier_id != 2 THEN 1 ELSE 0 END) AS low_line_count + FROM oorder, order_line + WHERE ol_w_id = o_w_id AND ol_d_id = o_d_id AND ol_o_id = o_id AND ol_delivery_d >= o_entry_d + AND TO_DATE('2020-01-01 00:00:00', 'YYYY-MM-DD HH24:MI:SS') > ol_delivery_d + GROUP BY o_ol_cnt ORDER BY o_ol_cnt + + + + + SELECT c_count, count(*) AS custdist FROM ( + SELECT c_id, count(o_id) AS c_count + FROM customer LEFT OUTER JOIN oorder ON + (c_w_id = o_w_id AND c_d_id = o_d_id AND c_id = o_c_id AND o_carrier_id > 8) + GROUP BY c_id + ) + GROUP BY c_count + ORDER BY custdist DESC, c_count DESC + + + + + SELECT (100.00 * sum(CASE WHEN i_data LIKE 'PR%' THEN ol_amount ELSE 0 END) / (1 + sum(ol_amount))) AS promo_revenue + FROM order_line, item + WHERE ol_i_id = i_id AND ol_delivery_d >= TO_DATE('2007-01-02 00:00:00', 'YYYY-MM-DD HH24:MI:SS') + AND TO_DATE('2020-01-02', 'YYYY-MM-DD HH24:MI:SS') > ol_delivery_d + + + + + CREATE view revenue0 (supplier_no, total_revenue) AS + SELECT mod((s_w_id * s_i_id),10000) as supplier_no, sum(ol_amount) as total_revenue + FROM order_line, stock + WHERE ol_i_id = s_i_id AND ol_supply_w_id = s_w_id + AND ol_delivery_d >= to_date('2007-01-02 00:00:00', 'YYYY-MM-DD HH24:MI:SS') + GROUP BY mod((s_w_id * s_i_id),10000) + + + + + SELECT i_name, substr(i_data, 1, 3) as brand, i_price, count(DISTINCT (mod((s_w_id * s_i_id),10000))) AS supplier_cnt + FROM stock, item + WHERE i_id = s_i_id AND i_data NOT LIKE 'zz%' AND (mod((s_w_id * s_i_id),10000) NOT IN + (SELECT su_suppkey FROM supplier WHERE su_comment LIKE '%bad%') + ) + GROUP BY i_name, substr(i_data, 1, 3), i_price ORDER BY supplier_cnt DESC + + + + + SELECT sum(ol_amount) AS revenue + FROM order_line, item + WHERE ( + ol_i_id = i_id AND i_data LIKE '%a' AND ol_quantity >= 1 AND 10 >= ol_quantity + AND i_price BETWEEN 1 AND 400000 AND ol_w_id IN (1, 2, 3) + ) OR ( + ol_i_id = i_id AND i_data LIKE '%b' AND ol_quantity >= 1 AND 10 >= ol_quantity + AND i_price BETWEEN 1 AND 400000 AND ol_w_id IN (1, 2, 4) + ) OR ( + ol_i_id = i_id AND i_data LIKE '%c' AND ol_quantity >= 1 AND 10 >= ol_quantity + AND i_price BETWEEN 1 AND 400000 AND ol_w_id IN (1, 5, 3) + ) + + + + + SELECT su_name, su_address FROM supplier, nation + WHERE su_suppkey IN ( + SELECT mod(s_i_id * s_w_id, 10000) + FROM stock INNER JOIN item ON i_id = s_i_id INNER JOIN order_line ON ol_i_id = s_i_id + WHERE ol_delivery_d > TO_DATE('2010-05-23 12:00:00', 'YYYY-MM-DD HH24:MI:SS') AND i_data LIKE 'co%' + GROUP BY s_i_id, s_w_id, s_quantity + HAVING 2*s_quantity > sum(ol_quantity) + ) AND su_nationkey = n_nationkey AND n_name = 'Germany' + ORDER BY su_name + + + + + SELECT substr(c_state,1,1) AS country, count(*) AS numcust, sum(c_balance) AS totacctbal + FROM customer + WHERE substr(c_phone,1,1) IN ('1', '2', '3', '4', '5', '6', '7') + AND c_balance > ( + SELECT avg(c_balance) + FROM customer + WHERE c_balance > 0.00 AND substr(c_phone,1,1) IN ('1', '2', '3', '4', '5', '6', '7')) + AND NOT EXISTS ( + SELECT * FROM oorder + WHERE o_c_id = c_id AND o_w_id = c_w_id AND o_d_id = c_d_id + ) + GROUP BY substr(c_state,1,1) + ORDER BY substr(c_state,1,1) + + + + \ No newline at end of file diff --git a/src/main/resources/benchmarks/chbenchmark/gather_schema_stats_oracle.sql b/src/main/resources/benchmarks/chbenchmark/gather_schema_stats_oracle.sql new file mode 100644 index 000000000..eb4a10862 --- /dev/null +++ b/src/main/resources/benchmarks/chbenchmark/gather_schema_stats_oracle.sql @@ -0,0 +1,2 @@ +-- Copyright (c) 2023, Oracle and/or its affiliates. +BEGIN dbms_stats.gather_schema_stats(ownname => 'benchbase', estimate_percent => dbms_stats.auto_sample_size, method_opt => 'for all columns size AUTO'); END;; \ No newline at end of file diff --git a/src/main/resources/benchmarks/epinions/ddl-oracle.sql b/src/main/resources/benchmarks/epinions/ddl-oracle.sql index 4b80c8c67..c589369cd 100644 --- a/src/main/resources/benchmarks/epinions/ddl-oracle.sql +++ b/src/main/resources/benchmarks/epinions/ddl-oracle.sql @@ -1,16 +1,18 @@ +-- Copyright (c) 2023, Oracle and/or its affiliates. + -- Epinions DDL for Oracle DDL -- Drop all tables -BEGIN EXECUTE IMMEDIATE 'DROP TABLE "review"'; EXCEPTION WHEN OTHERS THEN IF SQLCODE != -942 THEN RAISE; END IF; END;; -BEGIN EXECUTE IMMEDIATE 'DROP TABLE "review_rating"'; EXCEPTION WHEN OTHERS THEN IF SQLCODE != -942 THEN RAISE; END IF; END;; -BEGIN EXECUTE IMMEDIATE 'DROP TABLE "trust"'; EXCEPTION WHEN OTHERS THEN IF SQLCODE != -942 THEN RAISE; END IF; END;; -BEGIN EXECUTE IMMEDIATE 'DROP TABLE "item"'; EXCEPTION WHEN OTHERS THEN IF SQLCODE != -942 THEN RAISE; END IF; END;; -BEGIN EXECUTE IMMEDIATE 'DROP TABLE "useracct"'; EXCEPTION WHEN OTHERS THEN IF SQLCODE != -942 THEN RAISE; END IF; END;; +BEGIN EXECUTE IMMEDIATE 'DROP TABLE review CASCADE CONSTRAINTS'; EXCEPTION WHEN OTHERS THEN IF SQLCODE != -942 THEN RAISE; END IF; END;; +BEGIN EXECUTE IMMEDIATE 'DROP TABLE review_rating CASCADE CONSTRAINTS'; EXCEPTION WHEN OTHERS THEN IF SQLCODE != -942 THEN RAISE; END IF; END;; +BEGIN EXECUTE IMMEDIATE 'DROP TABLE trust CASCADE CONSTRAINTS'; EXCEPTION WHEN OTHERS THEN IF SQLCODE != -942 THEN RAISE; END IF; END;; +BEGIN EXECUTE IMMEDIATE 'DROP TABLE item CASCADE CONSTRAINTS'; EXCEPTION WHEN OTHERS THEN IF SQLCODE != -942 THEN RAISE; END IF; END;; +BEGIN EXECUTE IMMEDIATE 'DROP TABLE useracct CASCADE CONSTRAINTS'; EXCEPTION WHEN OTHERS THEN IF SQLCODE != -942 THEN RAISE; END IF; END;; -- create tables -CREATE TABLE "useracct" ( +CREATE TABLE useracct ( u_id number(11,0) NOT NULL, name varchar(128) NOT NULL, email varchar(128) NOT NULL, @@ -18,7 +20,7 @@ CREATE TABLE "useracct" ( PRIMARY KEY (u_id) ); -CREATE TABLE "item" ( +CREATE TABLE item ( i_id number(11,0) NOT NULL, title varchar(128) NOT NULL, description varchar(512) DEFAULT NULL, @@ -26,18 +28,18 @@ CREATE TABLE "item" ( PRIMARY KEY (i_id) ); -CREATE TABLE "review" ( +CREATE TABLE review ( a_id number(11,0) NOT NULL, - u_id number(11,0) NOT NULL REFERENCES "useracct" (u_id), - i_id number(11,0) NOT NULL REFERENCES "item" (i_id), + u_id number(11,0) NOT NULL REFERENCES useracct (u_id), + i_id number(11,0) NOT NULL REFERENCES item (i_id), rating number(11,0) DEFAULT NULL, rank number(11,0) DEFAULT NULL, - comment varchar(256) DEFAULT NULL, + "comment" varchar(256) DEFAULT NULL, creation_date date DEFAULT NULL ); -CREATE TABLE "review_rating" ( - u_id number(11,0) NOT NULL REFERENCES "useracct" (u_id), +CREATE TABLE review_rating ( + u_id number(11,0) NOT NULL REFERENCES useracct (u_id), a_id number(11,0) NOT NULL, rating number(11,0) NOT NULL, status number(11,0) NOT NULL, @@ -47,20 +49,20 @@ CREATE TABLE "review_rating" ( vertical_id number(11,0) DEFAULT NULL ); -CREATE TABLE "trust" ( - source_u_id number(11,0) NOT NULL REFERENCES "useracct" (u_id), - target_u_id number(11,0) NOT NULL REFERENCES "useracct" (u_id), +CREATE TABLE trust ( + source_u_id number(11,0) NOT NULL REFERENCES useracct (u_id), + target_u_id number(11,0) NOT NULL REFERENCES useracct (u_id), trust number(11,0) NOT NULL, creation_date date DEFAULT NULL ); -- create indexes -CREATE INDEX IDX_REVIEW_RATING_UID ON "review_rating" (u_id); -CREATE INDEX IDX_REVIEW_RATING_AID ON "review_rating" (a_id); -CREATE INDEX IDX_TRUST_SID ON "trust" (source_u_id); -CREATE INDEX IDX_TRUST_TID ON "trust" (target_u_id); -CREATE INDEX IDX_RATING_UID ON "review" (u_id); -CREATE INDEX IDX_RATING_AID ON "review" (a_id); -CREATE INDEX IDX_RATING_IID ON "review" (i_id); +CREATE INDEX IDX_REVIEW_RATING_UID ON review_rating (u_id); +CREATE INDEX IDX_REVIEW_RATING_AID ON review_rating (a_id); +CREATE INDEX IDX_TRUST_SID ON trust (source_u_id); +CREATE INDEX IDX_TRUST_TID ON trust (target_u_id); +CREATE INDEX IDX_RATING_UID ON review (u_id); +CREATE INDEX IDX_RATING_AID ON review (a_id); +CREATE INDEX IDX_RATING_IID ON review (i_id); diff --git a/src/main/resources/benchmarks/epinions/dialect-oracle.xml b/src/main/resources/benchmarks/epinions/dialect-oracle.xml index 749c1901a..2bbd8c459 100644 --- a/src/main/resources/benchmarks/epinions/dialect-oracle.xml +++ b/src/main/resources/benchmarks/epinions/dialect-oracle.xml @@ -1,56 +1,59 @@ + - SELECT avg(rating) FROM "review" r, "trust" t WHERE r.u_id=t.target_u_id AND r.i_id=? AND t.source_u_id=? + SELECT avg(rating) FROM review r, trust t WHERE r.u_id=t.target_u_id AND r.i_id=? AND t.source_u_id=? - SELECT avg(rating) FROM "review" r WHERE r.i_id=? + SELECT avg(rating) FROM review r WHERE r.i_id=? - SELECT * FROM "review" r WHERE r.i_id=? ORDER BY creation_date DESC + SELECT * FROM review r WHERE r.i_id=? ORDER BY creation_date DESC - SELECT * FROM "trust" t WHERE t.source_u_id=? + SELECT * FROM trust t WHERE t.source_u_id=? - + - SELECT * FROM "review" r, "item" i WHERE i.i_id = r.i_id and r.i_id=? AND ROWNUM <= 10 + SELECT * FROM review r, item i WHERE i.i_id = r.i_id and r.i_id=? ORDER BY rating DESC, r.creation_date DESC + FETCH NEXT 10 ROWS ONLY - SELECT * FROM "review" r, "useracct" u WHERE u.u_id = r.u_id AND r.u_id=? AND ROWNUM <= 10 + SELECT * FROM review r, useracct u WHERE u.u_id = r.u_id AND r.u_id=? ORDER BY rating DESC, r.creation_date DESC + FETCH NEXT 10 ROWS ONLY - UPDATE "item" SET title = ? WHERE i_id=? + UPDATE item SET title = ? WHERE i_id=? - UPDATE "review" SET rating = ? WHERE i_id=? AND u_id=? + UPDATE review SET rating = ? WHERE i_id=? AND u_id=? - UPDATE "trust" SET trust = ? WHERE source_u_id=? AND target_u_id=? + UPDATE trust SET trust = ? WHERE source_u_id=? AND target_u_id=? - UPDATE "useracct" SET name = ? WHERE u_id=? + UPDATE useracct SET name = ? WHERE u_id=? - + diff --git a/src/main/resources/benchmarks/hyadapt/ddl-oracle.sql b/src/main/resources/benchmarks/hyadapt/ddl-oracle.sql new file mode 100644 index 000000000..b470c97d3 --- /dev/null +++ b/src/main/resources/benchmarks/hyadapt/ddl-oracle.sql @@ -0,0 +1,256 @@ +-- Copyright (c) 2023, Oracle and/or its affiliates. +BEGIN EXECUTE IMMEDIATE 'DROP TABLE htable'; EXCEPTION WHEN OTHERS THEN IF SQLCODE != -942 THEN RAISE; END IF; END;; + +CREATE TABLE htable ( + h_key int PRIMARY KEY, + field1 int, + field2 int, + field3 int, + field4 int, + field5 int, + field6 int, + field7 int, + field8 int, + field9 int, + field10 int, + field11 int, + field12 int, + field13 int, + field14 int, + field15 int, + field16 int, + field17 int, + field18 int, + field19 int, + field20 int, + field21 int, + field22 int, + field23 int, + field24 int, + field25 int, + field26 int, + field27 int, + field28 int, + field29 int, + field30 int, + field31 int, + field32 int, + field33 int, + field34 int, + field35 int, + field36 int, + field37 int, + field38 int, + field39 int, + field40 int, + field41 int, + field42 int, + field43 int, + field44 int, + field45 int, + field46 int, + field47 int, + field48 int, + field49 int, + field50 int, + field51 int, + field52 int, + field53 int, + field54 int, + field55 int, + field56 int, + field57 int, + field58 int, + field59 int, + field60 int, + field61 int, + field62 int, + field63 int, + field64 int, + field65 int, + field66 int, + field67 int, + field68 int, + field69 int, + field70 int, + field71 int, + field72 int, + field73 int, + field74 int, + field75 int, + field76 int, + field77 int, + field78 int, + field79 int, + field80 int, + field81 int, + field82 int, + field83 int, + field84 int, + field85 int, + field86 int, + field87 int, + field88 int, + field89 int, + field90 int, + field91 int, + field92 int, + field93 int, + field94 int, + field95 int, + field96 int, + field97 int, + field98 int, + field99 int, + field100 int, + field101 int, + field102 int, + field103 int, + field104 int, + field105 int, + field106 int, + field107 int, + field108 int, + field109 int, + field110 int, + field111 int, + field112 int, + field113 int, + field114 int, + field115 int, + field116 int, + field117 int, + field118 int, + field119 int, + field120 int, + field121 int, + field122 int, + field123 int, + field124 int, + field125 int, + field126 int, + field127 int, + field128 int, + field129 int, + field130 int, + field131 int, + field132 int, + field133 int, + field134 int, + field135 int, + field136 int, + field137 int, + field138 int, + field139 int, + field140 int, + field141 int, + field142 int, + field143 int, + field144 int, + field145 int, + field146 int, + field147 int, + field148 int, + field149 int, + field150 int, + field151 int, + field152 int, + field153 int, + field154 int, + field155 int, + field156 int, + field157 int, + field158 int, + field159 int, + field160 int, + field161 int, + field162 int, + field163 int, + field164 int, + field165 int, + field166 int, + field167 int, + field168 int, + field169 int, + field170 int, + field171 int, + field172 int, + field173 int, + field174 int, + field175 int, + field176 int, + field177 int, + field178 int, + field179 int, + field180 int, + field181 int, + field182 int, + field183 int, + field184 int, + field185 int, + field186 int, + field187 int, + field188 int, + field189 int, + field190 int, + field191 int, + field192 int, + field193 int, + field194 int, + field195 int, + field196 int, + field197 int, + field198 int, + field199 int, + field200 int, + field201 int, + field202 int, + field203 int, + field204 int, + field205 int, + field206 int, + field207 int, + field208 int, + field209 int, + field210 int, + field211 int, + field212 int, + field213 int, + field214 int, + field215 int, + field216 int, + field217 int, + field218 int, + field219 int, + field220 int, + field221 int, + field222 int, + field223 int, + field224 int, + field225 int, + field226 int, + field227 int, + field228 int, + field229 int, + field230 int, + field231 int, + field232 int, + field233 int, + field234 int, + field235 int, + field236 int, + field237 int, + field238 int, + field239 int, + field240 int, + field241 int, + field242 int, + field243 int, + field244 int, + field245 int, + field246 int, + field247 int, + field248 int, + field249 int, + field250 int +); \ No newline at end of file diff --git a/src/main/resources/benchmarks/noop/ddl-oracle.sql b/src/main/resources/benchmarks/noop/ddl-oracle.sql new file mode 100644 index 000000000..19c4ccd88 --- /dev/null +++ b/src/main/resources/benchmarks/noop/ddl-oracle.sql @@ -0,0 +1,7 @@ +-- Copyright (c) 2023, Oracle and/or its affiliates. +BEGIN EXECUTE IMMEDIATE 'DROP TABLE fake'; EXCEPTION WHEN OTHERS THEN IF SQLCODE != -942 THEN RAISE; END IF; END;; + +CREATE TABLE fake ( + id INT NOT NULL, + PRIMARY KEY (id) +); diff --git a/src/main/resources/benchmarks/noop/dialect-oracle.xml b/src/main/resources/benchmarks/noop/dialect-oracle.xml new file mode 100644 index 000000000..07064d5cf --- /dev/null +++ b/src/main/resources/benchmarks/noop/dialect-oracle.xml @@ -0,0 +1,11 @@ + + + + + + + SELECT 1 FROM DUAL; + + + + diff --git a/src/main/resources/benchmarks/otmetrics/ddl-oracle-trimmed.sql b/src/main/resources/benchmarks/otmetrics/ddl-oracle-trimmed.sql new file mode 100644 index 000000000..15a182ad9 --- /dev/null +++ b/src/main/resources/benchmarks/otmetrics/ddl-oracle-trimmed.sql @@ -0,0 +1,34 @@ +CREATE TABLE sources ( + id INT NOT NULL, + name VARCHAR(128) NOT NULL UNIQUE, + comments VARCHAR(256) DEFAULT NULL, + created_time TIMESTAMP NOT NULL, + PRIMARY KEY (id) +); + +CREATE TABLE types ( + id INT NOT NULL, + category INT NOT NULL, + value_type INT NOT NULL, + name VARCHAR(64) NOT NULL, + comments VARCHAR(256) DEFAULT NULL, + PRIMARY KEY (id), + UNIQUE (category, name) +); + +CREATE TABLE sessions ( + id INT NOT NULL, + source_id INT NOT NULL REFERENCES sources (id), + agent VARCHAR(32) NOT NULL, + created_time TIMESTAMP NOT NULL, + PRIMARY KEY (id) +); + +CREATE TABLE observations ( + source_id INT NOT NULL REFERENCES sources (id), + session_id INT NOT NULL REFERENCES sessions (id), + type_id INT NOT NULL REFERENCES types (id), + value NUMBER(38) NOT NULL, + created_time TIMESTAMP NOT NULL +); +CREATE INDEX idx_observations_source_session ON observations (source_id, session_id, type_id); \ No newline at end of file diff --git a/src/main/resources/benchmarks/otmetrics/ddl-oracle.sql b/src/main/resources/benchmarks/otmetrics/ddl-oracle.sql new file mode 100644 index 000000000..c1b004056 --- /dev/null +++ b/src/main/resources/benchmarks/otmetrics/ddl-oracle.sql @@ -0,0 +1,40 @@ +-- Copyright (c) 2023, Oracle and/or its affiliates. +BEGIN EXECUTE IMMEDIATE 'DROP TABLE observations CASCADE CONSTRAINTS'; EXCEPTION WHEN OTHERS THEN IF SQLCODE != -942 THEN RAISE; END IF; END;; +BEGIN EXECUTE IMMEDIATE 'DROP TABLE types CASCADE CONSTRAINTS'; EXCEPTION WHEN OTHERS THEN IF SQLCODE != -942 THEN RAISE; END IF; END;; +BEGIN EXECUTE IMMEDIATE 'DROP TABLE sessions CASCADE CONSTRAINTS'; EXCEPTION WHEN OTHERS THEN IF SQLCODE != -942 THEN RAISE; END IF; END;; +BEGIN EXECUTE IMMEDIATE 'DROP TABLE sources CASCADE CONSTRAINTS'; EXCEPTION WHEN OTHERS THEN IF SQLCODE != -942 THEN RAISE; END IF; END;; + +CREATE TABLE sources ( + id INT NOT NULL, + name VARCHAR(128) NOT NULL UNIQUE, + comments VARCHAR(256) DEFAULT NULL, + created_time TIMESTAMP NOT NULL, + PRIMARY KEY (id) +); + +CREATE TABLE types ( + id INT NOT NULL, + category INT NOT NULL, + value_type INT NOT NULL, + name VARCHAR(64) NOT NULL, + comments VARCHAR(256) DEFAULT NULL, + PRIMARY KEY (id), + UNIQUE (category, name) +); + +CREATE TABLE sessions ( + id INT NOT NULL, + source_id INT NOT NULL REFERENCES sources (id), + agent VARCHAR(32) NOT NULL, + created_time TIMESTAMP NOT NULL, + PRIMARY KEY (id) +); + +CREATE TABLE observations ( + source_id INT NOT NULL REFERENCES sources (id), + session_id INT NOT NULL REFERENCES sessions (id), + type_id INT NOT NULL REFERENCES types (id), + value NUMBER(38) NOT NULL, + created_time TIMESTAMP NOT NULL +); +CREATE INDEX idx_observations_source_session ON observations (source_id, session_id, type_id); \ No newline at end of file diff --git a/src/main/resources/benchmarks/resourcestresser/ddl-oracle.sql b/src/main/resources/benchmarks/resourcestresser/ddl-oracle.sql index 104503962..1ec3ba72e 100644 --- a/src/main/resources/benchmarks/resourcestresser/ddl-oracle.sql +++ b/src/main/resources/benchmarks/resourcestresser/ddl-oracle.sql @@ -1,9 +1,10 @@ +-- Copyright (c) 2023, Oracle and/or its affiliates. -- Drop all tables -BEGIN EXECUTE IMMEDIATE 'DROP TABLE "cputable"'; EXCEPTION WHEN OTHERS THEN IF SQLCODE != -942 THEN RAISE; END IF; END;; -BEGIN EXECUTE IMMEDIATE 'DROP TABLE "iotable"'; EXCEPTION WHEN OTHERS THEN IF SQLCODE != -942 THEN RAISE; END IF; END;; -BEGIN EXECUTE IMMEDIATE 'DROP TABLE "iotablesmallrow"'; EXCEPTION WHEN OTHERS THEN IF SQLCODE != -942 THEN RAISE; END IF; END;; -BEGIN EXECUTE IMMEDIATE 'DROP TABLE "locktable"'; EXCEPTION WHEN OTHERS THEN IF SQLCODE != -942 THEN RAISE; END IF; END;; +BEGIN EXECUTE IMMEDIATE 'DROP TABLE cputable'; EXCEPTION WHEN OTHERS THEN IF SQLCODE != -942 THEN RAISE; END IF; END;; +BEGIN EXECUTE IMMEDIATE 'DROP TABLE iotable'; EXCEPTION WHEN OTHERS THEN IF SQLCODE != -942 THEN RAISE; END IF; END;; +BEGIN EXECUTE IMMEDIATE 'DROP TABLE iotablesmallrow'; EXCEPTION WHEN OTHERS THEN IF SQLCODE != -942 THEN RAISE; END IF; END;; +BEGIN EXECUTE IMMEDIATE 'DROP TABLE locktable'; EXCEPTION WHEN OTHERS THEN IF SQLCODE != -942 THEN RAISE; END IF; END;; -- Create table @@ -48,22 +49,20 @@ CREATE TABLE locktable ( -- Procedures -create or replace -function md5raw (text in varchar2) -return varchar2 is -hash_value varchar2(20); -begin - hash_value := dbms_obfuscation_toolkit.md5 (input_string => text); - return hash_value; -end; +-- See https://docs.oracle.com/en/database/oracle/oracle-database/23/arpls/DBMS_CRYPTO.html +-- DBMS_OBFUSCATION_TOOLKIT is deprecated, using DBMS_CRYPTO + +-- MD5 is deprecated for Oracle 23c onwards, potentially change to SHA-2 using DBMS_CRYPTO.HASH_SH256. +-- The procedure name however should still be kept as "md5". + +-- Current (Oct 5, 2023) dialect file cannot change the function name as it can only change the SQL string +-- inside SQLStmt, but related SQL for this procedure is constructed outside. create or replace function md5(text in varchar2) -return varchar2 is -hash_value varchar2(32); -begin - select lower(rawtohex(md5raw(text))) - into hash_value - from dual; - return hash_value; -end; +return varchar2 is hash_value varchar2(32) +;begin +select lower(UTL_I18N.RAW_TO_CHAR (DBMS_CRYPTO.HASH(text, DBMS_CRYPTO.HASH_MD5), 'AL32UTF8')) +into hash_value from dual +;return hash_value +;end;; diff --git a/src/main/resources/benchmarks/seats/ddl-oracle.sql b/src/main/resources/benchmarks/seats/ddl-oracle.sql index f3b8fda73..2ea643cf1 100644 --- a/src/main/resources/benchmarks/seats/ddl-oracle.sql +++ b/src/main/resources/benchmarks/seats/ddl-oracle.sql @@ -1,15 +1,16 @@ +-- Copyright (c) 2023, Oracle and/or its affiliates. -- DROP TABLE -BEGIN EXECUTE IMMEDIATE 'DROP TABLE CONFIG_PROFILE'; EXCEPTION WHEN OTHERS THEN IF SQLCODE != -942 THEN RAISE; END IF; END;; -BEGIN EXECUTE IMMEDIATE 'DROP TABLE CONFIG_HISTOGRAMS'; EXCEPTION WHEN OTHERS THEN IF SQLCODE != -942 THEN RAISE; END IF; END;; -BEGIN EXECUTE IMMEDIATE 'DROP TABLE AIRPORT_DISTANCE'; EXCEPTION WHEN OTHERS THEN IF SQLCODE != -942 THEN RAISE; END IF; END;; -BEGIN EXECUTE IMMEDIATE 'DROP TABLE FREQUENT_FLYER'; EXCEPTION WHEN OTHERS THEN IF SQLCODE != -942 THEN RAISE; END IF; END;; -BEGIN EXECUTE IMMEDIATE 'DROP TABLE RESERVATION'; EXCEPTION WHEN OTHERS THEN IF SQLCODE != -942 THEN RAISE; END IF; END;; +BEGIN EXECUTE IMMEDIATE 'DROP TABLE CONFIG_PROFILE CASCADE CONSTRAINTS'; EXCEPTION WHEN OTHERS THEN IF SQLCODE != -942 THEN RAISE; END IF; END;; +BEGIN EXECUTE IMMEDIATE 'DROP TABLE CONFIG_HISTOGRAMS CASCADE CONSTRAINTS'; EXCEPTION WHEN OTHERS THEN IF SQLCODE != -942 THEN RAISE; END IF; END;; +BEGIN EXECUTE IMMEDIATE 'DROP TABLE AIRPORT_DISTANCE CASCADE CONSTRAINTS'; EXCEPTION WHEN OTHERS THEN IF SQLCODE != -942 THEN RAISE; END IF; END;; +BEGIN EXECUTE IMMEDIATE 'DROP TABLE FREQUENT_FLYER CASCADE CONSTRAINTS'; EXCEPTION WHEN OTHERS THEN IF SQLCODE != -942 THEN RAISE; END IF; END;; +BEGIN EXECUTE IMMEDIATE 'DROP TABLE RESERVATION CASCADE CONSTRAINTS'; EXCEPTION WHEN OTHERS THEN IF SQLCODE != -942 THEN RAISE; END IF; END;; BEGIN EXECUTE IMMEDIATE 'DROP TABLE AIRLINE CASCADE CONSTRAINTS'; EXCEPTION WHEN OTHERS THEN IF SQLCODE != -942 THEN RAISE; END IF; END;; -BEGIN EXECUTE IMMEDIATE 'DROP TABLE FLIGHT'; EXCEPTION WHEN OTHERS THEN IF SQLCODE != -942 THEN RAISE; END IF; END;; -BEGIN EXECUTE IMMEDIATE 'DROP TABLE CUSTOMER'; EXCEPTION WHEN OTHERS THEN IF SQLCODE != -942 THEN RAISE; END IF; END;; -BEGIN EXECUTE IMMEDIATE 'DROP TABLE AIRPORT'; EXCEPTION WHEN OTHERS THEN IF SQLCODE != -942 THEN RAISE; END IF; END;; -BEGIN EXECUTE IMMEDIATE 'DROP TABLE COUNTRY'; EXCEPTION WHEN OTHERS THEN IF SQLCODE != -942 THEN RAISE; END IF; END;; +BEGIN EXECUTE IMMEDIATE 'DROP TABLE FLIGHT CASCADE CONSTRAINTS'; EXCEPTION WHEN OTHERS THEN IF SQLCODE != -942 THEN RAISE; END IF; END;; +BEGIN EXECUTE IMMEDIATE 'DROP TABLE CUSTOMER CASCADE CONSTRAINTS'; EXCEPTION WHEN OTHERS THEN IF SQLCODE != -942 THEN RAISE; END IF; END;; +BEGIN EXECUTE IMMEDIATE 'DROP TABLE AIRPORT CASCADE CONSTRAINTS'; EXCEPTION WHEN OTHERS THEN IF SQLCODE != -942 THEN RAISE; END IF; END;; +BEGIN EXECUTE IMMEDIATE 'DROP TABLE COUNTRY CASCADE CONSTRAINTS'; EXCEPTION WHEN OTHERS THEN IF SQLCODE != -942 THEN RAISE; END IF; END;; -- CREATE TABLE CONFIG_PROFILE ( CFP_SCALE_FACTOR FLOAT NOT NULL, @@ -20,7 +21,7 @@ CREATE TABLE CONFIG_PROFILE ( CFP_FLIGHT_FUTURE_DAYS INT NOT NULL, CFP_FLIGHT_OFFSET INT, CFP_RESERVATION_OFFSET INT, - CFP_NUM_RESERVATIONS INT NOT NULL, + CFP_NUM_RESERVATIONS NUMBER(19, 0) NOT NULL, CFP_CODE_IDS_XREFS CLOB NOT NULL ); @@ -34,7 +35,7 @@ CREATE TABLE CONFIG_HISTOGRAMS ( PRIMARY KEY (CFH_NAME) ); --- +-- -- COUNTRY -- CREATE TABLE COUNTRY ( @@ -121,7 +122,7 @@ CREATE TABLE AIRLINE ( -- CUSTOMER -- CREATE TABLE CUSTOMER ( - C_ID NUMBER(19,0) NOT NULL, + C_ID VARCHAR2(128) NOT NULL, C_ID_STR VARCHAR2(64) UNIQUE NOT NULL, C_BASE_AP_ID NUMBER(19,0) REFERENCES AIRPORT (AP_ID), C_BALANCE FLOAT NOT NULL, @@ -172,7 +173,7 @@ CREATE TABLE CUSTOMER ( -- FREQUENT_FLYER -- CREATE TABLE FREQUENT_FLYER ( - FF_C_ID NUMBER(19,0) NOT NULL REFERENCES CUSTOMER (C_ID), + FF_C_ID VARCHAR2(128) NOT NULL REFERENCES CUSTOMER (C_ID), FF_AL_ID NUMBER(19,0) NOT NULL REFERENCES AIRLINE (AL_ID), FF_C_ID_STR VARCHAR2(64) NOT NULL, FF_SATTR00 VARCHAR2(32), @@ -203,7 +204,7 @@ CREATE INDEX IDX_FF_CUSTOMER_ID ON FREQUENT_FLYER (FF_C_ID_STR); -- FLIGHT -- CREATE TABLE FLIGHT ( - F_ID NUMBER(19,0) NOT NULL, + F_ID VARCHAR2(128) NOT NULL, F_AL_ID NUMBER(19,0) NOT NULL REFERENCES AIRLINE (AL_ID), F_DEPART_AP_ID NUMBER(19,0) NOT NULL REFERENCES AIRPORT (AP_ID), F_DEPART_TIME TIMESTAMP NOT NULL, @@ -252,8 +253,8 @@ CREATE INDEX F_DEPART_TIME_IDX ON FLIGHT (F_DEPART_TIME); -- CREATE TABLE RESERVATION ( R_ID NUMBER(19,0) NOT NULL, - R_C_ID NUMBER(19,0) NOT NULL REFERENCES CUSTOMER (C_ID), - R_F_ID NUMBER(19,0) NOT NULL REFERENCES FLIGHT (F_ID), + R_C_ID VARCHAR2(128) NOT NULL REFERENCES CUSTOMER (C_ID), + R_F_ID VARCHAR2(128) NOT NULL REFERENCES FLIGHT (F_ID), R_SEAT NUMBER(19,0) NOT NULL, R_PRICE FLOAT NOT NULL, R_IATTR00 NUMBER(19,0), diff --git a/src/main/resources/benchmarks/sibench/ddl-oracle.sql b/src/main/resources/benchmarks/sibench/ddl-oracle.sql new file mode 100644 index 000000000..cdaa7cdfb --- /dev/null +++ b/src/main/resources/benchmarks/sibench/ddl-oracle.sql @@ -0,0 +1,7 @@ +-- Copyright (c) 2023, Oracle and/or its affiliates. +BEGIN EXECUTE IMMEDIATE 'DROP TABLE sitest'; EXCEPTION WHEN OTHERS THEN IF SQLCODE != -942 THEN RAISE; END IF; END;; + +CREATE TABLE sitest ( + id INT PRIMARY KEY, + value INT NOT NULL +); \ No newline at end of file diff --git a/src/main/resources/benchmarks/sibench/dialect-oracle.xml b/src/main/resources/benchmarks/sibench/dialect-oracle.xml new file mode 100644 index 000000000..209efa087 --- /dev/null +++ b/src/main/resources/benchmarks/sibench/dialect-oracle.xml @@ -0,0 +1,11 @@ + + + + + + + SELECT id FROM sitest ORDER BY value ASC FETCH NEXT 1 ROWS ONLY + + + + diff --git a/src/main/resources/benchmarks/smallbank/ddl-oracle.sql b/src/main/resources/benchmarks/smallbank/ddl-oracle.sql new file mode 100644 index 000000000..d2c0a29dc --- /dev/null +++ b/src/main/resources/benchmarks/smallbank/ddl-oracle.sql @@ -0,0 +1,25 @@ +-- Copyright (c) 2023, Oracle and/or its affiliates. +BEGIN EXECUTE IMMEDIATE 'DROP TABLE checking CASCADE CONSTRAINTS'; EXCEPTION WHEN OTHERS THEN IF SQLCODE != -942 THEN RAISE; END IF; END;; +BEGIN EXECUTE IMMEDIATE 'DROP TABLE savings CASCADE CONSTRAINTS'; EXCEPTION WHEN OTHERS THEN IF SQLCODE != -942 THEN RAISE; END IF; END;; +BEGIN EXECUTE IMMEDIATE 'DROP TABLE accounts CASCADE CONSTRAINTS'; EXCEPTION WHEN OTHERS THEN IF SQLCODE != -942 THEN RAISE; END IF; END;; + +CREATE TABLE accounts ( + custid NUMBER(19) NOT NULL, + name VARCHAR(64) NOT NULL, + CONSTRAINT pk_accounts PRIMARY KEY (custid) +); +CREATE INDEX idx_accounts_name ON accounts (name); + +CREATE TABLE savings ( + custid NUMBER(19) NOT NULL, + bal NUMBER NOT NULL, + CONSTRAINT pk_savings PRIMARY KEY (custid), + FOREIGN KEY (custid) REFERENCES accounts (custid) +); + +CREATE TABLE checking ( + custid NUMBER(19) NOT NULL, + bal NUMBER NOT NULL, + CONSTRAINT pk_checking PRIMARY KEY (custid), + FOREIGN KEY (custid) REFERENCES accounts (custid) +); diff --git a/src/main/resources/benchmarks/tpch/ddl-oracle.sql b/src/main/resources/benchmarks/tpch/ddl-oracle.sql new file mode 100644 index 000000000..f32607292 --- /dev/null +++ b/src/main/resources/benchmarks/tpch/ddl-oracle.sql @@ -0,0 +1,128 @@ +-- Copyright (c) 2023, Oracle and/or its affiliates. +BEGIN EXECUTE IMMEDIATE 'DROP TABLE nation CASCADE CONSTRAINTS'; EXCEPTION WHEN OTHERS THEN IF SQLCODE != -942 THEN RAISE; END IF; END;; +BEGIN EXECUTE IMMEDIATE 'DROP TABLE region CASCADE CONSTRAINTS'; EXCEPTION WHEN OTHERS THEN IF SQLCODE != -942 THEN RAISE; END IF; END;; +BEGIN EXECUTE IMMEDIATE 'DROP TABLE part CASCADE CONSTRAINTS'; EXCEPTION WHEN OTHERS THEN IF SQLCODE != -942 THEN RAISE; END IF; END;; +BEGIN EXECUTE IMMEDIATE 'DROP TABLE supplier CASCADE CONSTRAINTS'; EXCEPTION WHEN OTHERS THEN IF SQLCODE != -942 THEN RAISE; END IF; END;; +BEGIN EXECUTE IMMEDIATE 'DROP TABLE partsupp CASCADE CONSTRAINTS'; EXCEPTION WHEN OTHERS THEN IF SQLCODE != -942 THEN RAISE; END IF; END;; +BEGIN EXECUTE IMMEDIATE 'DROP TABLE customer CASCADE CONSTRAINTS'; EXCEPTION WHEN OTHERS THEN IF SQLCODE != -942 THEN RAISE; END IF; END;; +BEGIN EXECUTE IMMEDIATE 'DROP TABLE orders CASCADE CONSTRAINTS'; EXCEPTION WHEN OTHERS THEN IF SQLCODE != -942 THEN RAISE; END IF; END;; +BEGIN EXECUTE IMMEDIATE 'DROP TABLE lineitem CASCADE CONSTRAINTS'; EXCEPTION WHEN OTHERS THEN IF SQLCODE != -942 THEN RAISE; END IF; END;; + +CREATE TABLE region ( + r_regionkey int NOT NULL, + r_name char(25) NOT NULL, + r_comment varchar2(152), + PRIMARY KEY (r_regionkey) +); + +CREATE TABLE nation ( + n_nationkey int NOT NULL, + n_name char(25) NOT NULL, + n_regionkey int NOT NULL, + n_comment varchar2(152), + PRIMARY KEY (n_nationkey), + FOREIGN KEY (n_regionkey) REFERENCES region (r_regionkey) ON DELETE CASCADE +); + +CREATE INDEX n_rk ON nation (n_regionkey ASC); + +CREATE TABLE part ( + p_partkey int NOT NULL, + p_name varchar2(55) NOT NULL, + p_mfgr char(25) NOT NULL, + p_brand char(10) NOT NULL, + p_type varchar2(25) NOT NULL, + p_size int NOT NULL, + p_container char(10) NOT NULL, + p_retailprice decimal(15, 2) NOT NULL, + p_comment varchar2(23) NOT NULL, + PRIMARY KEY (p_partkey) +); + + +CREATE TABLE supplier ( + s_suppkey int NOT NULL, + s_name char(25) NOT NULL, + s_address varchar2(40) NOT NULL, + s_nationkey int NOT NULL, + s_phone char(15) NOT NULL, + s_acctbal decimal(15, 2) NOT NULL, + s_comment varchar2(101) NOT NULL, + PRIMARY KEY (s_suppkey), + FOREIGN KEY (s_nationkey) REFERENCES nation (n_nationkey) ON DELETE CASCADE +); +CREATE INDEX s_nk ON supplier (s_nationkey ASC); + +CREATE TABLE partsupp ( + ps_partkey int NOT NULL, + ps_suppkey int NOT NULL, + ps_availqty int NOT NULL, + ps_supplycost decimal(15, 2) NOT NULL, + ps_comment varchar2(199) NOT NULL, + PRIMARY KEY (ps_partkey, ps_suppkey), + FOREIGN KEY (ps_partkey) REFERENCES part (p_partkey) ON DELETE CASCADE, + FOREIGN KEY (ps_suppkey) REFERENCES supplier (s_suppkey) ON DELETE CASCADE +); +CREATE INDEX ps_pk ON partsupp (ps_partkey ASC); +CREATE INDEX ps_sk ON partsupp (ps_suppkey ASC); +CREATE UNIQUE INDEX ps_sk_pk ON partsupp (ps_suppkey ASC, ps_partkey ASC); + +CREATE TABLE customer ( + c_custkey int NOT NULL, + c_name varchar2(25) NOT NULL, + c_address varchar2(40) NOT NULL, + c_nationkey int NOT NULL, + c_phone char(15) NOT NULL, + c_acctbal decimal(15, 2) NOT NULL, + c_mktsegment char(10) NOT NULL, + c_comment varchar2(117) NOT NULL, + PRIMARY KEY (c_custkey), + FOREIGN KEY (c_nationkey) REFERENCES nation (n_nationkey) ON DELETE CASCADE +); +CREATE INDEX c_nk ON customer (c_nationkey ASC); + +CREATE TABLE orders ( + o_orderkey int NOT NULL, + o_custkey int NOT NULL, + o_orderstatus char(1) NOT NULL, + o_totalprice decimal(15, 2) NOT NULL, + o_orderdate date NOT NULL, + o_orderpriority char(15) NOT NULL, + o_clerk char(15) NOT NULL, + o_shippriority int NOT NULL, + o_comment varchar2(79) NOT NULL, + PRIMARY KEY (o_orderkey), + FOREIGN KEY (o_custkey) REFERENCES customer (c_custkey) ON DELETE CASCADE +); +CREATE INDEX o_ck ON orders (o_custkey ASC); +CREATE INDEX o_od ON orders (o_orderdate ASC); + +CREATE TABLE lineitem ( + l_orderkey int NOT NULL, + l_partkey int NOT NULL, + l_suppkey int NOT NULL, + l_linenumber int NOT NULL, + l_quantity decimal(15, 2) NOT NULL, + l_extendedprice decimal(15, 2) NOT NULL, + l_discount decimal(15, 2) NOT NULL, + l_tax decimal(15, 2) NOT NULL, + l_returnflag char(1) NOT NULL, + l_linestatus char(1) NOT NULL, + l_shipdate date NOT NULL, + l_commitdate date NOT NULL, + l_receiptdate date NOT NULL, + l_shipinstruct char(25) NOT NULL, + l_shipmode char(10) NOT NULL, + l_comment varchar2(44) NOT NULL, + PRIMARY KEY (l_orderkey, l_linenumber), + FOREIGN KEY (l_orderkey) REFERENCES orders (o_orderkey) ON DELETE CASCADE, + FOREIGN KEY (l_partkey, l_suppkey) REFERENCES partsupp (ps_partkey, ps_suppkey) ON DELETE CASCADE +); +CREATE INDEX l_ok ON lineitem (l_orderkey ASC); +CREATE INDEX l_pk ON lineitem (l_partkey ASC); +CREATE INDEX l_sk ON lineitem (l_suppkey ASC); +CREATE INDEX l_sd ON lineitem (l_shipdate ASC); +CREATE INDEX l_cd ON lineitem (l_commitdate ASC); +CREATE INDEX l_rd ON lineitem (l_receiptdate ASC); +CREATE INDEX l_pk_sk ON lineitem (l_partkey ASC, l_suppkey ASC); +CREATE INDEX l_sk_pk ON lineitem (l_suppkey ASC, l_partkey ASC); diff --git a/src/main/resources/benchmarks/tpch/dialect-oracle.xml b/src/main/resources/benchmarks/tpch/dialect-oracle.xml new file mode 100644 index 000000000..bdd14ab58 --- /dev/null +++ b/src/main/resources/benchmarks/tpch/dialect-oracle.xml @@ -0,0 +1,117 @@ + + + + + + + SELECT l_returnflag, l_linestatus, sum(l_quantity) as sum_qty, + sum(l_extendedprice) as sum_base_price, sum(l_extendedprice * (1 - l_discount)) as sum_disc_price, + sum(l_extendedprice * (1 - l_discount) * (1 + l_tax)) as sum_charge, + avg(l_quantity) as avg_qty, avg(l_extendedprice) as avg_price, avg(l_discount) as avg_disc, count(*) as count_order + FROM lineitem + WHERE l_shipdate <= to_date('1998-12-01', 'YYYY-MM-DD') - ? + GROUP BY l_returnflag, l_linestatus + ORDER BY l_returnflag, l_linestatus + + + + + select s_acctbal, s_name, n_name, p_partkey, p_mfgr, s_address, s_phone, s_comment from part, supplier, partsupp, nation, region where p_partkey = ps_partkey and s_suppkey = ps_suppkey and p_size = ? and p_type like ? and s_nationkey = n_nationkey and n_regionkey = r_regionkey and r_name = ? and ps_supplycost = ( select min(ps_supplycost) from partsupp, supplier, nation, region where p_partkey = ps_partkey and s_suppkey = ps_suppkey and s_nationkey = n_nationkey and n_regionkey = r_regionkey and r_name = ? ) order by s_acctbal desc, n_name, s_name, p_partkey FETCH NEXT 100 ROWS ONLY + + + + + select l_orderkey, sum(l_extendedprice * (1 - l_discount)) as revenue, o_orderdate, o_shippriority from customer, orders, lineitem where c_mktsegment = ? and c_custkey = o_custkey and l_orderkey = o_orderkey and o_orderdate < ? and l_shipdate > ? group by l_orderkey, o_orderdate, o_shippriority order by revenue desc, o_orderdate FETCH NEXT 10 ROWS ONLY + + + + + select o_orderpriority, count(*) as order_count from orders where o_orderdate >= ? and o_orderdate < add_months(?, 3) and exists ( select * from lineitem where l_orderkey = o_orderkey and l_commitdate < l_receiptdate ) group by o_orderpriority order by o_orderpriority + + + + + SELECT n_name, SUM(l_extendedprice * (1 - l_discount)) as revenue from customer, orders, lineitem, supplier, nation, region WHERE c_custkey = o_custkey and l_orderkey = o_orderkey and l_suppkey = s_suppkey and c_nationkey = s_nationkey and s_nationkey = n_nationkey and n_regionkey = r_regionkey and r_name = ? and o_orderdate >= ? and add_months(?, 12) > o_orderdate group by n_name order by revenue DESC + + + + + select sum(l_extendedprice * l_discount) as revenue from lineitem where l_shipdate >= ? and add_months(?, 12) > l_shipdate and l_discount between ? - 0.01 and ? + 0.01 and l_quantity < ? + + + + + select supp_nation, cust_nation, l_year, sum(volume) as revenue + from ( + select n1.n_name as supp_nation, n2.n_name as cust_nation, EXTRACT(YEAR FROM l_shipdate) AS l_year, + l_extendedprice * (1 - l_discount) as volume + from supplier, lineitem, orders, customer, nation n1, nation n2 + where s_suppkey = l_suppkey and o_orderkey = l_orderkey and c_custkey = o_custkey + and s_nationkey = n1.n_nationkey and c_nationkey = n2.n_nationkey + and ( + (n1.n_name = ? and n2.n_name = ?) or + (n1.n_name = ? and n2.n_name = ?) + ) + and l_shipdate between to_date('1995-01-01', 'YYYY-MM-DD') and to_date('1996-12-31', 'YYYY-MM-DD') + ) + group by supp_nation, cust_nation, l_year + order by supp_nation, cust_nation, l_year + + + + + select o_year, sum(case when nation = ? then volume else 0 end) / sum(volume) as mkt_share from ( select EXTRACT(YEAR FROM o_orderdate) as o_year, l_extendedprice * (1 - l_discount) as volume, n2.n_name as nation from part, supplier, lineitem, orders, customer, nation n1, nation n2, region where p_partkey = l_partkey and s_suppkey = l_suppkey and l_orderkey = o_orderkey and o_custkey = c_custkey and c_nationkey = n1.n_nationkey and n1.n_regionkey = r_regionkey and r_name = ? and s_nationkey = n2.n_nationkey and o_orderdate between to_date('1995-01-01', 'YYYY-MM-DD') and to_date('1996-12-31', 'YYYY-MM-DD') and p_type = ? ) group by o_year order by o_year + + + + + select nation, o_year, sum(amount) as sum_profit from ( select n_name as nation, EXTRACT(YEAR FROM o_orderdate) as o_year, l_extendedprice * (1 - l_discount) - ps_supplycost * l_quantity as amount from part, supplier, lineitem, partsupp, orders, nation where s_suppkey = l_suppkey and ps_suppkey = l_suppkey and ps_partkey = l_partkey and p_partkey = l_partkey and o_orderkey = l_orderkey and s_nationkey = n_nationkey and p_name like ? ) group by nation, o_year order by nation, o_year desc + + + + + select c_custkey, c_name, sum(l_extendedprice * (1 - l_discount)) as revenue, c_acctbal, n_name, c_address, c_phone, c_comment from customer, orders, lineitem, nation where c_custkey = o_custkey and l_orderkey = o_orderkey and o_orderdate >= ? and o_orderdate < add_months(?, 3) and l_returnflag = 'R' and c_nationkey = n_nationkey group by c_custkey, c_name, c_acctbal, c_phone, n_name, c_address, c_comment order by revenue desc FETCH NEXT 20 ROWS ONLY + + + + + select l_shipmode, sum(case when o_orderpriority = '1-URGENT' or o_orderpriority = '2-HIGH' then 1 else 0 end) as high_line_count, sum(case when o_orderpriority <> '1-URGENT' and o_orderpriority <> '2-HIGH' then 1 else 0 end) as low_line_count from orders, lineitem where o_orderkey = l_orderkey and l_shipmode in (?, ?) and l_commitdate < l_receiptdate and l_shipdate < l_commitdate and l_receiptdate >= ? and l_receiptdate < add_months(?, 1) group by l_shipmode order by l_shipmode + + + + + SELECT c_count, COUNT(*) AS custdist FROM (SELECT c_custkey, COUNT(o_orderkey) AS c_count FROM customer LEFT OUTER JOIN orders ON c_custkey = o_custkey AND o_comment NOT LIKE ? GROUP BY c_custkey) GROUP BY c_count ORDER BY custdist DESC, c_count DESC + + + + + select 100.00 * sum(case when p_type like 'PROMO%' then l_extendedprice * (1 - l_discount) else 0 end) / sum(l_extendedprice * (1 - l_discount)) as promo_revenue from lineitem, part where l_partkey = p_partkey and l_shipdate >= ? and l_shipdate < add_months(?, 1) + + + + + create view revenue0 (supplier_no, total_revenue) as select l_suppkey, sum(l_extendedprice * (1 - l_discount)) from lineitem where l_shipdate >= to_date(?, 'YYYY-MM-DD') and l_shipdate < add_months(to_date(?, 'YYYY-MM-DD'), 3) group by l_suppkey + + + + + select c_name, c_custkey, o_orderkey, o_orderdate, o_totalprice, sum(l_quantity) from customer, orders, lineitem where o_orderkey in ( select l_orderkey from lineitem group by l_orderkey having sum(l_quantity) > ? ) and c_custkey = o_custkey and o_orderkey = l_orderkey group by c_name, c_custkey, o_orderkey, o_orderdate, o_totalprice order by o_totalprice desc, o_orderdate FETCH NEXT 100 ROWS ONLY + + + + + select s_name, s_address from supplier, nation where s_suppkey in ( select ps_suppkey from partsupp where ps_partkey in ( select p_partkey from part where p_name like ? ) and ps_availqty > ( select 0.5 * sum(l_quantity) from lineitem where l_partkey = ps_partkey and l_suppkey = ps_suppkey and l_shipdate >= ? and l_shipdate < add_months(?, 12) ) ) and s_nationkey = n_nationkey and n_name = ? order by s_name + + + + + select s_name, count(*) as numwait from supplier, lineitem l1, orders, nation where s_suppkey = l1.l_suppkey and o_orderkey = l1.l_orderkey and o_orderstatus = 'F' and l1.l_receiptdate > l1.l_commitdate and exists ( select * from lineitem l2 where l2.l_orderkey = l1.l_orderkey and l2.l_suppkey <> l1.l_suppkey ) and not exists ( select * from lineitem l3 where l3.l_orderkey = l1.l_orderkey and l3.l_suppkey <> l1.l_suppkey and l3.l_receiptdate > l3.l_commitdate ) and s_nationkey = n_nationkey and n_name = ? group by s_name order by numwait desc, s_name FETCH NEXT 100 ROWS ONLY + + + + + select cntrycode, count(*) as numcust, sum(c_acctbal) as totacctbal from ( select substr(c_phone, 1, 2) as cntrycode, c_acctbal from customer where substr(c_phone, 1, 2) in (?, ?, ?, ?, ?, ?, ?) and c_acctbal > ( select avg(c_acctbal) from customer where c_acctbal > 0.00 and substr(c_phone, 1, 2) in (?, ?, ?, ?, ?, ?, ?) ) and not exists ( select * from orders where o_custkey = c_custkey ) ) group by cntrycode order by cntrycode + + + + \ No newline at end of file diff --git a/src/main/resources/benchmarks/tpch/gather_schema_stats_oracle.sql b/src/main/resources/benchmarks/tpch/gather_schema_stats_oracle.sql new file mode 100644 index 000000000..eb4a10862 --- /dev/null +++ b/src/main/resources/benchmarks/tpch/gather_schema_stats_oracle.sql @@ -0,0 +1,2 @@ +-- Copyright (c) 2023, Oracle and/or its affiliates. +BEGIN dbms_stats.gather_schema_stats(ownname => 'benchbase', estimate_percent => dbms_stats.auto_sample_size, method_opt => 'for all columns size AUTO'); END;; \ No newline at end of file diff --git a/src/main/resources/benchmarks/twitter/ddl-oracle.sql b/src/main/resources/benchmarks/twitter/ddl-oracle.sql index 6ea8fa891..9e8ef2553 100644 --- a/src/main/resources/benchmarks/twitter/ddl-oracle.sql +++ b/src/main/resources/benchmarks/twitter/ddl-oracle.sql @@ -1,8 +1,9 @@ -BEGIN EXECUTE IMMEDIATE 'DROP TABLE "added_tweets"'; EXCEPTION WHEN OTHERS THEN IF SQLCODE != -942 THEN RAISE; END IF; END;; -BEGIN EXECUTE IMMEDIATE 'DROP TABLE "tweets"'; EXCEPTION WHEN OTHERS THEN IF SQLCODE != -942 THEN RAISE; END IF; END;; -BEGIN EXECUTE IMMEDIATE 'DROP TABLE "user_profiles"'; EXCEPTION WHEN OTHERS THEN IF SQLCODE != -942 THEN RAISE; END IF; END;; +-- Copyright (c) 2023, Oracle and/or its affiliates. +BEGIN EXECUTE IMMEDIATE 'DROP TABLE added_tweets CASCADE CONSTRAINTS'; EXCEPTION WHEN OTHERS THEN IF SQLCODE != -942 THEN RAISE; END IF; END;; +BEGIN EXECUTE IMMEDIATE 'DROP TABLE tweets CASCADE CONSTRAINTS'; EXCEPTION WHEN OTHERS THEN IF SQLCODE != -942 THEN RAISE; END IF; END;; +BEGIN EXECUTE IMMEDIATE 'DROP TABLE user_profiles CASCADE CONSTRAINTS'; EXCEPTION WHEN OTHERS THEN IF SQLCODE != -942 THEN RAISE; END IF; END;; -CREATE TABLE "user_profiles" ( +CREATE TABLE user_profiles ( uuid int NOT NULL, name varchar2(255) DEFAULT NULL, email varchar2(255) DEFAULT NULL, @@ -11,44 +12,44 @@ CREATE TABLE "user_profiles" ( followers number(11,0) DEFAULT NULL, CONSTRAINT uid_key PRIMARY KEY (uuid) ); -CREATE INDEX IDX_USER_FOLLOWERS ON "user_profiles" (followers); -CREATE INDEX IDX_USER_PARTITION ON "user_profiles" (partitionid); +CREATE INDEX IDX_USER_FOLLOWERS ON user_profiles (followers); +CREATE INDEX IDX_USER_PARTITION ON user_profiles (partitionid); -BEGIN EXECUTE IMMEDIATE 'DROP TABLE "followers"'; EXCEPTION WHEN OTHERS THEN IF SQLCODE != -942 THEN RAISE; END IF; END;; -CREATE TABLE "followers" ( - f1 int NOT NULL REFERENCES "user_profiles" (uid), - f2 int NOT NULL REFERENCES "user_profiles" (uid), +BEGIN EXECUTE IMMEDIATE 'DROP TABLE followers CASCADE CONSTRAINTS'; EXCEPTION WHEN OTHERS THEN IF SQLCODE != -942 THEN RAISE; END IF; END;; +CREATE TABLE followers ( + f1 int NOT NULL REFERENCES user_profiles (uuid), + f2 int NOT NULL REFERENCES user_profiles (uuid), CONSTRAINT follower_key PRIMARY KEY (f1,f2) ); -BEGIN EXECUTE IMMEDIATE 'DROP TABLE "follows"'; EXCEPTION WHEN OTHERS THEN IF SQLCODE != -942 THEN RAISE; END IF; END;; -CREATE TABLE "follows" ( - f1 int NOT NULL REFERENCES "user_profiles" (uid), - f2 int NOT NULL REFERENCES "user_profiles" (uid), +BEGIN EXECUTE IMMEDIATE 'DROP TABLE follows CASCADE CONSTRAINTS'; EXCEPTION WHEN OTHERS THEN IF SQLCODE != -942 THEN RAISE; END IF; END;; +CREATE TABLE follows ( + f1 int NOT NULL REFERENCES user_profiles (uuid), + f2 int NOT NULL REFERENCES user_profiles (uuid), CONSTRAINT follows_key PRIMARY KEY (f1,f2) ); -- TODO: id AUTO_INCREMENT -CREATE TABLE "tweets" ( +CREATE TABLE tweets ( id number(19,0) NOT NULL, - uuid int NOT NULL REFERENCES "user_profiles" (uuid), + uuid int NOT NULL REFERENCES user_profiles (uuid), text char(140) NOT NULL, createdate date DEFAULT NULL, CONSTRAINT tweetid_key PRIMARY KEY (id) ); -CREATE INDEX IDX_TWEETS_uuid ON "tweets" (uuid); +CREATE INDEX IDX_TWEETS_uuid ON tweets (uuid); -CREATE TABLE "added_tweets" ( +CREATE TABLE added_tweets ( id number(19,0) NOT NULL, - uuid int NOT NULL REFERENCES "user_profiles" (uuid), + uuid int NOT NULL REFERENCES user_profiles (uuid), text char(140) NOT NULL, createdate date DEFAULT NULL, CONSTRAINT new_tweet_id PRIMARY KEY (id) ); -CREATE INDEX IDX_ADDED_TWEETS_uuid ON "added_tweets" (uuid); +CREATE INDEX IDX_ADDED_TWEETS_uuid ON added_tweets (uuid); -- sequence DECLARE cnt NUMBER; BEGIN SELECT count(*) INTO cnt FROM all_sequences WHERE sequence_name = 'TWEET_IDSEQ'; IF cnt > 0 THEN EXECUTE IMMEDIATE 'DROP SEQUENCE TWEET_IDSEQ'; END IF; END;; -create sequence tweet_idseq start with 1 increment by 1 nomaxvalue; \ No newline at end of file +create sequence tweet_idseq start with 1 increment by 1 nomaxvalue; \ No newline at end of file diff --git a/src/main/resources/benchmarks/twitter/dialect-oracle.xml b/src/main/resources/benchmarks/twitter/dialect-oracle.xml index f853736f6..b96ded2e6 100644 --- a/src/main/resources/benchmarks/twitter/dialect-oracle.xml +++ b/src/main/resources/benchmarks/twitter/dialect-oracle.xml @@ -1,35 +1,36 @@ + - SELECT * FROM "tweets" WHERE id = ? + SELECT * FROM tweets WHERE id = ? - SELECT f2 FROM "follows" WHERE f1 = ? AND ROWNUM <= 20 + SELECT f2 FROM follows WHERE f1 = ? AND ROWNUM <= 20 - SELECT * FROM "tweets" WHERE uuid IN (??) + SELECT * FROM tweets WHERE uuid IN (??) - + - SELECT f2 FROM "followers" WHERE f1 = ? AND ROWNUM <= 20 + SELECT f2 FROM followers WHERE f1 = ? AND ROWNUM <= 20 - SELECT uuid, name FROM "user_profiles" WHERE uuid IN (??) + SELECT uuid, name FROM user_profiles WHERE uuid IN (??) - SELECT * FROM "tweets" WHERE uuid = ? AND ROWNUM <= 10 + SELECT * FROM tweets WHERE uuid = ? AND ROWNUM <= 10 - INSERT INTO "added_tweets" VALUES (tweet_idseq.nextval, ?, ?, ?) + INSERT INTO added_tweets VALUES (tweet_idseq.nextval, ?, ?, ?) diff --git a/src/main/resources/benchmarks/voter/ddl-oracle.sql b/src/main/resources/benchmarks/voter/ddl-oracle.sql new file mode 100644 index 000000000..c8b03c960 --- /dev/null +++ b/src/main/resources/benchmarks/voter/ddl-oracle.sql @@ -0,0 +1,38 @@ +-- Copyright (c) 2023, Oracle and/or its affiliates. +BEGIN EXECUTE IMMEDIATE 'DROP VIEW v_votes_by_phone_number CASCADE CONSTRAINTS'; EXCEPTION WHEN OTHERS THEN IF SQLCODE != -942 THEN RAISE; END IF; END;; +BEGIN EXECUTE IMMEDIATE 'DROP VIEW v_votes_by_contestant_number_state CASCADE CONSTRAINTS'; EXCEPTION WHEN OTHERS THEN IF SQLCODE != -942 THEN RAISE; END IF; END;; +BEGIN EXECUTE IMMEDIATE 'DROP TABLE votes CASCADE CONSTRAINTS'; EXCEPTION WHEN OTHERS THEN IF SQLCODE != -942 THEN RAISE; END IF; END;; +BEGIN EXECUTE IMMEDIATE 'DROP TABLE area_code_state CASCADE CONSTRAINTS'; EXCEPTION WHEN OTHERS THEN IF SQLCODE != -942 THEN RAISE; END IF; END;; +BEGIN EXECUTE IMMEDIATE 'DROP TABLE contestants CASCADE CONSTRAINTS'; EXCEPTION WHEN OTHERS THEN IF SQLCODE != -942 THEN RAISE; END IF; END;; + +CREATE TABLE contestants ( + contestant_number INT NOT NULL, + contestant_name VARCHAR(50) NOT NULL, + PRIMARY KEY (contestant_number) +); + +CREATE TABLE area_code_state ( + area_code INT NOT NULL, + state VARCHAR(2) NOT NULL, + PRIMARY KEY (area_code) +); + +CREATE TABLE votes ( + vote_id NUMBER(19) NOT NULL, + phone_number NUMBER(19) NOT NULL, + state VARCHAR(2) NOT NULL, + contestant_number INT NOT NULL, + created TIMESTAMP(9) NOT NULL, + FOREIGN KEY (contestant_number) REFERENCES contestants (contestant_number) ON DELETE CASCADE +); +CREATE INDEX idx_votes_phone_number ON votes (phone_number); + +CREATE VIEW v_votes_by_phone_number (phone_number, num_votes) AS +SELECT phone_number, COUNT(*) +FROM votes +GROUP BY phone_number; + +CREATE VIEW v_votes_by_contestant_number_state (contestant_number, state, num_votes) AS +SELECT contestant_number, state, COUNT(*) +FROM votes +GROUP BY contestant_number, state; \ No newline at end of file diff --git a/src/main/resources/benchmarks/voter/dialect-oracle.xml b/src/main/resources/benchmarks/voter/dialect-oracle.xml new file mode 100644 index 000000000..5def61e5f --- /dev/null +++ b/src/main/resources/benchmarks/voter/dialect-oracle.xml @@ -0,0 +1,11 @@ + + + + + + + INSERT INTO votes (vote_id, phone_number, state, contestant_number, created) VALUES (?, ?, ?, ?, CURRENT_TIMESTAMP) + + + + diff --git a/src/main/resources/benchmarks/wikipedia/ddl-oracle.sql b/src/main/resources/benchmarks/wikipedia/ddl-oracle.sql index 92d1087cd..172c01bb6 100644 --- a/src/main/resources/benchmarks/wikipedia/ddl-oracle.sql +++ b/src/main/resources/benchmarks/wikipedia/ddl-oracle.sql @@ -1,23 +1,24 @@ +-- Copyright (c) 2023, Oracle and/or its affiliates. -- ORACLE Wikipedia ALTER SESSION SET NLS_LENGTH_SEMANTICS=CHAR; -- Drop All tables -BEGIN EXECUTE IMMEDIATE 'DROP TABLE ipblocks'; EXCEPTION WHEN OTHERS THEN IF SQLCODE != -942 THEN RAISE; END IF; END;; -BEGIN EXECUTE IMMEDIATE 'DROP TABLE logging'; EXCEPTION WHEN OTHERS THEN IF SQLCODE != -942 THEN RAISE; END IF; END;; -BEGIN EXECUTE IMMEDIATE 'DROP TABLE page'; EXCEPTION WHEN OTHERS THEN IF SQLCODE != -942 THEN RAISE; END IF; END;; -BEGIN EXECUTE IMMEDIATE 'DROP TABLE page_restrictions'; EXCEPTION WHEN OTHERS THEN IF SQLCODE != -942 THEN RAISE; END IF; END;; -BEGIN EXECUTE IMMEDIATE 'DROP TABLE recentchanges'; EXCEPTION WHEN OTHERS THEN IF SQLCODE != -942 THEN RAISE; END IF; END;; -BEGIN EXECUTE IMMEDIATE 'DROP TABLE revision'; EXCEPTION WHEN OTHERS THEN IF SQLCODE != -942 THEN RAISE; END IF; END;; -BEGIN EXECUTE IMMEDIATE 'DROP TABLE text'; EXCEPTION WHEN OTHERS THEN IF SQLCODE != -942 THEN RAISE; END IF; END;; -BEGIN EXECUTE IMMEDIATE 'DROP TABLE useracct'; EXCEPTION WHEN OTHERS THEN IF SQLCODE != -942 THEN RAISE; END IF; END;; -BEGIN EXECUTE IMMEDIATE 'DROP TABLE user_groups'; EXCEPTION WHEN OTHERS THEN IF SQLCODE != -942 THEN RAISE; END IF; END;; -BEGIN EXECUTE IMMEDIATE 'DROP TABLE watchlist'; EXCEPTION WHEN OTHERS THEN IF SQLCODE != -942 THEN RAISE; END IF; END;; +BEGIN EXECUTE IMMEDIATE 'DROP TABLE ipblocks CASCADE CONSTRAINTS'; EXCEPTION WHEN OTHERS THEN IF SQLCODE != -942 THEN RAISE; END IF; END;; +BEGIN EXECUTE IMMEDIATE 'DROP TABLE logging CASCADE CONSTRAINTS'; EXCEPTION WHEN OTHERS THEN IF SQLCODE != -942 THEN RAISE; END IF; END;; +BEGIN EXECUTE IMMEDIATE 'DROP TABLE page CASCADE CONSTRAINTS'; EXCEPTION WHEN OTHERS THEN IF SQLCODE != -942 THEN RAISE; END IF; END;; +BEGIN EXECUTE IMMEDIATE 'DROP TABLE page_restrictions CASCADE CONSTRAINTS'; EXCEPTION WHEN OTHERS THEN IF SQLCODE != -942 THEN RAISE; END IF; END;; +BEGIN EXECUTE IMMEDIATE 'DROP TABLE recentchanges CASCADE CONSTRAINTS'; EXCEPTION WHEN OTHERS THEN IF SQLCODE != -942 THEN RAISE; END IF; END;; +BEGIN EXECUTE IMMEDIATE 'DROP TABLE revision CASCADE CONSTRAINTS'; EXCEPTION WHEN OTHERS THEN IF SQLCODE != -942 THEN RAISE; END IF; END;; +BEGIN EXECUTE IMMEDIATE 'DROP TABLE text CASCADE CONSTRAINTS'; EXCEPTION WHEN OTHERS THEN IF SQLCODE != -942 THEN RAISE; END IF; END;; +BEGIN EXECUTE IMMEDIATE 'DROP TABLE useracct CASCADE CONSTRAINTS'; EXCEPTION WHEN OTHERS THEN IF SQLCODE != -942 THEN RAISE; END IF; END;; +BEGIN EXECUTE IMMEDIATE 'DROP TABLE user_groups CASCADE CONSTRAINTS'; EXCEPTION WHEN OTHERS THEN IF SQLCODE != -942 THEN RAISE; END IF; END;; +BEGIN EXECUTE IMMEDIATE 'DROP TABLE watchlist CASCADE CONSTRAINTS'; EXCEPTION WHEN OTHERS THEN IF SQLCODE != -942 THEN RAISE; END IF; END;; -- Create tables CREATE TABLE ipblocks ( -ipb_id number(10,0) NOT NULL, +ipb_id number(10,0) GENERATED BY DEFAULT ON NULL AS IDENTITY NOT NULL, ipb_address varchar2(255) NOT NULL, ipb_user number(10,0) DEFAULT '0', ipb_by number(10,0) DEFAULT '0', @@ -39,7 +40,7 @@ UNIQUE (ipb_address,ipb_user,ipb_auto,ipb_anon_only) ); CREATE TABLE logging ( -log_id number(10,0) NOT NULL, +log_id number(10,0) GENERATED BY DEFAULT ON NULL AS IDENTITY NOT NULL, log_type varchar2(32) NOT NULL, log_action varchar2(32) NOT NULL, log_timestamp varchar2(14) DEFAULT '19700101000000', @@ -55,7 +56,7 @@ PRIMARY KEY (log_id) ); CREATE TABLE page ( -page_id number(10,0) NOT NULL, +page_id number(10,0) GENERATED BY DEFAULT ON NULL AS IDENTITY NOT NULL, page_namespace number(10,0) NOT NULL, page_title varchar2(255) NOT NULL, page_restrictions varchar(255) NOT NULL, @@ -83,7 +84,7 @@ UNIQUE (pr_page,pr_type) ); CREATE TABLE recentchanges ( -rc_id number(10,0) NOT NULL, +rc_id number(10,0) GENERATED BY DEFAULT ON NULL AS IDENTITY NOT NULL, rc_timestamp varchar2(14) DEFAULT '', rc_cur_time varchar2(14) DEFAULT '', rc_user number(10,0) DEFAULT '0', @@ -95,7 +96,7 @@ rc_minor number(3,0) DEFAULT '0', rc_bot number(3,0) DEFAULT '0', rc_new number(3,0) DEFAULT '0', rc_cur_id number(10,0) DEFAULT '0', -rc_this_oldid number(10,0) DEFAULT '0', +rc_this_oldid number(19,0) DEFAULT '0', rc_last_oldid number(10,0) DEFAULT '0', rc_type number(3,0) DEFAULT '0', rc_moved_to_ns number(3,0) DEFAULT '0', @@ -113,7 +114,7 @@ PRIMARY KEY (rc_id) ); CREATE TABLE revision ( -rev_id number(10,0) NOT NULL, +rev_id number(10,0) GENERATED BY DEFAULT ON NULL AS IDENTITY NOT NULL, rev_page number(10,0) NOT NULL, rev_text_id number(10,0) NOT NULL, rev_comment varchar2(1024) NOT NULL, @@ -129,7 +130,7 @@ UNIQUE (rev_page,rev_id) ); CREATE TABLE text ( -old_id number(10,0) NOT NULL, +old_id int GENERATED BY DEFAULT ON NULL AS IDENTITY NOT NULL, old_text clob NOT NULL, old_flags varchar2(30) NOT NULL, old_page number(10,0) DEFAULT NULL, @@ -202,59 +203,4 @@ CREATE INDEX IDX_RC_IP ON recentchanges (rc_ip); CREATE INDEX IDX_RC_NS_USER_TEXT ON recentchanges (rc_namespace,rc_user_text); CREATE INDEX IDX_RC_USER_TEXT ON recentchanges (rc_user_text,rc_timestamp); --- Sequences -DECLARE cnt NUMBER; BEGIN SELECT count(*) INTO cnt FROM all_sequences WHERE sequence_name = 'IPBLOCKS_SEQ'; IF cnt > 0 THEN EXECUTE IMMEDIATE 'DROP SEQUENCE IPBLOCKS_SEQ'; END IF; END;; -DECLARE cnt NUMBER; BEGIN SELECT count(*) INTO cnt FROM all_sequences WHERE sequence_name = 'LOGGING_SEQ'; IF cnt > 0 THEN EXECUTE IMMEDIATE 'DROP SEQUENCE LOGGING_SEQ'; END IF; END;; -DECLARE cnt NUMBER; BEGIN SELECT count(*) INTO cnt FROM all_sequences WHERE sequence_name = 'PAGE_SEQ'; IF cnt > 0 THEN EXECUTE IMMEDIATE 'DROP SEQUENCE PAGE_SEQ'; END IF; END;; -DECLARE cnt NUMBER; BEGIN SELECT count(*) INTO cnt FROM all_sequences WHERE sequence_name = 'PAGE_RESTRICTIONS_SEQ'; IF cnt > 0 THEN EXECUTE IMMEDIATE 'DROP SEQUENCE PAGE_RESTRICTIONS_SEQ'; END IF; END;; -DECLARE cnt NUMBER; BEGIN SELECT count(*) INTO cnt FROM all_sequences WHERE sequence_name = 'RECENTCHANGES_SEQ'; IF cnt > 0 THEN EXECUTE IMMEDIATE 'DROP SEQUENCE RECENTCHANGES_SEQ'; END IF; END;; -DECLARE cnt NUMBER; BEGIN SELECT count(*) INTO cnt FROM all_sequences WHERE sequence_name = 'REVISION_SEQ'; IF cnt > 0 THEN EXECUTE IMMEDIATE 'DROP SEQUENCE REVISION_SEQ'; END IF; END;; -DECLARE cnt NUMBER; BEGIN SELECT count(*) INTO cnt FROM all_sequences WHERE sequence_name = 'TEXT_SEQ'; IF cnt > 0 THEN EXECUTE IMMEDIATE 'DROP SEQUENCE TEXT_SEQ'; END IF; END;; -DECLARE cnt NUMBER; BEGIN SELECT count(*) INTO cnt FROM all_sequences WHERE sequence_name = 'USER_SEQ'; IF cnt > 0 THEN EXECUTE IMMEDIATE 'DROP SEQUENCE USER_SEQ'; END IF; END;; - -create sequence ipblocks_seq start with 1 increment by 1 nomaxvalue; -create sequence logging_seq start with 1 increment by 1 nomaxvalue; -create sequence page_seq start with 1 increment by 1 nomaxvalue; -create sequence page_restrictions_seq start with 1 increment by 1 nomaxvalue; -create sequence recentchanges_seq start with 1 increment by 1 nomaxvalue; -create sequence revision_seq start with 1 increment by 1 nomaxvalue; -create sequence text_seq start with 1 increment by 1 nomaxvalue; -create sequence user_seq start with 1 increment by 1 nomaxvalue; - --- Sequences' triggers -CREATE OR REPLACE TRIGGER user_seq_tr -BEFORE INSERT ON useracct FOR EACH ROW -WHEN (NEW.user_id IS NULL OR NEW.user_id = 0) -BEGIN -SELECT user_seq.NEXTVAL INTO :NEW.user_id FROM dual;END;; - -CREATE OR REPLACE TRIGGER page_seq_tr -BEFORE INSERT ON page FOR EACH ROW -WHEN (NEW.page_id IS NULL OR NEW.page_id = 0) -BEGIN -SELECT page_seq.NEXTVAL INTO :NEW.page_id FROM dual;END;; - -CREATE OR REPLACE TRIGGER text_seq_tr -BEFORE INSERT ON text FOR EACH ROW -WHEN (NEW.old_id IS NULL OR NEW.old_id = 0) -BEGIN -SELECT text_seq.NEXTVAL INTO :NEW.old_id FROM dual;END;; - -CREATE OR REPLACE TRIGGER revision_seq_tr -BEFORE INSERT ON revision FOR EACH ROW -WHEN (NEW.rev_id IS NULL OR NEW.rev_id = 0) -BEGIN -SELECT revision_seq.NEXTVAL INTO :NEW.rev_id FROM dual;END;; - -CREATE OR REPLACE TRIGGER recentchanges_seq_tr -BEFORE INSERT ON recentchanges FOR EACH ROW -WHEN (NEW.rc_id IS NULL OR NEW.rc_id = 0) -BEGIN -SELECT recentchanges_seq.NEXTVAL INTO :NEW.rc_id FROM dual;END;; - -CREATE OR REPLACE TRIGGER logging_seq_tr -BEFORE INSERT ON logging FOR EACH ROW -WHEN (NEW.log_id IS NULL OR NEW.log_id = 0) -BEGIN -SELECT logging_seq.NEXTVAL INTO :NEW.log_id FROM dual;END;; diff --git a/src/main/resources/benchmarks/wikipedia/dialect-oracle.xml b/src/main/resources/benchmarks/wikipedia/dialect-oracle.xml index 6b1f1f5f4..2203ac36f 100644 --- a/src/main/resources/benchmarks/wikipedia/dialect-oracle.xml +++ b/src/main/resources/benchmarks/wikipedia/dialect-oracle.xml @@ -1,72 +1,30 @@ + - - - INSERT /*+ ignore_row_on_dupkey_index(watchlist(wl_user,wl_namespace,wl_title)) */ INTO watchlist (wl_user,wl_namespace,wl_title,wl_notificationtimestamp) VALUES (?,?,?,NULL) - - - UPDATE useracct SET user_touched = ? WHERE user_id = ? - - - - - DELETE FROM watchlist WHERE wl_user = ? AND wl_namespace = ? AND wl_title = ? - - - UPDATE useracct SET user_touched = ? WHERE user_id = ? - - - SELECT * FROM page WHERE page_namespace = ? AND page_title = ? AND ROWNUM = 1 + SELECT * FROM page WHERE page_namespace = ? AND page_title = ? FETCH NEXT 1 ROWS ONLY - SELECT * FROM page,revision WHERE (page_id=rev_page) AND rev_page = ? AND page_id = ? AND (rev_id=page_latest) AND ROWNUM = 1 + SELECT * FROM page,revision WHERE (page_id=rev_page) AND rev_page = ? AND page_id = ? AND (rev_id=page_latest) FETCH NEXT 1 ROWS ONLY - SELECT old_text,old_flags FROM text WHERE old_id = ? AND ROWNUM = 1 - - - - - INSERT INTO text (old_id,old_page,old_text,old_flags) VALUES (text_seq.NEXTVAL,?,?,'utf-8') - - - INSERT INTO revision (rev_id,rev_page,rev_text_id,rev_comment,rev_minor_edit,rev_user,rev_user_text,rev_timestamp,rev_deleted,rev_len,rev_parent_id) - VALUES (revision_seq.NEXTVAL,?, ?, ? ,'0',?, ?, ? ,'0',?,?) - - - INSERT INTO recentchanges (rc_id,rc_timestamp,rc_cur_time,rc_namespace,rc_title,rc_type,rc_minor,rc_cur_id,rc_user,rc_user_text,rc_comment,rc_this_oldid, - rc_last_oldid,rc_bot,rc_moved_to_ns,rc_moved_to_title,rc_ip,rc_patrolled,rc_new,rc_old_len,rc_new_len,rc_deleted,rc_logid,rc_log_type,rc_log_action,rc_params) - VALUES (recentchanges_seq.NEXTVAL,?, ?, ? , ? ,'0','0', ? , ? , ? ,'', ? , ? ,'0','0','',?,'1','0', ? , ? ,'0','0',NULL,'','') - - - SELECT * FROM useracct WHERE user_id = ? - - - UPDATE useracct SET user_editcount=user_editcount+1 WHERE user_id = ? - - - UPDATE useracct SET user_touched = ? WHERE user_id = ? - - - INSERT INTO logging (log_id,log_type,log_action,log_timestamp,log_user,log_user_text,log_namespace,log_title,log_page,log_comment,log_params) - VALUES (logging_seq.NEXTVAL,'patrol','patrol',?,?,?,?,?,?,'',?) + SELECT old_text,old_flags FROM text WHERE old_id = ? FETCH NEXT 1 ROWS ONLY - SELECT * FROM useracct WHERE user_id = ? AND ROWNUM = 1 + SELECT * FROM useracct WHERE user_id = ? FETCH NEXT 1 ROWS ONLY - SELECT * FROM page WHERE page_namespace = ? AND page_title = ? AND ROWNUM = 1 + SELECT * FROM page WHERE page_namespace = ? AND page_title = ? FETCH NEXT 1 ROWS ONLY - SELECT * FROM page, revision WHERE (page_id=rev_page) AND rev_page = ? AND page_id = ? AND (rev_id=page_latest) AND ROWNUM = 1 + SELECT * FROM page, revision WHERE (page_id=rev_page) AND rev_page = ? AND page_id = ? AND (rev_id=page_latest) FETCH NEXT 1 ROWS ONLY - SELECT old_text,old_flags FROM text WHERE old_id = ? AND ROWNUM = 1 + SELECT old_text,old_flags FROM text WHERE old_id = ? FETCH NEXT 1 ROWS ONLY From 913b4170230040c9b3ceeaf78b8d519de2b998b1 Mon Sep 17 00:00:00 2001 From: Nguyen Nguyen Date: Fri, 6 Oct 2023 14:46:02 +1000 Subject: [PATCH 02/17] Oracle DB service name --- .github/workflows/maven.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/maven.yml b/.github/workflows/maven.yml index f14fc4278..19d209749 100644 --- a/.github/workflows/maven.yml +++ b/.github/workflows/maven.yml @@ -292,6 +292,8 @@ jobs: env: ORACLE_PWD: password ORACLE_CHARACTERSET: AL32UTF8 + options: >- + --name oracle steps: - name: Download artifact uses: actions/download-artifact@v3 From b9c035576b6397ef56bc40be66082abee8c8c014 Mon Sep 17 00:00:00 2001 From: Nguyen Nguyen Date: Fri, 6 Oct 2023 15:53:10 +1000 Subject: [PATCH 03/17] Move user reset to sql script inside Docker --- .github/workflows/maven.yml | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/.github/workflows/maven.yml b/.github/workflows/maven.yml index 19d209749..183565b27 100644 --- a/.github/workflows/maven.yml +++ b/.github/workflows/maven.yml @@ -308,9 +308,11 @@ jobs: run: | rm -rf benchbase-oracle.tgz - - name: Set up non-DBA user + # Add a SQL file to recreate non-DBA user to Oracle DB Docker so it can be invoked later using sqlplus + - name: Set up user reset script run: | - printf "create user benchbase identified by password;\nGRANT CONNECT, RESOURCE TO benchbase;" | docker exec oracle sqlplus "system/password@freepdb1" + printf "DROP USER benchbase CASCADE;\ncreate user benchbase identified by password;\nGRANT CONNECT, RESOURCE, UNLIMITED TABLESPACE TO benchbase;\nGRANT EXECUTE ON DBMS_CRYPTO TO benchbase;\nGRANT EXECUTE ON DBMS_LOCK TO benchbase;\n" > reset.sql + docker cp reset.sql oracle:/home/oracle/reset.sql - name: Set up JDK uses: actions/setup-java@v3 @@ -320,7 +322,7 @@ jobs: - name: Run benchmark run: | - printf "DROP USER benchbase CASCADE; create user benchbase identified by password;\nGRANT CONNECT, RESOURCE, UNLIMITED TABLESPACE TO benchbase; GRANT EXECUTE ON DBMS_CRYPTO TO benchbase; GRANT EXECUTE ON DBMS_LOCK TO benchbase;" | docker exec oracle sqlplus "sys/password@freepdb1 as sysdba" + docker exec oracle sqlplus "sys/password@freepdb1 as sysdba" @reset.sql java -jar benchbase.jar -b ${{matrix.benchmark}} -c config/oracle/sample_${{matrix.benchmark}}_config.xml --create=true --load=true --execute=true --json-histograms results/histograms.json # FIXME: Reduce the error rate so we don't need these overrides. if [ ${{matrix.benchmark}} == auctionmark ]; then From 77ef9e2fe863ed57ab33e62b28b5acc049352726 Mon Sep 17 00:00:00 2001 From: Nguyen Nguyen Date: Fri, 6 Oct 2023 16:50:40 +1000 Subject: [PATCH 04/17] Error rate fix for tpcc/resourcestresser --- .github/workflows/maven.yml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/.github/workflows/maven.yml b/.github/workflows/maven.yml index 183565b27..ad1138a3e 100644 --- a/.github/workflows/maven.yml +++ b/.github/workflows/maven.yml @@ -330,7 +330,9 @@ jobs: elif [ ${{matrix.benchmark}} == tatp ]; then ERRORS_THRESHOLD=0.05 elif [ ${{matrix.benchmark}} == tpcc ]; then - ERRORS_THRESHOLD=0.02 + ERRORS_THRESHOLD=0.03 + elif [ ${{matrix.benchmark}} == resourcestresser ]; then + ERRORS_THRESHOLD=0.04 elif [ ${{matrix.benchmark}} == wikipedia ]; then ERRORS_THRESHOLD=0.02 fi From ec0efe004affcc0697a5a87e4bbc2721d4852952 Mon Sep 17 00:00:00 2001 From: Nguyen Nguyen Date: Thu, 12 Oct 2023 13:21:51 +1000 Subject: [PATCH 05/17] Templated benchmark default oracle config. Oracle workflow with templated config --- .github/workflows/maven.yml | 11 ++++- config/oracle/sample_templated_config.xml | 50 +++++++++++++++++++++++ 2 files changed, 59 insertions(+), 2 deletions(-) create mode 100644 config/oracle/sample_templated_config.xml diff --git a/.github/workflows/maven.yml b/.github/workflows/maven.yml index ad1138a3e..be9a37e59 100644 --- a/.github/workflows/maven.yml +++ b/.github/workflows/maven.yml @@ -282,7 +282,7 @@ jobs: strategy: fail-fast: false matrix: - benchmark: [ 'auctionmark', 'epinions', 'hyadapt', 'otmetrics', 'resourcestresser', 'seats', 'sibench', 'smallbank', 'tatp', 'tpcc', 'twitter', 'voter', 'wikipedia', 'ycsb' ] + benchmark: [ 'auctionmark', 'epinions', 'hyadapt', 'otmetrics', 'resourcestresser', 'seats', 'sibench', 'smallbank', 'tatp', 'tpcc', 'twitter', 'voter', 'wikipedia', 'ycsb', 'templated' ] services: oracle: image: container-registry.oracle.com/database/free:23.2.0.0 @@ -323,7 +323,14 @@ jobs: - name: Run benchmark run: | docker exec oracle sqlplus "sys/password@freepdb1 as sysdba" @reset.sql - java -jar benchbase.jar -b ${{matrix.benchmark}} -c config/oracle/sample_${{matrix.benchmark}}_config.xml --create=true --load=true --execute=true --json-histograms results/histograms.json + # For templated benchmarks, we need to preload some data for the test since by design, templated benchmarks do not support the 'load' operation + # In this case, we load the tpcc data. + if [[ ${{matrix.benchmark}} == templated ]]; then + java -jar benchbase.jar -b tpcc -c config/oracle/sample_tpcc_config.xml --create=true --load=true --execute=false --json-histograms results/histograms.json + java -jar benchbase.jar -b ${{matrix.benchmark}} -c config/oracle/sample_${{matrix.benchmark}}_config.xml --create=false --load=false --execute=true --json-histograms results/histograms.json + else + java -jar benchbase.jar -b ${{matrix.benchmark}} -c config/oracle/sample_${{matrix.benchmark}}_config.xml --create=true --load=true --execute=true --json-histograms results/histograms.json + fi # FIXME: Reduce the error rate so we don't need these overrides. if [ ${{matrix.benchmark}} == auctionmark ]; then ERRORS_THRESHOLD=0.04 diff --git a/config/oracle/sample_templated_config.xml b/config/oracle/sample_templated_config.xml new file mode 100644 index 000000000..0faf2ef68 --- /dev/null +++ b/config/oracle/sample_templated_config.xml @@ -0,0 +1,50 @@ + + + + + + ORACLE + oracle.jdbc.OracleDriver + jdbc:oracle:thin:@localhost:1521/freepdb1 + benchbase + password + TRANSACTION_SERIALIZABLE + 128 + + + + data/templated/example.xml + + + 1 + + + + 100 + 30,20,10,30,10 + + + + + + + GetOrder + + + GetCust + + + GetCustNull + + + GetWarehouse + + + GetItemByPrice + + + From d1c6e4754f36eb5dc9f3cff391e3fc06a5e3b7b6 Mon Sep 17 00:00:00 2001 From: Nguyen Nguyen Date: Wed, 18 Oct 2023 12:35:14 +1000 Subject: [PATCH 06/17] Move to Oracle 21 XE --- .github/workflows/maven.yml | 22 ++++++++++++++----- config/oracle/sample_auctionmark_config.xml | 2 +- config/oracle/sample_chbenchmark_config.xml | 2 +- config/oracle/sample_epinions_config.xml | 2 +- config/oracle/sample_hyadapt_config.xml | 2 +- config/oracle/sample_noop_config.xml | 2 +- config/oracle/sample_otmetrics_config.xml | 2 +- .../oracle/sample_resourcestresser_config.xml | 2 +- config/oracle/sample_seats_config.xml | 2 +- config/oracle/sample_sibench_config.xml | 2 +- config/oracle/sample_smallbank_config.xml | 2 +- config/oracle/sample_tatp_config.xml | 2 +- config/oracle/sample_templated_config.xml | 2 +- config/oracle/sample_tpcc_config.xml | 2 +- config/oracle/sample_tpch_config.xml | 2 +- config/oracle/sample_twitter_config.xml | 2 +- config/oracle/sample_voter_config.xml | 2 +- config/oracle/sample_wikipedia_config.xml | 2 +- config/oracle/sample_ycsb_config.xml | 2 +- docker/oracle/docker-compose.yml | 16 +++++++++----- .../oracle/{setup/01_user.sql => reset.sql} | 6 ++--- 21 files changed, 47 insertions(+), 33 deletions(-) rename docker/oracle/{setup/01_user.sql => reset.sql} (63%) diff --git a/.github/workflows/maven.yml b/.github/workflows/maven.yml index be9a37e59..231cbcfd7 100644 --- a/.github/workflows/maven.yml +++ b/.github/workflows/maven.yml @@ -285,15 +285,22 @@ jobs: benchmark: [ 'auctionmark', 'epinions', 'hyadapt', 'otmetrics', 'resourcestresser', 'seats', 'sibench', 'smallbank', 'tatp', 'tpcc', 'twitter', 'voter', 'wikipedia', 'ycsb', 'templated' ] services: oracle: - image: container-registry.oracle.com/database/free:23.2.0.0 + image: gvenzl/oracle-xe:21.3.0-slim-faststart ports: - "1521:1521" - "5500:5500" env: - ORACLE_PWD: password + ORACLE_PASSWORD: password ORACLE_CHARACTERSET: AL32UTF8 + APP_USER: benchbase + APP_USER_PASSWORD: password options: >- --name oracle + --health-cmd "echo exit | sqlplus benchbase/password@xepdb1 | grep Connected" + --health-interval 10s + --health-timeout 5s + --health-retries 5 + --health-start-period 5s steps: - name: Download artifact uses: actions/download-artifact@v3 @@ -308,11 +315,14 @@ jobs: run: | rm -rf benchbase-oracle.tgz - # Add a SQL file to recreate non-DBA user to Oracle DB Docker so it can be invoked later using sqlplus + # Add a reset SQL file to Oracle container home directory (docker exec oracle pwd) to recreate non-DBA user, so it can be invoked later using sqlplus + # See docker/oracle/reset.sql + # This file is recreated using printf instead of included in the artifact because only Oracle profile reset is more complicated than others, + # and benchmark doesn't need to be reset between runs normally - name: Set up user reset script run: | - printf "DROP USER benchbase CASCADE;\ncreate user benchbase identified by password;\nGRANT CONNECT, RESOURCE, UNLIMITED TABLESPACE TO benchbase;\nGRANT EXECUTE ON DBMS_CRYPTO TO benchbase;\nGRANT EXECUTE ON DBMS_LOCK TO benchbase;\n" > reset.sql - docker cp reset.sql oracle:/home/oracle/reset.sql + printf "DROP USER benchbase CASCADE;\ncreate user benchbase identified by password;\nGRANT CONNECT, RESOURCE, CREATE VIEW, UNLIMITED TABLESPACE TO benchbase;\nGRANT EXECUTE ON DBMS_CRYPTO TO benchbase;\nGRANT EXECUTE ON DBMS_LOCK TO benchbase;\n" > reset.sql + docker cp reset.sql oracle:/opt/oracle/reset.sql - name: Set up JDK uses: actions/setup-java@v3 @@ -322,7 +332,7 @@ jobs: - name: Run benchmark run: | - docker exec oracle sqlplus "sys/password@freepdb1 as sysdba" @reset.sql + docker exec oracle sqlplus "sys/password@xepdb1 as sysdba" @reset.sql # For templated benchmarks, we need to preload some data for the test since by design, templated benchmarks do not support the 'load' operation # In this case, we load the tpcc data. if [[ ${{matrix.benchmark}} == templated ]]; then diff --git a/config/oracle/sample_auctionmark_config.xml b/config/oracle/sample_auctionmark_config.xml index bfe909d0f..e3b54acc1 100644 --- a/config/oracle/sample_auctionmark_config.xml +++ b/config/oracle/sample_auctionmark_config.xml @@ -5,7 +5,7 @@ ORACLE oracle.jdbc.OracleDriver - jdbc:oracle:thin:@localhost:1521/freepdb1 + jdbc:oracle:thin:@localhost:1521/xepdb1 benchbase password TRANSACTION_SERIALIZABLE diff --git a/config/oracle/sample_chbenchmark_config.xml b/config/oracle/sample_chbenchmark_config.xml index ee165747e..2989003c3 100644 --- a/config/oracle/sample_chbenchmark_config.xml +++ b/config/oracle/sample_chbenchmark_config.xml @@ -5,7 +5,7 @@ ORACLE oracle.jdbc.OracleDriver - jdbc:oracle:thin:@localhost:1521/freepdb1 + jdbc:oracle:thin:@localhost:1521/xepdb1 benchbase password TRANSACTION_SERIALIZABLE diff --git a/config/oracle/sample_epinions_config.xml b/config/oracle/sample_epinions_config.xml index 1b4c9e91f..649432af7 100644 --- a/config/oracle/sample_epinions_config.xml +++ b/config/oracle/sample_epinions_config.xml @@ -5,7 +5,7 @@ ORACLE oracle.jdbc.OracleDriver - jdbc:oracle:thin:@localhost:1521/freepdb1 + jdbc:oracle:thin:@localhost:1521/xepdb1 benchbase password TRANSACTION_SERIALIZABLE diff --git a/config/oracle/sample_hyadapt_config.xml b/config/oracle/sample_hyadapt_config.xml index fa35a658e..a3ac12073 100644 --- a/config/oracle/sample_hyadapt_config.xml +++ b/config/oracle/sample_hyadapt_config.xml @@ -5,7 +5,7 @@ ORACLE oracle.jdbc.OracleDriver - jdbc:oracle:thin:@localhost:1521/freepdb1 + jdbc:oracle:thin:@localhost:1521/xepdb1 benchbase password TRANSACTION_SERIALIZABLE diff --git a/config/oracle/sample_noop_config.xml b/config/oracle/sample_noop_config.xml index ac9d9b331..7d8b2f5d4 100644 --- a/config/oracle/sample_noop_config.xml +++ b/config/oracle/sample_noop_config.xml @@ -5,7 +5,7 @@ ORACLE oracle.jdbc.OracleDriver - jdbc:oracle:thin:@localhost:1521/freepdb1 + jdbc:oracle:thin:@localhost:1521/xepdb1 system password TRANSACTION_SERIALIZABLE diff --git a/config/oracle/sample_otmetrics_config.xml b/config/oracle/sample_otmetrics_config.xml index 43b50e166..0450050f1 100644 --- a/config/oracle/sample_otmetrics_config.xml +++ b/config/oracle/sample_otmetrics_config.xml @@ -5,7 +5,7 @@ ORACLE oracle.jdbc.OracleDriver - jdbc:oracle:thin:@localhost:1521/freepdb1 + jdbc:oracle:thin:@localhost:1521/xepdb1 benchbase password TRANSACTION_SERIALIZABLE diff --git a/config/oracle/sample_resourcestresser_config.xml b/config/oracle/sample_resourcestresser_config.xml index f6309f26a..2a9bbe500 100644 --- a/config/oracle/sample_resourcestresser_config.xml +++ b/config/oracle/sample_resourcestresser_config.xml @@ -5,7 +5,7 @@ ORACLE oracle.jdbc.OracleDriver - jdbc:oracle:thin:@localhost:1521/freepdb1 + jdbc:oracle:thin:@localhost:1521/xepdb1 benchbase password TRANSACTION_SERIALIZABLE diff --git a/config/oracle/sample_seats_config.xml b/config/oracle/sample_seats_config.xml index 035e99638..479abf19d 100644 --- a/config/oracle/sample_seats_config.xml +++ b/config/oracle/sample_seats_config.xml @@ -5,7 +5,7 @@ ORACLE oracle.jdbc.OracleDriver - jdbc:oracle:thin:@localhost:1521/freepdb1 + jdbc:oracle:thin:@localhost:1521/xepdb1 benchbase password TRANSACTION_SERIALIZABLE diff --git a/config/oracle/sample_sibench_config.xml b/config/oracle/sample_sibench_config.xml index ca4b90ce5..f4e521d25 100644 --- a/config/oracle/sample_sibench_config.xml +++ b/config/oracle/sample_sibench_config.xml @@ -5,7 +5,7 @@ ORACLE oracle.jdbc.OracleDriver - jdbc:oracle:thin:@localhost:1521/freepdb1 + jdbc:oracle:thin:@localhost:1521/xepdb1 benchbase password TRANSACTION_SERIALIZABLE diff --git a/config/oracle/sample_smallbank_config.xml b/config/oracle/sample_smallbank_config.xml index 236677cad..fdd0de7c5 100644 --- a/config/oracle/sample_smallbank_config.xml +++ b/config/oracle/sample_smallbank_config.xml @@ -5,7 +5,7 @@ ORACLE oracle.jdbc.OracleDriver - jdbc:oracle:thin:@localhost:1521/freepdb1 + jdbc:oracle:thin:@localhost:1521/xepdb1 benchbase password TRANSACTION_SERIALIZABLE diff --git a/config/oracle/sample_tatp_config.xml b/config/oracle/sample_tatp_config.xml index 233f4ccc5..651a10bd0 100644 --- a/config/oracle/sample_tatp_config.xml +++ b/config/oracle/sample_tatp_config.xml @@ -5,7 +5,7 @@ ORACLE oracle.jdbc.OracleDriver - jdbc:oracle:thin:@localhost:1521/freepdb1 + jdbc:oracle:thin:@localhost:1521/xepdb1 benchbase password TRANSACTION_SERIALIZABLE diff --git a/config/oracle/sample_templated_config.xml b/config/oracle/sample_templated_config.xml index 0faf2ef68..23f17ca60 100644 --- a/config/oracle/sample_templated_config.xml +++ b/config/oracle/sample_templated_config.xml @@ -5,7 +5,7 @@ ORACLE oracle.jdbc.OracleDriver - jdbc:oracle:thin:@localhost:1521/freepdb1 + jdbc:oracle:thin:@localhost:1521/xepdb1 benchbase password TRANSACTION_SERIALIZABLE diff --git a/config/oracle/sample_tpcc_config.xml b/config/oracle/sample_tpcc_config.xml index 6ced76b9c..a3089a0e9 100644 --- a/config/oracle/sample_tpcc_config.xml +++ b/config/oracle/sample_tpcc_config.xml @@ -5,7 +5,7 @@ ORACLE oracle.jdbc.OracleDriver - jdbc:oracle:thin:@localhost:1521/freepdb1 + jdbc:oracle:thin:@localhost:1521/xepdb1 benchbase password diff --git a/config/oracle/sample_tpch_config.xml b/config/oracle/sample_tpch_config.xml index ab71e0d9e..92afc10f3 100644 --- a/config/oracle/sample_tpch_config.xml +++ b/config/oracle/sample_tpch_config.xml @@ -5,7 +5,7 @@ ORACLE oracle.jdbc.OracleDriver - jdbc:oracle:thin:@localhost:1521/freepdb1 + jdbc:oracle:thin:@localhost:1521/xepdb1 benchbase password TRANSACTION_SERIALIZABLE diff --git a/config/oracle/sample_twitter_config.xml b/config/oracle/sample_twitter_config.xml index 9f1f1c6c5..07e937114 100644 --- a/config/oracle/sample_twitter_config.xml +++ b/config/oracle/sample_twitter_config.xml @@ -5,7 +5,7 @@ ORACLE oracle.jdbc.OracleDriver - jdbc:oracle:thin:@localhost:1521/freepdb1 + jdbc:oracle:thin:@localhost:1521/xepdb1 benchbase password TRANSACTION_SERIALIZABLE diff --git a/config/oracle/sample_voter_config.xml b/config/oracle/sample_voter_config.xml index ce33f3d04..8775f08e9 100644 --- a/config/oracle/sample_voter_config.xml +++ b/config/oracle/sample_voter_config.xml @@ -5,7 +5,7 @@ ORACLE oracle.jdbc.OracleDriver - jdbc:oracle:thin:@localhost:1521/freepdb1 + jdbc:oracle:thin:@localhost:1521/xepdb1 benchbase password TRANSACTION_SERIALIZABLE diff --git a/config/oracle/sample_wikipedia_config.xml b/config/oracle/sample_wikipedia_config.xml index a0f1e47f4..43f8dd996 100644 --- a/config/oracle/sample_wikipedia_config.xml +++ b/config/oracle/sample_wikipedia_config.xml @@ -5,7 +5,7 @@ ORACLE oracle.jdbc.OracleDriver - jdbc:oracle:thin:@localhost:1521/freepdb1 + jdbc:oracle:thin:@localhost:1521/xepdb1 benchbase password diff --git a/config/oracle/sample_ycsb_config.xml b/config/oracle/sample_ycsb_config.xml index 165d1f36c..988438e70 100644 --- a/config/oracle/sample_ycsb_config.xml +++ b/config/oracle/sample_ycsb_config.xml @@ -5,7 +5,7 @@ ORACLE oracle.jdbc.OracleDriver - jdbc:oracle:thin:@localhost:1521/freepdb1 + jdbc:oracle:thin:@localhost:1521/xepdb1 benchbase password diff --git a/docker/oracle/docker-compose.yml b/docker/oracle/docker-compose.yml index 1ac47285e..720139242 100644 --- a/docker/oracle/docker-compose.yml +++ b/docker/oracle/docker-compose.yml @@ -4,15 +4,19 @@ version: '3.5' services: oracle: - image: container-registry.oracle.com/database/free:23.2.0.0 + image: gvenzl/oracle-xe:21.3.0-slim-faststart container_name: oracle ports: - "1521:1521" - "5500:5500" environment: - - ORACLE_PWD=password + - ORACLE_PASSWORD=password - ORACLE_CHARACTERSET=AL32UTF8 - volumes: - # This should be done at setup, but this image is already expanded for faster startup. The script only sets up - # a user so there is no issue rerunning the script multiple times - - "./setup:/opt/oracle/scripts/startup" \ No newline at end of file + - APP_USER=benchbase + - APP_USER_PASSWORD=password + healthcheck: + test: echo exit | sqlplus benchbase/password@xepdb1 | grep Connected + interval: 1s + timeout: 5s + retries: 30 + start_period: 5s \ No newline at end of file diff --git a/docker/oracle/setup/01_user.sql b/docker/oracle/reset.sql similarity index 63% rename from docker/oracle/setup/01_user.sql rename to docker/oracle/reset.sql index 14b18b046..3d4acf931 100644 --- a/docker/oracle/setup/01_user.sql +++ b/docker/oracle/reset.sql @@ -1,8 +1,8 @@ -- Copyright (c) 2023, Oracle and/or its affiliates. -- Non-DBA user specified in sample config file -alter session set container = FREEPDB1; -create user benchbase identified by password; -GRANT CONNECT, RESOURCE, UNLIMITED TABLESPACE TO benchbase; +DROP USER benchbase CASCADE; +CREATE USER benchbase IDENTIFIED BY password; +GRANT CONNECT, RESOURCE, CREATE VIEW, UNLIMITED TABLESPACE TO benchbase; -- Resourcestresser benchmark requires these two packages from SYS GRANT EXECUTE ON DBMS_CRYPTO TO benchbase; GRANT EXECUTE ON DBMS_LOCK TO benchbase; From 20419c93761d8c52f9745fb157e493a393af8eb6 Mon Sep 17 00:00:00 2001 From: Nguyen Nguyen Date: Tue, 7 Nov 2023 17:28:19 +1000 Subject: [PATCH 07/17] Update src/main/resources/benchmarks/sibench/ddl-oracle.sql Co-authored-by: Brian Kroth --- src/main/resources/benchmarks/sibench/ddl-oracle.sql | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/resources/benchmarks/sibench/ddl-oracle.sql b/src/main/resources/benchmarks/sibench/ddl-oracle.sql index cdaa7cdfb..0af3d7422 100644 --- a/src/main/resources/benchmarks/sibench/ddl-oracle.sql +++ b/src/main/resources/benchmarks/sibench/ddl-oracle.sql @@ -2,6 +2,6 @@ BEGIN EXECUTE IMMEDIATE 'DROP TABLE sitest'; EXCEPTION WHEN OTHERS THEN IF SQLCODE != -942 THEN RAISE; END IF; END;; CREATE TABLE sitest ( - id INT PRIMARY KEY, + id INT PRIMARY KEY, value INT NOT NULL ); \ No newline at end of file From 09f92a9ab56e413a04fdb128db95d71d0a57bb30 Mon Sep 17 00:00:00 2001 From: Nguyen Nguyen Date: Wed, 18 Oct 2023 17:10:14 +1000 Subject: [PATCH 08/17] Remove unnecessary file change --- .../benchmarks/auctionmark/AuctionMarkProfile.java | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/main/java/com/oltpbenchmark/benchmarks/auctionmark/AuctionMarkProfile.java b/src/main/java/com/oltpbenchmark/benchmarks/auctionmark/AuctionMarkProfile.java index 9c6f20197..fb3a38f00 100644 --- a/src/main/java/com/oltpbenchmark/benchmarks/auctionmark/AuctionMarkProfile.java +++ b/src/main/java/com/oltpbenchmark/benchmarks/auctionmark/AuctionMarkProfile.java @@ -15,7 +15,6 @@ * */ -/* Copyright (c) 2023, Oracle and/or its affiliates. */ package com.oltpbenchmark.benchmarks.auctionmark; @@ -287,7 +286,7 @@ private AuctionMarkProfile copyProfile(AuctionMarkWorker worker, AuctionMarkProf this.items_per_category = other.items_per_category; this.gag_ids = other.gag_ids; - // Initialize the UserIdGenerator so we can figure out whether our + // Initialize the UserIdGenerator so we can figure out whether our // client should even have these ids this.initializeUserIdGenerator(this.client_id); @@ -862,7 +861,7 @@ private ItemInfo getRandomItem(LinkedList itemSet, boolean needCurrent continue; } - // If they want an item that is ending in the future, then we compare it with + // If they want an item that is ending in the future, then we compare it with // the current timestamp if (needFutureEndDate) { boolean compareTo = (temp.getEndDate().compareTo(currentTime) < 0); From 700aba96e1dd0c6051fb893de15a23685bd68ead Mon Sep 17 00:00:00 2001 From: Nguyen Nguyen Date: Tue, 7 Nov 2023 15:44:53 +1000 Subject: [PATCH 09/17] Moved copyright to contributor file --- .github/workflows/maven.yml | 2 -- CONTRIBUTORS.md | 3 ++- config/oracle/sample_auctionmark_config.xml | 1 - config/oracle/sample_chbenchmark_config.xml | 1 - config/oracle/sample_epinions_config.xml | 1 - config/oracle/sample_hyadapt_config.xml | 1 - config/oracle/sample_noop_config.xml | 1 - config/oracle/sample_otmetrics_config.xml | 1 - config/oracle/sample_resourcestresser_config.xml | 1 - config/oracle/sample_seats_config.xml | 1 - config/oracle/sample_sibench_config.xml | 1 - config/oracle/sample_smallbank_config.xml | 1 - config/oracle/sample_tatp_config.xml | 1 - config/oracle/sample_templated_config.xml | 1 - config/oracle/sample_tpcc_config.xml | 1 - config/oracle/sample_tpch_config.xml | 1 - config/oracle/sample_twitter_config.xml | 1 - config/oracle/sample_voter_config.xml | 1 - config/oracle/sample_wikipedia_config.xml | 1 - config/oracle/sample_ycsb_config.xml | 1 - docker/oracle/docker-compose.yml | 2 -- docker/oracle/down.sh | 1 - docker/oracle/prune.sh | 1 - docker/oracle/reset.sql | 1 - docker/oracle/up.sh | 1 - pom.xml | 1 - src/main/java/com/oltpbenchmark/DBWorkload.java | 2 -- src/main/java/com/oltpbenchmark/api/BenchmarkModule.java | 2 -- src/main/java/com/oltpbenchmark/api/Procedure.java | 1 - .../benchmarks/auctionmark/AuctionMarkLoader.java | 1 - .../benchmarks/auctionmark/procedures/LoadConfig.java | 1 - .../benchmarks/otmetrics/procedures/GetSessionRange.java | 2 -- .../benchmarks/resourcestresser/procedures/CPU1.java | 2 -- .../benchmarks/resourcestresser/procedures/CPU2.java | 2 -- .../com/oltpbenchmark/benchmarks/voter/procedures/Vote.java | 2 -- .../oltpbenchmark/benchmarks/wikipedia/WikipediaLoader.java | 2 -- src/main/java/com/oltpbenchmark/util/SQLUtil.java | 2 -- src/main/resources/benchmarks/auctionmark/ddl-oracle.sql | 2 -- src/main/resources/benchmarks/auctionmark/dialect-oracle.xml | 1 - src/main/resources/benchmarks/chbenchmark/ddl-oracle.sql | 2 -- src/main/resources/benchmarks/chbenchmark/dialect-oracle.xml | 1 - .../benchmarks/chbenchmark/gather_schema_stats_oracle.sql | 1 - src/main/resources/benchmarks/epinions/ddl-oracle.sql | 2 -- src/main/resources/benchmarks/epinions/dialect-oracle.xml | 1 - src/main/resources/benchmarks/hyadapt/ddl-oracle.sql | 1 - src/main/resources/benchmarks/noop/ddl-oracle.sql | 1 - src/main/resources/benchmarks/noop/dialect-oracle.xml | 1 - src/main/resources/benchmarks/otmetrics/ddl-oracle.sql | 1 - src/main/resources/benchmarks/resourcestresser/ddl-oracle.sql | 1 - src/main/resources/benchmarks/seats/ddl-oracle.sql | 1 - src/main/resources/benchmarks/sibench/ddl-oracle.sql | 1 - src/main/resources/benchmarks/sibench/dialect-oracle.xml | 1 - src/main/resources/benchmarks/smallbank/ddl-oracle.sql | 1 - src/main/resources/benchmarks/tpch/ddl-oracle.sql | 1 - src/main/resources/benchmarks/tpch/dialect-oracle.xml | 1 - .../resources/benchmarks/tpch/gather_schema_stats_oracle.sql | 1 - src/main/resources/benchmarks/twitter/ddl-oracle.sql | 1 - src/main/resources/benchmarks/twitter/dialect-oracle.xml | 1 - src/main/resources/benchmarks/voter/ddl-oracle.sql | 1 - src/main/resources/benchmarks/voter/dialect-oracle.xml | 1 - src/main/resources/benchmarks/wikipedia/ddl-oracle.sql | 1 - src/main/resources/benchmarks/wikipedia/dialect-oracle.xml | 1 - 62 files changed, 2 insertions(+), 75 deletions(-) diff --git a/.github/workflows/maven.yml b/.github/workflows/maven.yml index 231cbcfd7..25eb489ed 100644 --- a/.github/workflows/maven.yml +++ b/.github/workflows/maven.yml @@ -10,8 +10,6 @@ # - One job to build/test the docker images. # - One job to publish the docker image. -# Copyright (c) 2023, Oracle and/or its affiliates. - name: BenchBase (Java with Maven) on: diff --git a/CONTRIBUTORS.md b/CONTRIBUTORS.md index 9a4cbeb43..f7b337852 100644 --- a/CONTRIBUTORS.md +++ b/CONTRIBUTORS.md @@ -19,4 +19,5 @@ We also acknowledge contributions from the following collaborators: + [Florian Funke](http://www3.in.tum.de/~funkef/) -+ [Michael Seibold](http://www3.in.tum.de/~seibold/) \ No newline at end of file ++ [Michael Seibold](http://www3.in.tum.de/~seibold/) ++ [Oracle](https://github.com/oracle) (Copyright (c) 2023, Oracle and/or its affiliates.) diff --git a/config/oracle/sample_auctionmark_config.xml b/config/oracle/sample_auctionmark_config.xml index e3b54acc1..f5c28c75a 100644 --- a/config/oracle/sample_auctionmark_config.xml +++ b/config/oracle/sample_auctionmark_config.xml @@ -1,5 +1,4 @@ - diff --git a/config/oracle/sample_chbenchmark_config.xml b/config/oracle/sample_chbenchmark_config.xml index 2989003c3..59f7843e8 100644 --- a/config/oracle/sample_chbenchmark_config.xml +++ b/config/oracle/sample_chbenchmark_config.xml @@ -1,5 +1,4 @@ - diff --git a/config/oracle/sample_epinions_config.xml b/config/oracle/sample_epinions_config.xml index 649432af7..f898b9ec7 100644 --- a/config/oracle/sample_epinions_config.xml +++ b/config/oracle/sample_epinions_config.xml @@ -1,5 +1,4 @@ - diff --git a/config/oracle/sample_hyadapt_config.xml b/config/oracle/sample_hyadapt_config.xml index a3ac12073..bc00ba982 100644 --- a/config/oracle/sample_hyadapt_config.xml +++ b/config/oracle/sample_hyadapt_config.xml @@ -1,5 +1,4 @@ - diff --git a/config/oracle/sample_noop_config.xml b/config/oracle/sample_noop_config.xml index 7d8b2f5d4..07e51d029 100644 --- a/config/oracle/sample_noop_config.xml +++ b/config/oracle/sample_noop_config.xml @@ -1,5 +1,4 @@ - diff --git a/config/oracle/sample_otmetrics_config.xml b/config/oracle/sample_otmetrics_config.xml index 0450050f1..ccf81ce93 100644 --- a/config/oracle/sample_otmetrics_config.xml +++ b/config/oracle/sample_otmetrics_config.xml @@ -1,5 +1,4 @@ - diff --git a/config/oracle/sample_resourcestresser_config.xml b/config/oracle/sample_resourcestresser_config.xml index 2a9bbe500..81dff7d61 100644 --- a/config/oracle/sample_resourcestresser_config.xml +++ b/config/oracle/sample_resourcestresser_config.xml @@ -1,5 +1,4 @@ - diff --git a/config/oracle/sample_seats_config.xml b/config/oracle/sample_seats_config.xml index 479abf19d..451e8a170 100644 --- a/config/oracle/sample_seats_config.xml +++ b/config/oracle/sample_seats_config.xml @@ -1,5 +1,4 @@ - diff --git a/config/oracle/sample_sibench_config.xml b/config/oracle/sample_sibench_config.xml index f4e521d25..0e17ed871 100644 --- a/config/oracle/sample_sibench_config.xml +++ b/config/oracle/sample_sibench_config.xml @@ -1,5 +1,4 @@ - diff --git a/config/oracle/sample_smallbank_config.xml b/config/oracle/sample_smallbank_config.xml index fdd0de7c5..58180c175 100644 --- a/config/oracle/sample_smallbank_config.xml +++ b/config/oracle/sample_smallbank_config.xml @@ -1,5 +1,4 @@ - diff --git a/config/oracle/sample_tatp_config.xml b/config/oracle/sample_tatp_config.xml index 651a10bd0..0f84d6731 100644 --- a/config/oracle/sample_tatp_config.xml +++ b/config/oracle/sample_tatp_config.xml @@ -1,5 +1,4 @@ - diff --git a/config/oracle/sample_templated_config.xml b/config/oracle/sample_templated_config.xml index 23f17ca60..043cb413f 100644 --- a/config/oracle/sample_templated_config.xml +++ b/config/oracle/sample_templated_config.xml @@ -1,5 +1,4 @@ - diff --git a/config/oracle/sample_tpcc_config.xml b/config/oracle/sample_tpcc_config.xml index a3089a0e9..4e991f6be 100644 --- a/config/oracle/sample_tpcc_config.xml +++ b/config/oracle/sample_tpcc_config.xml @@ -1,5 +1,4 @@ - diff --git a/config/oracle/sample_tpch_config.xml b/config/oracle/sample_tpch_config.xml index 92afc10f3..59f0014cb 100644 --- a/config/oracle/sample_tpch_config.xml +++ b/config/oracle/sample_tpch_config.xml @@ -1,5 +1,4 @@ - diff --git a/config/oracle/sample_twitter_config.xml b/config/oracle/sample_twitter_config.xml index 07e937114..a08996e02 100644 --- a/config/oracle/sample_twitter_config.xml +++ b/config/oracle/sample_twitter_config.xml @@ -1,5 +1,4 @@ - diff --git a/config/oracle/sample_voter_config.xml b/config/oracle/sample_voter_config.xml index 8775f08e9..8428adcca 100644 --- a/config/oracle/sample_voter_config.xml +++ b/config/oracle/sample_voter_config.xml @@ -1,5 +1,4 @@ - diff --git a/config/oracle/sample_wikipedia_config.xml b/config/oracle/sample_wikipedia_config.xml index 43f8dd996..3209b6775 100644 --- a/config/oracle/sample_wikipedia_config.xml +++ b/config/oracle/sample_wikipedia_config.xml @@ -1,5 +1,4 @@ - diff --git a/config/oracle/sample_ycsb_config.xml b/config/oracle/sample_ycsb_config.xml index 988438e70..06b1df9b6 100644 --- a/config/oracle/sample_ycsb_config.xml +++ b/config/oracle/sample_ycsb_config.xml @@ -1,5 +1,4 @@ - diff --git a/docker/oracle/docker-compose.yml b/docker/oracle/docker-compose.yml index 720139242..633657e0f 100644 --- a/docker/oracle/docker-compose.yml +++ b/docker/oracle/docker-compose.yml @@ -1,5 +1,3 @@ -# Copyright (c) 2023, Oracle and/or its affiliates. - version: '3.5' services: diff --git a/docker/oracle/down.sh b/docker/oracle/down.sh index 28a445caa..483906787 100755 --- a/docker/oracle/down.sh +++ b/docker/oracle/down.sh @@ -1,5 +1,4 @@ #!/bin/bash -# Copyright (c) 2023, Oracle and/or its affiliates. set -eu scriptdir=$(dirname "$(readlink -f "$0")") diff --git a/docker/oracle/prune.sh b/docker/oracle/prune.sh index 1276d2679..66b76933a 100755 --- a/docker/oracle/prune.sh +++ b/docker/oracle/prune.sh @@ -1,5 +1,4 @@ #!/bin/bash -# Copyright (c) 2023, Oracle and/or its affiliates. set -eu scriptdir=$(dirname "$(readlink -f "$0")") diff --git a/docker/oracle/reset.sql b/docker/oracle/reset.sql index 3d4acf931..08f15c426 100644 --- a/docker/oracle/reset.sql +++ b/docker/oracle/reset.sql @@ -1,4 +1,3 @@ --- Copyright (c) 2023, Oracle and/or its affiliates. -- Non-DBA user specified in sample config file DROP USER benchbase CASCADE; CREATE USER benchbase IDENTIFIED BY password; diff --git a/docker/oracle/up.sh b/docker/oracle/up.sh index f285b5d1f..8516e3b8d 100755 --- a/docker/oracle/up.sh +++ b/docker/oracle/up.sh @@ -1,5 +1,4 @@ #!/bin/bash -# Copyright (c) 2023, Oracle and/or its affiliates. set -eu scriptdir=$(dirname "$(readlink -f "$0")") diff --git a/pom.xml b/pom.xml index 7e4deb8ce..aefd84c1e 100644 --- a/pom.xml +++ b/pom.xml @@ -1,5 +1,4 @@ - 4.0.0 diff --git a/src/main/java/com/oltpbenchmark/DBWorkload.java b/src/main/java/com/oltpbenchmark/DBWorkload.java index f28ebbc96..a20fe04ce 100644 --- a/src/main/java/com/oltpbenchmark/DBWorkload.java +++ b/src/main/java/com/oltpbenchmark/DBWorkload.java @@ -15,8 +15,6 @@ * */ -/* Copyright (c) 2023, Oracle and/or its affiliates. */ - package com.oltpbenchmark; import com.oltpbenchmark.api.BenchmarkModule; diff --git a/src/main/java/com/oltpbenchmark/api/BenchmarkModule.java b/src/main/java/com/oltpbenchmark/api/BenchmarkModule.java index d834c28e5..a2788fefc 100644 --- a/src/main/java/com/oltpbenchmark/api/BenchmarkModule.java +++ b/src/main/java/com/oltpbenchmark/api/BenchmarkModule.java @@ -15,8 +15,6 @@ * */ -/* Copyright (c) 2023, Oracle and/or its affiliates. */ - package com.oltpbenchmark.api; import com.oltpbenchmark.WorkloadConfiguration; diff --git a/src/main/java/com/oltpbenchmark/api/Procedure.java b/src/main/java/com/oltpbenchmark/api/Procedure.java index 60c07f723..e98138435 100644 --- a/src/main/java/com/oltpbenchmark/api/Procedure.java +++ b/src/main/java/com/oltpbenchmark/api/Procedure.java @@ -15,7 +15,6 @@ * */ -/* Copyright (c) 2023, Oracle and/or its affiliates. */ package com.oltpbenchmark.api; import com.oltpbenchmark.jdbc.AutoIncrementPreparedStatement; diff --git a/src/main/java/com/oltpbenchmark/benchmarks/auctionmark/AuctionMarkLoader.java b/src/main/java/com/oltpbenchmark/benchmarks/auctionmark/AuctionMarkLoader.java index 1491b127f..4dec5fcbd 100644 --- a/src/main/java/com/oltpbenchmark/benchmarks/auctionmark/AuctionMarkLoader.java +++ b/src/main/java/com/oltpbenchmark/benchmarks/auctionmark/AuctionMarkLoader.java @@ -15,7 +15,6 @@ * */ -/* Copyright (c) 2023, Oracle and/or its affiliates. */ package com.oltpbenchmark.benchmarks.auctionmark; import com.oltpbenchmark.api.BenchmarkModule; diff --git a/src/main/java/com/oltpbenchmark/benchmarks/auctionmark/procedures/LoadConfig.java b/src/main/java/com/oltpbenchmark/benchmarks/auctionmark/procedures/LoadConfig.java index 3476c899e..89916b3cf 100644 --- a/src/main/java/com/oltpbenchmark/benchmarks/auctionmark/procedures/LoadConfig.java +++ b/src/main/java/com/oltpbenchmark/benchmarks/auctionmark/procedures/LoadConfig.java @@ -15,7 +15,6 @@ * */ -/* Copyright (c) 2023, Oracle and/or its affiliates. */ package com.oltpbenchmark.benchmarks.auctionmark.procedures; import com.oltpbenchmark.api.Procedure; diff --git a/src/main/java/com/oltpbenchmark/benchmarks/otmetrics/procedures/GetSessionRange.java b/src/main/java/com/oltpbenchmark/benchmarks/otmetrics/procedures/GetSessionRange.java index 832d2ae8f..310a8f6fa 100644 --- a/src/main/java/com/oltpbenchmark/benchmarks/otmetrics/procedures/GetSessionRange.java +++ b/src/main/java/com/oltpbenchmark/benchmarks/otmetrics/procedures/GetSessionRange.java @@ -15,8 +15,6 @@ * */ -/* Copyright (c) 2023, Oracle and/or its affiliates. */ - package com.oltpbenchmark.benchmarks.otmetrics.procedures; import com.oltpbenchmark.api.Procedure; diff --git a/src/main/java/com/oltpbenchmark/benchmarks/resourcestresser/procedures/CPU1.java b/src/main/java/com/oltpbenchmark/benchmarks/resourcestresser/procedures/CPU1.java index 63dc06e24..95fe70c49 100644 --- a/src/main/java/com/oltpbenchmark/benchmarks/resourcestresser/procedures/CPU1.java +++ b/src/main/java/com/oltpbenchmark/benchmarks/resourcestresser/procedures/CPU1.java @@ -15,8 +15,6 @@ * */ -/* Copyright (c) 2023, Oracle and/or its affiliates. */ - package com.oltpbenchmark.benchmarks.resourcestresser.procedures; import com.oltpbenchmark.api.Procedure; diff --git a/src/main/java/com/oltpbenchmark/benchmarks/resourcestresser/procedures/CPU2.java b/src/main/java/com/oltpbenchmark/benchmarks/resourcestresser/procedures/CPU2.java index 49b29541b..b6d515f12 100644 --- a/src/main/java/com/oltpbenchmark/benchmarks/resourcestresser/procedures/CPU2.java +++ b/src/main/java/com/oltpbenchmark/benchmarks/resourcestresser/procedures/CPU2.java @@ -15,8 +15,6 @@ * */ -/* Copyright (c) 2023, Oracle and/or its affiliates. */ - package com.oltpbenchmark.benchmarks.resourcestresser.procedures; import com.oltpbenchmark.api.Procedure; diff --git a/src/main/java/com/oltpbenchmark/benchmarks/voter/procedures/Vote.java b/src/main/java/com/oltpbenchmark/benchmarks/voter/procedures/Vote.java index 3c726a683..f1d057ca7 100644 --- a/src/main/java/com/oltpbenchmark/benchmarks/voter/procedures/Vote.java +++ b/src/main/java/com/oltpbenchmark/benchmarks/voter/procedures/Vote.java @@ -44,8 +44,6 @@ // number of allowed votes. // -/* Copyright (c) 2023, Oracle and/or its affiliates. */ - package com.oltpbenchmark.benchmarks.voter.procedures; import com.oltpbenchmark.api.Procedure; diff --git a/src/main/java/com/oltpbenchmark/benchmarks/wikipedia/WikipediaLoader.java b/src/main/java/com/oltpbenchmark/benchmarks/wikipedia/WikipediaLoader.java index bd4662ffd..fe2ead717 100644 --- a/src/main/java/com/oltpbenchmark/benchmarks/wikipedia/WikipediaLoader.java +++ b/src/main/java/com/oltpbenchmark/benchmarks/wikipedia/WikipediaLoader.java @@ -15,8 +15,6 @@ * */ -/* Copyright (c) 2023, Oracle and/or its affiliates. */ - package com.oltpbenchmark.benchmarks.wikipedia; import com.oltpbenchmark.api.Loader; diff --git a/src/main/java/com/oltpbenchmark/util/SQLUtil.java b/src/main/java/com/oltpbenchmark/util/SQLUtil.java index e984dd4d4..8a24dae59 100644 --- a/src/main/java/com/oltpbenchmark/util/SQLUtil.java +++ b/src/main/java/com/oltpbenchmark/util/SQLUtil.java @@ -15,8 +15,6 @@ * */ -/* Copyright (c) 2023, Oracle and/or its affiliates. */ - package com.oltpbenchmark.util; import com.oltpbenchmark.api.BenchmarkModule; diff --git a/src/main/resources/benchmarks/auctionmark/ddl-oracle.sql b/src/main/resources/benchmarks/auctionmark/ddl-oracle.sql index 4e1f932d9..56092d220 100644 --- a/src/main/resources/benchmarks/auctionmark/ddl-oracle.sql +++ b/src/main/resources/benchmarks/auctionmark/ddl-oracle.sql @@ -1,5 +1,3 @@ --- Copyright (c) 2023, Oracle and/or its affiliates. - BEGIN EXECUTE IMMEDIATE 'DROP TABLE CONFIG_PROFILE'; EXCEPTION WHEN OTHERS THEN IF SQLCODE != -942 THEN RAISE; END IF; END;; BEGIN EXECUTE IMMEDIATE 'DROP TABLE REGION CASCADE CONSTRAINTS'; EXCEPTION WHEN OTHERS THEN IF SQLCODE != -942 THEN RAISE; END IF; END;; BEGIN EXECUTE IMMEDIATE 'DROP TABLE USERACCT CASCADE CONSTRAINTS'; EXCEPTION WHEN OTHERS THEN IF SQLCODE != -942 THEN RAISE; END IF; END;; diff --git a/src/main/resources/benchmarks/auctionmark/dialect-oracle.xml b/src/main/resources/benchmarks/auctionmark/dialect-oracle.xml index f3ce35eec..9423d8fc9 100644 --- a/src/main/resources/benchmarks/auctionmark/dialect-oracle.xml +++ b/src/main/resources/benchmarks/auctionmark/dialect-oracle.xml @@ -1,5 +1,4 @@ - diff --git a/src/main/resources/benchmarks/chbenchmark/ddl-oracle.sql b/src/main/resources/benchmarks/chbenchmark/ddl-oracle.sql index 2dc94be55..7cb323154 100644 --- a/src/main/resources/benchmarks/chbenchmark/ddl-oracle.sql +++ b/src/main/resources/benchmarks/chbenchmark/ddl-oracle.sql @@ -1,5 +1,3 @@ --- Copyright (c) 2023, Oracle and/or its affiliates. - BEGIN EXECUTE IMMEDIATE 'DROP TABLE supplier CASCADE CONSTRAINTS'; EXCEPTION WHEN OTHERS THEN IF SQLCODE != -942 THEN RAISE; END IF; END;; BEGIN EXECUTE IMMEDIATE 'DROP TABLE nation CASCADE CONSTRAINTS'; EXCEPTION WHEN OTHERS THEN IF SQLCODE != -942 THEN RAISE; END IF; END;; BEGIN EXECUTE IMMEDIATE 'DROP TABLE region CASCADE CONSTRAINTS'; EXCEPTION WHEN OTHERS THEN IF SQLCODE != -942 THEN RAISE; END IF; END;; diff --git a/src/main/resources/benchmarks/chbenchmark/dialect-oracle.xml b/src/main/resources/benchmarks/chbenchmark/dialect-oracle.xml index 3515dd771..9d4559fd2 100644 --- a/src/main/resources/benchmarks/chbenchmark/dialect-oracle.xml +++ b/src/main/resources/benchmarks/chbenchmark/dialect-oracle.xml @@ -1,5 +1,4 @@ - diff --git a/src/main/resources/benchmarks/chbenchmark/gather_schema_stats_oracle.sql b/src/main/resources/benchmarks/chbenchmark/gather_schema_stats_oracle.sql index eb4a10862..692f10cdc 100644 --- a/src/main/resources/benchmarks/chbenchmark/gather_schema_stats_oracle.sql +++ b/src/main/resources/benchmarks/chbenchmark/gather_schema_stats_oracle.sql @@ -1,2 +1 @@ --- Copyright (c) 2023, Oracle and/or its affiliates. BEGIN dbms_stats.gather_schema_stats(ownname => 'benchbase', estimate_percent => dbms_stats.auto_sample_size, method_opt => 'for all columns size AUTO'); END;; \ No newline at end of file diff --git a/src/main/resources/benchmarks/epinions/ddl-oracle.sql b/src/main/resources/benchmarks/epinions/ddl-oracle.sql index c589369cd..5e3db2b96 100644 --- a/src/main/resources/benchmarks/epinions/ddl-oracle.sql +++ b/src/main/resources/benchmarks/epinions/ddl-oracle.sql @@ -1,5 +1,3 @@ --- Copyright (c) 2023, Oracle and/or its affiliates. - -- Epinions DDL for Oracle DDL -- Drop all tables diff --git a/src/main/resources/benchmarks/epinions/dialect-oracle.xml b/src/main/resources/benchmarks/epinions/dialect-oracle.xml index 2bbd8c459..6f32b3b82 100644 --- a/src/main/resources/benchmarks/epinions/dialect-oracle.xml +++ b/src/main/resources/benchmarks/epinions/dialect-oracle.xml @@ -1,5 +1,4 @@ - diff --git a/src/main/resources/benchmarks/hyadapt/ddl-oracle.sql b/src/main/resources/benchmarks/hyadapt/ddl-oracle.sql index b470c97d3..3e49ee17b 100644 --- a/src/main/resources/benchmarks/hyadapt/ddl-oracle.sql +++ b/src/main/resources/benchmarks/hyadapt/ddl-oracle.sql @@ -1,4 +1,3 @@ --- Copyright (c) 2023, Oracle and/or its affiliates. BEGIN EXECUTE IMMEDIATE 'DROP TABLE htable'; EXCEPTION WHEN OTHERS THEN IF SQLCODE != -942 THEN RAISE; END IF; END;; CREATE TABLE htable ( diff --git a/src/main/resources/benchmarks/noop/ddl-oracle.sql b/src/main/resources/benchmarks/noop/ddl-oracle.sql index 19c4ccd88..e3065812d 100644 --- a/src/main/resources/benchmarks/noop/ddl-oracle.sql +++ b/src/main/resources/benchmarks/noop/ddl-oracle.sql @@ -1,4 +1,3 @@ --- Copyright (c) 2023, Oracle and/or its affiliates. BEGIN EXECUTE IMMEDIATE 'DROP TABLE fake'; EXCEPTION WHEN OTHERS THEN IF SQLCODE != -942 THEN RAISE; END IF; END;; CREATE TABLE fake ( diff --git a/src/main/resources/benchmarks/noop/dialect-oracle.xml b/src/main/resources/benchmarks/noop/dialect-oracle.xml index 07064d5cf..7a0a33e52 100644 --- a/src/main/resources/benchmarks/noop/dialect-oracle.xml +++ b/src/main/resources/benchmarks/noop/dialect-oracle.xml @@ -1,5 +1,4 @@ - diff --git a/src/main/resources/benchmarks/otmetrics/ddl-oracle.sql b/src/main/resources/benchmarks/otmetrics/ddl-oracle.sql index c1b004056..910238521 100644 --- a/src/main/resources/benchmarks/otmetrics/ddl-oracle.sql +++ b/src/main/resources/benchmarks/otmetrics/ddl-oracle.sql @@ -1,4 +1,3 @@ --- Copyright (c) 2023, Oracle and/or its affiliates. BEGIN EXECUTE IMMEDIATE 'DROP TABLE observations CASCADE CONSTRAINTS'; EXCEPTION WHEN OTHERS THEN IF SQLCODE != -942 THEN RAISE; END IF; END;; BEGIN EXECUTE IMMEDIATE 'DROP TABLE types CASCADE CONSTRAINTS'; EXCEPTION WHEN OTHERS THEN IF SQLCODE != -942 THEN RAISE; END IF; END;; BEGIN EXECUTE IMMEDIATE 'DROP TABLE sessions CASCADE CONSTRAINTS'; EXCEPTION WHEN OTHERS THEN IF SQLCODE != -942 THEN RAISE; END IF; END;; diff --git a/src/main/resources/benchmarks/resourcestresser/ddl-oracle.sql b/src/main/resources/benchmarks/resourcestresser/ddl-oracle.sql index 1ec3ba72e..d72a84536 100644 --- a/src/main/resources/benchmarks/resourcestresser/ddl-oracle.sql +++ b/src/main/resources/benchmarks/resourcestresser/ddl-oracle.sql @@ -1,4 +1,3 @@ --- Copyright (c) 2023, Oracle and/or its affiliates. -- Drop all tables BEGIN EXECUTE IMMEDIATE 'DROP TABLE cputable'; EXCEPTION WHEN OTHERS THEN IF SQLCODE != -942 THEN RAISE; END IF; END;; diff --git a/src/main/resources/benchmarks/seats/ddl-oracle.sql b/src/main/resources/benchmarks/seats/ddl-oracle.sql index 2ea643cf1..7bd420092 100644 --- a/src/main/resources/benchmarks/seats/ddl-oracle.sql +++ b/src/main/resources/benchmarks/seats/ddl-oracle.sql @@ -1,4 +1,3 @@ --- Copyright (c) 2023, Oracle and/or its affiliates. -- DROP TABLE BEGIN EXECUTE IMMEDIATE 'DROP TABLE CONFIG_PROFILE CASCADE CONSTRAINTS'; EXCEPTION WHEN OTHERS THEN IF SQLCODE != -942 THEN RAISE; END IF; END;; diff --git a/src/main/resources/benchmarks/sibench/ddl-oracle.sql b/src/main/resources/benchmarks/sibench/ddl-oracle.sql index 0af3d7422..d3a7c75d8 100644 --- a/src/main/resources/benchmarks/sibench/ddl-oracle.sql +++ b/src/main/resources/benchmarks/sibench/ddl-oracle.sql @@ -1,4 +1,3 @@ --- Copyright (c) 2023, Oracle and/or its affiliates. BEGIN EXECUTE IMMEDIATE 'DROP TABLE sitest'; EXCEPTION WHEN OTHERS THEN IF SQLCODE != -942 THEN RAISE; END IF; END;; CREATE TABLE sitest ( diff --git a/src/main/resources/benchmarks/sibench/dialect-oracle.xml b/src/main/resources/benchmarks/sibench/dialect-oracle.xml index 209efa087..ce4a98e7d 100644 --- a/src/main/resources/benchmarks/sibench/dialect-oracle.xml +++ b/src/main/resources/benchmarks/sibench/dialect-oracle.xml @@ -1,5 +1,4 @@ - diff --git a/src/main/resources/benchmarks/smallbank/ddl-oracle.sql b/src/main/resources/benchmarks/smallbank/ddl-oracle.sql index d2c0a29dc..a70d5b4cc 100644 --- a/src/main/resources/benchmarks/smallbank/ddl-oracle.sql +++ b/src/main/resources/benchmarks/smallbank/ddl-oracle.sql @@ -1,4 +1,3 @@ --- Copyright (c) 2023, Oracle and/or its affiliates. BEGIN EXECUTE IMMEDIATE 'DROP TABLE checking CASCADE CONSTRAINTS'; EXCEPTION WHEN OTHERS THEN IF SQLCODE != -942 THEN RAISE; END IF; END;; BEGIN EXECUTE IMMEDIATE 'DROP TABLE savings CASCADE CONSTRAINTS'; EXCEPTION WHEN OTHERS THEN IF SQLCODE != -942 THEN RAISE; END IF; END;; BEGIN EXECUTE IMMEDIATE 'DROP TABLE accounts CASCADE CONSTRAINTS'; EXCEPTION WHEN OTHERS THEN IF SQLCODE != -942 THEN RAISE; END IF; END;; diff --git a/src/main/resources/benchmarks/tpch/ddl-oracle.sql b/src/main/resources/benchmarks/tpch/ddl-oracle.sql index f32607292..7a7be7da2 100644 --- a/src/main/resources/benchmarks/tpch/ddl-oracle.sql +++ b/src/main/resources/benchmarks/tpch/ddl-oracle.sql @@ -1,4 +1,3 @@ --- Copyright (c) 2023, Oracle and/or its affiliates. BEGIN EXECUTE IMMEDIATE 'DROP TABLE nation CASCADE CONSTRAINTS'; EXCEPTION WHEN OTHERS THEN IF SQLCODE != -942 THEN RAISE; END IF; END;; BEGIN EXECUTE IMMEDIATE 'DROP TABLE region CASCADE CONSTRAINTS'; EXCEPTION WHEN OTHERS THEN IF SQLCODE != -942 THEN RAISE; END IF; END;; BEGIN EXECUTE IMMEDIATE 'DROP TABLE part CASCADE CONSTRAINTS'; EXCEPTION WHEN OTHERS THEN IF SQLCODE != -942 THEN RAISE; END IF; END;; diff --git a/src/main/resources/benchmarks/tpch/dialect-oracle.xml b/src/main/resources/benchmarks/tpch/dialect-oracle.xml index bdd14ab58..00d401c52 100644 --- a/src/main/resources/benchmarks/tpch/dialect-oracle.xml +++ b/src/main/resources/benchmarks/tpch/dialect-oracle.xml @@ -1,5 +1,4 @@ - diff --git a/src/main/resources/benchmarks/tpch/gather_schema_stats_oracle.sql b/src/main/resources/benchmarks/tpch/gather_schema_stats_oracle.sql index eb4a10862..692f10cdc 100644 --- a/src/main/resources/benchmarks/tpch/gather_schema_stats_oracle.sql +++ b/src/main/resources/benchmarks/tpch/gather_schema_stats_oracle.sql @@ -1,2 +1 @@ --- Copyright (c) 2023, Oracle and/or its affiliates. BEGIN dbms_stats.gather_schema_stats(ownname => 'benchbase', estimate_percent => dbms_stats.auto_sample_size, method_opt => 'for all columns size AUTO'); END;; \ No newline at end of file diff --git a/src/main/resources/benchmarks/twitter/ddl-oracle.sql b/src/main/resources/benchmarks/twitter/ddl-oracle.sql index 9e8ef2553..63e687a93 100644 --- a/src/main/resources/benchmarks/twitter/ddl-oracle.sql +++ b/src/main/resources/benchmarks/twitter/ddl-oracle.sql @@ -1,4 +1,3 @@ --- Copyright (c) 2023, Oracle and/or its affiliates. BEGIN EXECUTE IMMEDIATE 'DROP TABLE added_tweets CASCADE CONSTRAINTS'; EXCEPTION WHEN OTHERS THEN IF SQLCODE != -942 THEN RAISE; END IF; END;; BEGIN EXECUTE IMMEDIATE 'DROP TABLE tweets CASCADE CONSTRAINTS'; EXCEPTION WHEN OTHERS THEN IF SQLCODE != -942 THEN RAISE; END IF; END;; BEGIN EXECUTE IMMEDIATE 'DROP TABLE user_profiles CASCADE CONSTRAINTS'; EXCEPTION WHEN OTHERS THEN IF SQLCODE != -942 THEN RAISE; END IF; END;; diff --git a/src/main/resources/benchmarks/twitter/dialect-oracle.xml b/src/main/resources/benchmarks/twitter/dialect-oracle.xml index b96ded2e6..1b61888cb 100644 --- a/src/main/resources/benchmarks/twitter/dialect-oracle.xml +++ b/src/main/resources/benchmarks/twitter/dialect-oracle.xml @@ -1,5 +1,4 @@ - diff --git a/src/main/resources/benchmarks/voter/ddl-oracle.sql b/src/main/resources/benchmarks/voter/ddl-oracle.sql index c8b03c960..bce127331 100644 --- a/src/main/resources/benchmarks/voter/ddl-oracle.sql +++ b/src/main/resources/benchmarks/voter/ddl-oracle.sql @@ -1,4 +1,3 @@ --- Copyright (c) 2023, Oracle and/or its affiliates. BEGIN EXECUTE IMMEDIATE 'DROP VIEW v_votes_by_phone_number CASCADE CONSTRAINTS'; EXCEPTION WHEN OTHERS THEN IF SQLCODE != -942 THEN RAISE; END IF; END;; BEGIN EXECUTE IMMEDIATE 'DROP VIEW v_votes_by_contestant_number_state CASCADE CONSTRAINTS'; EXCEPTION WHEN OTHERS THEN IF SQLCODE != -942 THEN RAISE; END IF; END;; BEGIN EXECUTE IMMEDIATE 'DROP TABLE votes CASCADE CONSTRAINTS'; EXCEPTION WHEN OTHERS THEN IF SQLCODE != -942 THEN RAISE; END IF; END;; diff --git a/src/main/resources/benchmarks/voter/dialect-oracle.xml b/src/main/resources/benchmarks/voter/dialect-oracle.xml index 5def61e5f..04eeaa9f3 100644 --- a/src/main/resources/benchmarks/voter/dialect-oracle.xml +++ b/src/main/resources/benchmarks/voter/dialect-oracle.xml @@ -1,5 +1,4 @@ - diff --git a/src/main/resources/benchmarks/wikipedia/ddl-oracle.sql b/src/main/resources/benchmarks/wikipedia/ddl-oracle.sql index 172c01bb6..3f9fd5910 100644 --- a/src/main/resources/benchmarks/wikipedia/ddl-oracle.sql +++ b/src/main/resources/benchmarks/wikipedia/ddl-oracle.sql @@ -1,4 +1,3 @@ --- Copyright (c) 2023, Oracle and/or its affiliates. -- ORACLE Wikipedia ALTER SESSION SET NLS_LENGTH_SEMANTICS=CHAR; diff --git a/src/main/resources/benchmarks/wikipedia/dialect-oracle.xml b/src/main/resources/benchmarks/wikipedia/dialect-oracle.xml index 2203ac36f..721247c9d 100644 --- a/src/main/resources/benchmarks/wikipedia/dialect-oracle.xml +++ b/src/main/resources/benchmarks/wikipedia/dialect-oracle.xml @@ -1,5 +1,4 @@ - From 07b2cb264783e0d03c6a8be610c31738e7cd287a Mon Sep 17 00:00:00 2001 From: Nguyen Nguyen Date: Tue, 7 Nov 2023 17:45:02 +1000 Subject: [PATCH 10/17] Address comments --- .github/workflows/maven.yml | 2 +- config/oracle/sample_chbenchmark_config.xml | 4 +-- config/oracle/sample_tpch_config.xml | 4 +-- docker/oracle/down.sh | 2 +- docker/oracle/up.sh | 2 +- .../java/com/oltpbenchmark/api/Procedure.java | 6 +++- .../auctionmark/AuctionMarkLoader.java | 3 +- .../auctionmark/procedures/LoadConfig.java | 9 +++-- .../seats/procedures/LoadConfig.java | 18 +++++++--- .../java/com/oltpbenchmark/util/SQLUtil.java | 13 +++++++ .../gather_schema_stats_oracle.sql | 2 ++ .../otmetrics/ddl-oracle-trimmed.sql | 34 ------------------- .../tpch/gather_schema_stats_oracle.sql | 1 - 13 files changed, 50 insertions(+), 50 deletions(-) rename src/main/resources/benchmarks/{chbenchmark => }/gather_schema_stats_oracle.sql (50%) delete mode 100644 src/main/resources/benchmarks/otmetrics/ddl-oracle-trimmed.sql delete mode 100644 src/main/resources/benchmarks/tpch/gather_schema_stats_oracle.sql diff --git a/.github/workflows/maven.yml b/.github/workflows/maven.yml index 25eb489ed..e1c245beb 100644 --- a/.github/workflows/maven.yml +++ b/.github/workflows/maven.yml @@ -58,7 +58,7 @@ jobs: runs-on: ubuntu-latest strategy: matrix: - profile: [ 'cockroachdb', 'mariadb', 'mysql', 'postgres', 'spanner', 'phoenix', 'sqlserver', 'sqlite' , 'oracle' ] + profile: [ 'cockroachdb', 'mariadb', 'mysql', 'oracle', 'phoenix', 'postgres', 'spanner', 'sqlite', 'sqlserver' ] steps: - name: Checkout repo uses: actions/checkout@v4 diff --git a/config/oracle/sample_chbenchmark_config.xml b/config/oracle/sample_chbenchmark_config.xml index 59f7843e8..a9faa9615 100644 --- a/config/oracle/sample_chbenchmark_config.xml +++ b/config/oracle/sample_chbenchmark_config.xml @@ -18,8 +18,8 @@ 1 - - /benchmarks/chbenchmark/gather_schema_stats_oracle.sql + + /benchmarks/gather_schema_stats_oracle.sql diff --git a/config/oracle/sample_tpch_config.xml b/config/oracle/sample_tpch_config.xml index 59f0014cb..4ab444e5a 100644 --- a/config/oracle/sample_tpch_config.xml +++ b/config/oracle/sample_tpch_config.xml @@ -14,8 +14,8 @@ 0.1 - - /benchmarks/tpch/gather_schema_stats_oracle.sql + + /benchmarks/gather_schema_stats_oracle.sql 1 diff --git a/docker/oracle/down.sh b/docker/oracle/down.sh index 483906787..c8f703de5 100755 --- a/docker/oracle/down.sh +++ b/docker/oracle/down.sh @@ -4,4 +4,4 @@ set -eu scriptdir=$(dirname "$(readlink -f "$0")") cd "$scriptdir/" -docker-compose down --remove-orphans --volumes +docker compose down --remove-orphans --volumes diff --git a/docker/oracle/up.sh b/docker/oracle/up.sh index 8516e3b8d..d05249baf 100755 --- a/docker/oracle/up.sh +++ b/docker/oracle/up.sh @@ -4,4 +4,4 @@ set -eu scriptdir=$(dirname "$(readlink -f "$0")") cd "$scriptdir/" -docker-compose up -d +docker compose up -d diff --git a/src/main/java/com/oltpbenchmark/api/Procedure.java b/src/main/java/com/oltpbenchmark/api/Procedure.java index e98138435..dd23c8cb9 100644 --- a/src/main/java/com/oltpbenchmark/api/Procedure.java +++ b/src/main/java/com/oltpbenchmark/api/Procedure.java @@ -36,6 +36,7 @@ public abstract class Procedure { private static final Logger LOG = LoggerFactory.getLogger(Procedure.class); private final String procName; + private DatabaseType dbType; /** * LoadConfig procedure in auctionmark and seats benchmark contains CLOB on Oracle config * @@ -44,7 +45,10 @@ public abstract class Procedure { * protected allows LoadConfig procedure to determine current database type, and decide if it should perform * the conversion. */ - protected DatabaseType dbType; + public DatabaseType getDbType() { + return dbType; + } + private Map name_stmt_xref; /** diff --git a/src/main/java/com/oltpbenchmark/benchmarks/auctionmark/AuctionMarkLoader.java b/src/main/java/com/oltpbenchmark/benchmarks/auctionmark/AuctionMarkLoader.java index 4dec5fcbd..64d0a8c73 100644 --- a/src/main/java/com/oltpbenchmark/benchmarks/auctionmark/AuctionMarkLoader.java +++ b/src/main/java/com/oltpbenchmark/benchmarks/auctionmark/AuctionMarkLoader.java @@ -442,7 +442,8 @@ protected int populateRandomColumns(Object[] row) { for (Column catalog_col : this.random_str_cols) { int size = catalog_col.getSize(); // This can generate an empty string which is treated as NULL in Oracle DB - row[catalog_col.getIndex()] = profile.rng.astring(profile.rng.nextInt(getDatabaseType() == ORACLE ? 1 : 0, size - 1), size); + int start = getDatabaseType() == ORACLE ? 1 : 0; + row[catalog_col.getIndex()] = profile.rng.astring(profile.rng.nextInt(start, size - 1), size); cols++; } diff --git a/src/main/java/com/oltpbenchmark/benchmarks/auctionmark/procedures/LoadConfig.java b/src/main/java/com/oltpbenchmark/benchmarks/auctionmark/procedures/LoadConfig.java index 89916b3cf..8e724f0f5 100644 --- a/src/main/java/com/oltpbenchmark/benchmarks/auctionmark/procedures/LoadConfig.java +++ b/src/main/java/com/oltpbenchmark/benchmarks/auctionmark/procedures/LoadConfig.java @@ -84,8 +84,13 @@ public Config run(Connection conn) throws SQLException { try (PreparedStatement preparedStatement = this.getPreparedStatement(conn, getConfigProfile)) { try (ResultSet resultSet = preparedStatement.executeQuery()) { configProfile = SQLUtil.toList(resultSet); - // CLOB needs to be done while connection is alive - if (dbType == DatabaseType.ORACLE) { + // Oracle DB DDL contains some CLOB fields (for LoadConfig procedures). + // These CLOB needs to be converted to String while the connection is alive. + + // This CLOB conversion for Oracle needs to be done here, otherwise the conversion will be attempted + // by SQLUtil.getString(Object) after the connection closes, which will result in + // java.sql.SQLRecoverableException: Closed Connection. + if (getDbType() == DatabaseType.ORACLE) { for (Object[] configProfileInstance: configProfile) { configProfileInstance[3] = SQLUtil.clobToString(configProfileInstance[3]); } diff --git a/src/main/java/com/oltpbenchmark/benchmarks/seats/procedures/LoadConfig.java b/src/main/java/com/oltpbenchmark/benchmarks/seats/procedures/LoadConfig.java index fb995aab7..309285716 100644 --- a/src/main/java/com/oltpbenchmark/benchmarks/seats/procedures/LoadConfig.java +++ b/src/main/java/com/oltpbenchmark/benchmarks/seats/procedures/LoadConfig.java @@ -68,8 +68,13 @@ public Config run(Connection conn) throws SQLException { try (PreparedStatement preparedStatement = this.getPreparedStatement(conn, getConfigProfile)) { try (ResultSet resultSet = preparedStatement.executeQuery()) { configProfile = SQLUtil.toList(resultSet); - // CLOB needs to be done while connection is alive - if (dbType == DatabaseType.ORACLE) { + // Oracle DB DDL contains some CLOB fields (for LoadConfig procedures). + // These CLOB needs to be converted to String while the connection is alive. + + // This CLOB conversion for Oracle needs to be done here, otherwise the conversion will be attempted + // by SQLUtil.getString(Object) after the connection closes, which will result in + // java.sql.SQLRecoverableException: Closed Connection. + if (getDbType() == DatabaseType.ORACLE) { for (Object[] configProfileInstance: configProfile) { configProfileInstance[1] = SQLUtil.clobToString(configProfileInstance[1]); } @@ -81,8 +86,13 @@ public Config run(Connection conn) throws SQLException { try (PreparedStatement preparedStatement = this.getPreparedStatement(conn, getConfigHistogram)) { try (ResultSet resultSet = preparedStatement.executeQuery()) { histogram = SQLUtil.toList(resultSet); - // CLOB needs to be done while connection is alive - if (dbType == DatabaseType.ORACLE) { + // Oracle DB DDL contains some CLOB fields (for LoadConfig procedures). + // These CLOB needs to be converted to String while the connection is alive. + + // This CLOB conversion for Oracle needs to be done here, otherwise the conversion will be attempted + // by SQLUtil.getString(Object) after the connection closes, which will result in + // java.sql.SQLRecoverableException: Closed Connection. + if (getDbType() == DatabaseType.ORACLE) { for (Object[] histogramInstance: histogram) { histogramInstance[1] = SQLUtil.clobToString(histogramInstance[1]); } diff --git a/src/main/java/com/oltpbenchmark/util/SQLUtil.java b/src/main/java/com/oltpbenchmark/util/SQLUtil.java index 8a24dae59..7168071e0 100644 --- a/src/main/java/com/oltpbenchmark/util/SQLUtil.java +++ b/src/main/java/com/oltpbenchmark/util/SQLUtil.java @@ -136,18 +136,30 @@ public static String getString(Object obj) { return (null); } + /** + * Support for Oracle DB introduced TIMESTAMP fields in Oracle DDL (for example, auctionmark CONFIG_PROFILE table), + * which results in OJDBC-specific {@code oracle.sql.TIMESTAMP} object. + * {@link #getTimestamp(Object)} needs to be able to convert {@code oracle.sql.TIMESTAMP} into {@code java.sql.TIMESTAMP}. + * + * The main issue is that {@code oracle.sql.TIMESTAMP} is not available in JDBC, so trying to import and resolve the + * type normally will break other database profiles. + * This can be solved by loading OJDBC-specific class + method reflectively. + */ private static final Class ORACLE_TIMESTAMP; private static final Method TIMESTAMP_VALUE_METHOD; static { Method timestampValueMethod; Class oracleTimestamp; try { + // If oracle.sql.TIMESTAMP can be loaded oracleTimestamp = Class.forName("oracle.sql.TIMESTAMP"); + // Then java.sql.Timestamp oracle.sql.TIMESTAMP.timestampValue() can be loaded timestampValueMethod = oracleTimestamp.getDeclaredMethod("timestampValue"); } catch (ClassNotFoundException | NoSuchMethodException e) { oracleTimestamp = null; timestampValueMethod = null; } + // If loading is successful then both variables won't be null. TIMESTAMP_VALUE_METHOD = timestampValueMethod; ORACLE_TIMESTAMP = oracleTimestamp; } @@ -169,6 +181,7 @@ public static Timestamp getTimestamp(Object obj) { return new Timestamp(((Date) obj).getTime()); } else if (ORACLE_TIMESTAMP != null && ORACLE_TIMESTAMP.isInstance(obj)) { try { + // https://docs.oracle.com/en/database/oracle/oracle-database/21/jajdb/oracle/sql/TIMESTAMP.html#timestampValue__ return (Timestamp) TIMESTAMP_VALUE_METHOD.invoke(ORACLE_TIMESTAMP.cast(obj)); } catch (IllegalAccessException | InvocationTargetException e) { throw new RuntimeException(e); diff --git a/src/main/resources/benchmarks/chbenchmark/gather_schema_stats_oracle.sql b/src/main/resources/benchmarks/gather_schema_stats_oracle.sql similarity index 50% rename from src/main/resources/benchmarks/chbenchmark/gather_schema_stats_oracle.sql rename to src/main/resources/benchmarks/gather_schema_stats_oracle.sql index 692f10cdc..0196f2cf6 100644 --- a/src/main/resources/benchmarks/chbenchmark/gather_schema_stats_oracle.sql +++ b/src/main/resources/benchmarks/gather_schema_stats_oracle.sql @@ -1 +1,3 @@ +-- Gather optimizer statistics to improve performance +-- Sample config for tpch/chbenchmark should already include afterload option to execute this query BEGIN dbms_stats.gather_schema_stats(ownname => 'benchbase', estimate_percent => dbms_stats.auto_sample_size, method_opt => 'for all columns size AUTO'); END;; \ No newline at end of file diff --git a/src/main/resources/benchmarks/otmetrics/ddl-oracle-trimmed.sql b/src/main/resources/benchmarks/otmetrics/ddl-oracle-trimmed.sql deleted file mode 100644 index 15a182ad9..000000000 --- a/src/main/resources/benchmarks/otmetrics/ddl-oracle-trimmed.sql +++ /dev/null @@ -1,34 +0,0 @@ -CREATE TABLE sources ( - id INT NOT NULL, - name VARCHAR(128) NOT NULL UNIQUE, - comments VARCHAR(256) DEFAULT NULL, - created_time TIMESTAMP NOT NULL, - PRIMARY KEY (id) -); - -CREATE TABLE types ( - id INT NOT NULL, - category INT NOT NULL, - value_type INT NOT NULL, - name VARCHAR(64) NOT NULL, - comments VARCHAR(256) DEFAULT NULL, - PRIMARY KEY (id), - UNIQUE (category, name) -); - -CREATE TABLE sessions ( - id INT NOT NULL, - source_id INT NOT NULL REFERENCES sources (id), - agent VARCHAR(32) NOT NULL, - created_time TIMESTAMP NOT NULL, - PRIMARY KEY (id) -); - -CREATE TABLE observations ( - source_id INT NOT NULL REFERENCES sources (id), - session_id INT NOT NULL REFERENCES sessions (id), - type_id INT NOT NULL REFERENCES types (id), - value NUMBER(38) NOT NULL, - created_time TIMESTAMP NOT NULL -); -CREATE INDEX idx_observations_source_session ON observations (source_id, session_id, type_id); \ No newline at end of file diff --git a/src/main/resources/benchmarks/tpch/gather_schema_stats_oracle.sql b/src/main/resources/benchmarks/tpch/gather_schema_stats_oracle.sql deleted file mode 100644 index 692f10cdc..000000000 --- a/src/main/resources/benchmarks/tpch/gather_schema_stats_oracle.sql +++ /dev/null @@ -1 +0,0 @@ -BEGIN dbms_stats.gather_schema_stats(ownname => 'benchbase', estimate_percent => dbms_stats.auto_sample_size, method_opt => 'for all columns size AUTO'); END;; \ No newline at end of file From 9484adca339a1e54c1459754cd756a281a284426 Mon Sep 17 00:00:00 2001 From: Nguyen Nguyen Date: Tue, 14 Nov 2023 12:19:49 +1000 Subject: [PATCH 11/17] Update src/main/resources/benchmarks/auctionmark/ddl-oracle.sql Fix spacing Co-authored-by: Brian Kroth --- src/main/resources/benchmarks/auctionmark/ddl-oracle.sql | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/resources/benchmarks/auctionmark/ddl-oracle.sql b/src/main/resources/benchmarks/auctionmark/ddl-oracle.sql index 56092d220..34b0d7eb6 100644 --- a/src/main/resources/benchmarks/auctionmark/ddl-oracle.sql +++ b/src/main/resources/benchmarks/auctionmark/ddl-oracle.sql @@ -70,7 +70,7 @@ CREATE TABLE USERACCT ( u_sattr7 VARCHAR2(64), u_iattr0 NUMBER(19, 0) DEFAULT NULL, u_iattr1 NUMBER(19, 0) DEFAULT NULL, - u_iattr2 NUMBER(19, 0) DEFAULT NULL, + u_iattr2 NUMBER(19, 0) DEFAULT NULL, u_iattr3 NUMBER(19, 0) DEFAULT NULL, u_iattr4 NUMBER(19, 0) DEFAULT NULL, u_iattr5 NUMBER(19, 0) DEFAULT NULL, From 253f0219bd89200903af21f8e060153ac08a670c Mon Sep 17 00:00:00 2001 From: Brian Kroth Date: Tue, 14 Nov 2023 10:46:31 -0600 Subject: [PATCH 12/17] Update src/main/java/com/oltpbenchmark/benchmarks/auctionmark/AuctionMarkLoader.java minor comment tweak --- .../oltpbenchmark/benchmarks/auctionmark/AuctionMarkLoader.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/com/oltpbenchmark/benchmarks/auctionmark/AuctionMarkLoader.java b/src/main/java/com/oltpbenchmark/benchmarks/auctionmark/AuctionMarkLoader.java index 64d0a8c73..71fe5f121 100644 --- a/src/main/java/com/oltpbenchmark/benchmarks/auctionmark/AuctionMarkLoader.java +++ b/src/main/java/com/oltpbenchmark/benchmarks/auctionmark/AuctionMarkLoader.java @@ -441,7 +441,7 @@ protected int populateRandomColumns(Object[] row) { // STRINGS for (Column catalog_col : this.random_str_cols) { int size = catalog_col.getSize(); - // This can generate an empty string which is treated as NULL in Oracle DB + // This (0) can generate an empty string which is treated as NULL in Oracle DB int start = getDatabaseType() == ORACLE ? 1 : 0; row[catalog_col.getIndex()] = profile.rng.astring(profile.rng.nextInt(start, size - 1), size); cols++; From ece5606adb928c7a30d641e0475b27879c3c844e Mon Sep 17 00:00:00 2001 From: Brian Kroth Date: Tue, 14 Nov 2023 10:56:46 -0600 Subject: [PATCH 13/17] Update src/main/java/com/oltpbenchmark/util/SQLUtil.java --- src/main/java/com/oltpbenchmark/util/SQLUtil.java | 1 + 1 file changed, 1 insertion(+) diff --git a/src/main/java/com/oltpbenchmark/util/SQLUtil.java b/src/main/java/com/oltpbenchmark/util/SQLUtil.java index 7168071e0..9574d6f3c 100644 --- a/src/main/java/com/oltpbenchmark/util/SQLUtil.java +++ b/src/main/java/com/oltpbenchmark/util/SQLUtil.java @@ -163,6 +163,7 @@ public static String getString(Object obj) { TIMESTAMP_VALUE_METHOD = timestampValueMethod; ORACLE_TIMESTAMP = oracleTimestamp; } + /** * Return a double from the given object * Handles the different cases from the various DBMSs From 63fcf6bc5ff2ffd520ad1f09ba0ce122822528fe Mon Sep 17 00:00:00 2001 From: Nguyen Nguyen Date: Thu, 23 Nov 2023 09:54:34 +1000 Subject: [PATCH 14/17] Update reset.sql location for GitHub Actions --- .github/workflows/maven.yml | 7 +------ config/oracle/scripts/reset.sql | 12 ++++++++++++ 2 files changed, 13 insertions(+), 6 deletions(-) create mode 100644 config/oracle/scripts/reset.sql diff --git a/.github/workflows/maven.yml b/.github/workflows/maven.yml index e1c245beb..b990df684 100644 --- a/.github/workflows/maven.yml +++ b/.github/workflows/maven.yml @@ -313,14 +313,9 @@ jobs: run: | rm -rf benchbase-oracle.tgz - # Add a reset SQL file to Oracle container home directory (docker exec oracle pwd) to recreate non-DBA user, so it can be invoked later using sqlplus - # See docker/oracle/reset.sql - # This file is recreated using printf instead of included in the artifact because only Oracle profile reset is more complicated than others, - # and benchmark doesn't need to be reset between runs normally - name: Set up user reset script run: | - printf "DROP USER benchbase CASCADE;\ncreate user benchbase identified by password;\nGRANT CONNECT, RESOURCE, CREATE VIEW, UNLIMITED TABLESPACE TO benchbase;\nGRANT EXECUTE ON DBMS_CRYPTO TO benchbase;\nGRANT EXECUTE ON DBMS_LOCK TO benchbase;\n" > reset.sql - docker cp reset.sql oracle:/opt/oracle/reset.sql + docker cp config/oracle/scripts/reset.sql oracle:/opt/oracle/reset.sql - name: Set up JDK uses: actions/setup-java@v3 diff --git a/config/oracle/scripts/reset.sql b/config/oracle/scripts/reset.sql new file mode 100644 index 000000000..7254298ea --- /dev/null +++ b/config/oracle/scripts/reset.sql @@ -0,0 +1,12 @@ +-- This SQL file recreate Oracle DB user (benchbase/password) for sample configs +-- This file is inteded to be copied into the OracleDB container, to be invoked later using sqlplus +-- docker cp config/oracle/scripts/reset.sql oracle:/opt/oracle/reset.sql +-- docker exec oracle sqlplus "sys/password@xepdb1 as sysdba" @reset.sql + +DROP USER benchbase CASCADE; +CREATE USER benchbase IDENTIFIED BY password; +GRANT CONNECT, RESOURCE, CREATE VIEW, UNLIMITED TABLESPACE TO benchbase; +-- Resourcestresser benchmark for Oracle requires access to these two packages +-- These will not be needed if running with user sys/system instead +GRANT EXECUTE ON DBMS_CRYPTO TO benchbase; +GRANT EXECUTE ON DBMS_LOCK TO benchbase; From 583c3958d515b7cf9122f326764aef8dac5f38e9 Mon Sep 17 00:00:00 2001 From: Nguyen Nguyen Date: Thu, 23 Nov 2023 16:52:09 +1000 Subject: [PATCH 15/17] Moved after load functionality to BenchmarkModule. Added test for after load --- .../java/com/oltpbenchmark/DBWorkload.java | 27 ++++------------ .../oltpbenchmark/api/BenchmarkModule.java | 19 ++++++++++- .../oltpbenchmark/api/AbstractTestLoader.java | 32 ++++++++++++++++--- src/test/resources/after-load.sql | 8 +++++ 4 files changed, 60 insertions(+), 26 deletions(-) create mode 100644 src/test/resources/after-load.sql diff --git a/src/main/java/com/oltpbenchmark/DBWorkload.java b/src/main/java/com/oltpbenchmark/DBWorkload.java index a20fe04ce..cd6aec3d6 100644 --- a/src/main/java/com/oltpbenchmark/DBWorkload.java +++ b/src/main/java/com/oltpbenchmark/DBWorkload.java @@ -213,6 +213,11 @@ public static void main(String[] args) throws Exception { postExecutionWait = xmlConfig.getLong(key + "/postExecutionWait"); } + // After load + if (xmlConfig.containsKey("afterload")) { + bench.setAfterLoadScriptPath(xmlConfig.getString("afterload")); + } + TransactionType tmpType = bench.initTransactionType(txnName, txnId + txnIdOffset, preExecutionWait, postExecutionWait); // Keep a reference for filtering @@ -454,21 +459,6 @@ public static void main(String[] args) throws Exception { LOG.debug("Skipping loading benchmark database records"); } - if (xmlConfig.containsKey("afterload")) { - try { - for (BenchmarkModule benchmark : benchList) { - LOG.info("Running script for {} database...", benchmark.getBenchmarkName().toUpperCase()); - runScriptAfterLoad(benchmark, xmlConfig.getString("afterload")); - LOG.info("Finished running script for {} database...", benchmark.getBenchmarkName().toUpperCase()); - } - } catch (Throwable ex) { - LOG.error("Unexpected error when running script", ex); - System.exit(1); - } - } else { - LOG.debug("Skipping script after database loading"); - } - // Execute Workload if (isBooleanOptionSet(argsLine, "execute")) { // Bombs away! @@ -640,16 +630,11 @@ private static void runCreator(BenchmarkModule bench) throws SQLException, IOExc bench.createDatabase(); } - private static void runLoader(BenchmarkModule bench) throws SQLException, InterruptedException { + private static void runLoader(BenchmarkModule bench) throws SQLException, InterruptedException, IOException { LOG.debug(String.format("Loading %s Database", bench)); bench.loadDatabase(); } - private static void runScriptAfterLoad(BenchmarkModule bench, String scriptPath) throws SQLException, IOException { - LOG.debug(String.format("Running script %s after loading data for %s Database", scriptPath, bench)); - bench.runScript(scriptPath); - } - private static Results runWorkload(List benchList, int intervalMonitor) throws IOException { List> workers = new ArrayList<>(); List workConfs = new ArrayList<>(); diff --git a/src/main/java/com/oltpbenchmark/api/BenchmarkModule.java b/src/main/java/com/oltpbenchmark/api/BenchmarkModule.java index a2788fefc..a0585d699 100644 --- a/src/main/java/com/oltpbenchmark/api/BenchmarkModule.java +++ b/src/main/java/com/oltpbenchmark/api/BenchmarkModule.java @@ -103,6 +103,17 @@ public final Connection makeConnection() throws SQLException { } } + private String afterLoadScriptPath = null; + + public final void setAfterLoadScriptPath(String scriptPath) { + this.afterLoadScriptPath = scriptPath; + } + + public String getAfterLoadScriptPath() { + return this.afterLoadScriptPath; + } + + // -------------------------------------------------------------------------- // IMPLEMENTING CLASS INTERFACE // -------------------------------------------------------------------------- @@ -258,7 +269,7 @@ public final void runScript(String scriptPath) throws SQLException, IOException /** * Invoke this benchmark's database loader */ - public final Loader loadDatabase() throws SQLException, InterruptedException { + public final Loader loadDatabase() throws IOException, SQLException, InterruptedException { Loader loader; loader = this.makeLoaderImpl(); @@ -281,6 +292,12 @@ public final Loader loadDatabase() throws SQLExceptio } } + if (this.afterLoadScriptPath != null) { + LOG.debug("Running script after load for {} benchmark...", this.workConf.getBenchmarkName().toUpperCase()); + runScript(this.afterLoadScriptPath); + LOG.debug("Finished running script after load for {} benchmark...", this.workConf.getBenchmarkName().toUpperCase()); + } + return loader; } diff --git a/src/test/java/com/oltpbenchmark/api/AbstractTestLoader.java b/src/test/java/com/oltpbenchmark/api/AbstractTestLoader.java index 9e17fb305..0db87c520 100644 --- a/src/test/java/com/oltpbenchmark/api/AbstractTestLoader.java +++ b/src/test/java/com/oltpbenchmark/api/AbstractTestLoader.java @@ -17,10 +17,6 @@ package com.oltpbenchmark.api; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertTrue; - import com.oltpbenchmark.catalog.Table; import com.oltpbenchmark.util.Histogram; import com.oltpbenchmark.util.SQLUtil; @@ -28,10 +24,14 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; +import java.sql.PreparedStatement; import java.sql.ResultSet; import java.sql.SQLException; import java.sql.Statement; import java.util.List; +import java.util.stream.Collectors; + +import static org.junit.Assert.*; public abstract class AbstractTestLoader extends AbstractTestCase { @@ -58,6 +58,19 @@ public void testLoad() throws Exception { } + /** + * testLoad with after load script + */ + @Test + public void testLoadWithAfterLoad() throws Exception { + this.benchmark.setAfterLoadScriptPath("/after-load.sql"); + + this.benchmark.loadDatabase(); + + validateLoad(); + + } + private void validateLoad() throws SQLException { assertFalse("Failed to get table names for " + benchmark.getBenchmarkName().toUpperCase(), this.catalog.getTables().isEmpty()); @@ -85,6 +98,17 @@ private void validateLoad() throws SQLException { } } + // A table called extra is added with after-load, with one + if (this.benchmark.getAfterLoadScriptPath() != null) { + try (PreparedStatement stmt = conn.prepareStatement("SELECT * FROM extra"); ResultSet rs = stmt.executeQuery()) { + while (rs.next()) { + assertEquals("Table 'extra' from /after-load.sql has value different than 0", rs.getInt(1), 0); + } + } catch (Exception e) { + fail("Table 'extra' from /after-load.sql was not initialized"); + } + } + LOG.debug("=== TABLE SIZES ===\n" + tableSizes); assertFalse("Unable to compute the tables size for " + benchmark.getBenchmarkName().toUpperCase(), tableSizes.isEmpty()); diff --git a/src/test/resources/after-load.sql b/src/test/resources/after-load.sql new file mode 100644 index 000000000..56183925a --- /dev/null +++ b/src/test/resources/after-load.sql @@ -0,0 +1,8 @@ +DROP TABLE IF EXISTS extra CASCADE; + +CREATE TABLE extra ( + extra_pk int NOT NULL, + PRIMARY KEY (extra_pk) +); + +INSERT INTO extra VALUES (0); From efd02ba590dd568c8b2efa542ad09e6656fc6088 Mon Sep 17 00:00:00 2001 From: Nguyen Nguyen Date: Thu, 7 Dec 2023 11:12:15 +1000 Subject: [PATCH 16/17] Apply suggestions Co-authored-by: Brian Kroth --- src/main/java/com/oltpbenchmark/api/Procedure.java | 3 ++- .../benchmarks/auctionmark/AuctionMarkLoader.java | 4 ++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/src/main/java/com/oltpbenchmark/api/Procedure.java b/src/main/java/com/oltpbenchmark/api/Procedure.java index dd23c8cb9..b3c2a1458 100644 --- a/src/main/java/com/oltpbenchmark/api/Procedure.java +++ b/src/main/java/com/oltpbenchmark/api/Procedure.java @@ -37,13 +37,14 @@ public abstract class Procedure { private final String procName; private DatabaseType dbType; + /** * LoadConfig procedure in auctionmark and seats benchmark contains CLOB on Oracle config * * For other databases, calling SQLUtil.getString(Object) after connection close is fine, but for * Oracle config, CLOBS needs to be resolved into String when the connection is open. Making this field * protected allows LoadConfig procedure to determine current database type, and decide if it should perform - * the conversion. + * the conversion. */ public DatabaseType getDbType() { return dbType; diff --git a/src/main/java/com/oltpbenchmark/benchmarks/auctionmark/AuctionMarkLoader.java b/src/main/java/com/oltpbenchmark/benchmarks/auctionmark/AuctionMarkLoader.java index 71fe5f121..dae155a5e 100644 --- a/src/main/java/com/oltpbenchmark/benchmarks/auctionmark/AuctionMarkLoader.java +++ b/src/main/java/com/oltpbenchmark/benchmarks/auctionmark/AuctionMarkLoader.java @@ -40,7 +40,7 @@ import java.util.concurrent.TimeUnit; import java.util.regex.Pattern; -import static com.oltpbenchmark.types.DatabaseType.ORACLE; +import com.oltpbenchmark.types.DatabaseType; /** * @author pavlo @@ -442,7 +442,7 @@ protected int populateRandomColumns(Object[] row) { for (Column catalog_col : this.random_str_cols) { int size = catalog_col.getSize(); // This (0) can generate an empty string which is treated as NULL in Oracle DB - int start = getDatabaseType() == ORACLE ? 1 : 0; + int start = getDatabaseType() == DatabaseType.ORACLE ? 1 : 0; row[catalog_col.getIndex()] = profile.rng.astring(profile.rng.nextInt(start, size - 1), size); cols++; } From 2d06e75b763adb8fb2411c1ae09a516b63575adf Mon Sep 17 00:00:00 2001 From: Nguyen Nguyen Date: Thu, 7 Dec 2023 11:20:42 +1000 Subject: [PATCH 17/17] Address comments --- src/main/java/com/oltpbenchmark/DBWorkload.java | 1 + src/main/java/com/oltpbenchmark/api/BenchmarkModule.java | 1 + src/main/java/com/oltpbenchmark/api/Procedure.java | 8 -------- .../java/com/oltpbenchmark/api/AbstractTestLoader.java | 3 --- 4 files changed, 2 insertions(+), 11 deletions(-) diff --git a/src/main/java/com/oltpbenchmark/DBWorkload.java b/src/main/java/com/oltpbenchmark/DBWorkload.java index 4e34bd425..46231c0e7 100644 --- a/src/main/java/com/oltpbenchmark/DBWorkload.java +++ b/src/main/java/com/oltpbenchmark/DBWorkload.java @@ -15,6 +15,7 @@ * */ + package com.oltpbenchmark; import com.oltpbenchmark.api.BenchmarkModule; diff --git a/src/main/java/com/oltpbenchmark/api/BenchmarkModule.java b/src/main/java/com/oltpbenchmark/api/BenchmarkModule.java index fc73af0ce..16a844e5e 100644 --- a/src/main/java/com/oltpbenchmark/api/BenchmarkModule.java +++ b/src/main/java/com/oltpbenchmark/api/BenchmarkModule.java @@ -15,6 +15,7 @@ * */ + package com.oltpbenchmark.api; import com.oltpbenchmark.WorkloadConfiguration; diff --git a/src/main/java/com/oltpbenchmark/api/Procedure.java b/src/main/java/com/oltpbenchmark/api/Procedure.java index b3c2a1458..fa9c711a8 100644 --- a/src/main/java/com/oltpbenchmark/api/Procedure.java +++ b/src/main/java/com/oltpbenchmark/api/Procedure.java @@ -38,14 +38,6 @@ public abstract class Procedure { private final String procName; private DatabaseType dbType; - /** - * LoadConfig procedure in auctionmark and seats benchmark contains CLOB on Oracle config - * - * For other databases, calling SQLUtil.getString(Object) after connection close is fine, but for - * Oracle config, CLOBS needs to be resolved into String when the connection is open. Making this field - * protected allows LoadConfig procedure to determine current database type, and decide if it should perform - * the conversion. - */ public DatabaseType getDbType() { return dbType; } diff --git a/src/test/java/com/oltpbenchmark/api/AbstractTestLoader.java b/src/test/java/com/oltpbenchmark/api/AbstractTestLoader.java index d199fc14f..cbfc7bc75 100644 --- a/src/test/java/com/oltpbenchmark/api/AbstractTestLoader.java +++ b/src/test/java/com/oltpbenchmark/api/AbstractTestLoader.java @@ -29,9 +29,6 @@ import java.sql.SQLException; import java.sql.Statement; import java.util.List; -import java.util.stream.Collectors; - -import static org.junit.Assert.*; import static org.junit.Assert.*; import static org.junit.Assert.fail;