LCOV - code coverage report
Current view: top level - server/schema - MysqlAccountPatchReviewStore.java (source / functions) Hit Total Coverage
Test: _coverage_report.dat Lines: 0 9 0.0 %
Date: 2022-11-19 15:00:39 Functions: 0 3 0.0 %

          Line data    Source code
       1             : // Copyright (C) 2017 The Android Open Source Project
       2             : //
       3             : // Licensed under the Apache License, Version 2.0 (the "License");
       4             : // you may not use this file except in compliance with the License.
       5             : // You may obtain a copy of the License at
       6             : //
       7             : // http://www.apache.org/licenses/LICENSE-2.0
       8             : //
       9             : // Unless required by applicable law or agreed to in writing, software
      10             : // distributed under the License is distributed on an "AS IS" BASIS,
      11             : // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
      12             : // See the License for the specific language governing permissions and
      13             : // limitations under the License.
      14             : 
      15             : package com.google.gerrit.server.schema;
      16             : 
      17             : import com.google.gerrit.exceptions.DuplicateKeyException;
      18             : import com.google.gerrit.exceptions.StorageException;
      19             : import com.google.gerrit.server.config.GerritServerConfig;
      20             : import com.google.gerrit.server.config.SitePaths;
      21             : import com.google.gerrit.server.config.ThreadSettingsConfig;
      22             : import com.google.inject.Inject;
      23             : import com.google.inject.Singleton;
      24             : import java.sql.SQLException;
      25             : import java.sql.Statement;
      26             : import org.eclipse.jgit.lib.Config;
      27             : 
      28             : @Singleton
      29             : public class MysqlAccountPatchReviewStore extends JdbcAccountPatchReviewStore {
      30             : 
      31             :   @Inject
      32             :   MysqlAccountPatchReviewStore(
      33             :       @GerritServerConfig Config cfg,
      34             :       SitePaths sitePaths,
      35             :       ThreadSettingsConfig threadSettingsConfig) {
      36           0 :     super(cfg, sitePaths, threadSettingsConfig);
      37           0 :   }
      38             : 
      39             :   @Override
      40             :   public StorageException convertError(String op, SQLException err) {
      41           0 :     switch (err.getErrorCode()) {
      42             :       case 1022: // ER_DUP_KEY
      43             :       case 1062: // ER_DUP_ENTRY
      44             :       case 1169: // ER_DUP_UNIQUE;
      45           0 :         return new DuplicateKeyException("ACCOUNT_PATCH_REVIEWS", err);
      46             : 
      47             :       default:
      48           0 :         if (err.getCause() == null && err.getNextException() != null) {
      49           0 :           err.initCause(err.getNextException());
      50             :         }
      51           0 :         return new StorageException(op + " failure on ACCOUNT_PATCH_REVIEWS", err);
      52             :     }
      53             :   }
      54             : 
      55             :   @Override
      56             :   protected void doCreateTable(Statement stmt) throws SQLException {
      57           0 :     stmt.executeUpdate(
      58             :         "CREATE TABLE IF NOT EXISTS account_patch_reviews ("
      59             :             + "account_id INTEGER DEFAULT 0 NOT NULL, "
      60             :             + "change_id INTEGER DEFAULT 0 NOT NULL, "
      61             :             + "patch_set_id INTEGER DEFAULT 0 NOT NULL, "
      62             :             + "file_name VARCHAR(255) DEFAULT '' NOT NULL, "
      63             :             + "CONSTRAINT primary_key_account_patch_reviews "
      64             :             + "PRIMARY KEY (change_id, patch_set_id, account_id, file_name)"
      65             :             + ")");
      66           0 :   }
      67             : }

Generated by: LCOV version 1.16+git.20220603.dfeb750