All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.amazon.redshift.jdbc.RedshiftWarningWrapper Maven / Gradle / Ivy

There is a newer version: 2.1.0.30
Show newest version
/*
 * Copyright (c) 2017, PostgreSQL Global Development Group
 * See the LICENSE file in the project root for more information.
 */

package com.amazon.redshift.jdbc;

import java.sql.SQLWarning;

/**
 * Wrapper class for SQLWarnings that provides an optimisation to add
 * new warnings to the tail of the SQLWarning singly linked list, avoiding Θ(n) insertion time
 * of calling #setNextWarning on the head. By encapsulating this into a single object it allows
 * users(ie PgStatement) to atomically set and clear the warning chain.
 */
class RedshiftWarningWrapper {

  private final SQLWarning firstWarning;
  private SQLWarning lastWarning;

  RedshiftWarningWrapper(SQLWarning warning) {
    firstWarning = warning;
    lastWarning = warning;
  }

  void addWarning(SQLWarning sqlWarning) {
    lastWarning.setNextWarning(sqlWarning);
    lastWarning = sqlWarning;
  }

  SQLWarning getFirstWarning() {
    return firstWarning;
  }

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy