add testcontainers

This commit is contained in:
Jörg Prante 2024-07-08 17:34:38 +02:00
parent 698d755934
commit ae8f10b9cf
614 changed files with 100376 additions and 98526 deletions

8
NOTICE.txt Normal file
View file

@ -0,0 +1,8 @@
This work integrates
pgjdbc - https://github.com/pgjdbc/pgjdbc (as of 1 Apr 2024)
stringprep - Stringprep (RFC 3454) Java implementation https://github.com/ongres/stringprep (as of 1 Apr 2024)
saslprep - a profile of stringprep
scram-client - SCRAM (RFC 5802) Java implementation https://github.com/ongres/scram (as of 1 Apr 2024)
All of those projects where modfied for Java 21+ with JPMS info.

View file

@ -1,4 +1,3 @@
group = org.xbib.jdbc
name = pgjdbc
version = 42.7.4.0

View file

@ -8,8 +8,8 @@ dependencies {
test {
useJUnitPlatform()
failFast = true
systemProperty 'java.util.logging.config.file', 'src/test/resources/logging.properties'
failFast = false
//systemProperty 'java.util.logging.config.file', 'src/test/resources/logging.properties'
testLogging {
events 'STARTED', 'PASSED', 'FAILED', 'SKIPPED'
showStandardStreams = true

Binary file not shown.

View file

@ -1,6 +1,6 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-8.5-all.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-8.7-bin.zip
networkTimeout=10000
validateDistributionUrl=true
zipStoreBase=GRADLE_USER_HOME

20
gradlew.bat vendored
View file

@ -43,11 +43,11 @@ set JAVA_EXE=java.exe
%JAVA_EXE% -version >NUL 2>&1
if %ERRORLEVEL% equ 0 goto execute
echo.
echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
echo.
echo Please set the JAVA_HOME variable in your environment to match the
echo location of your Java installation.
echo. 1>&2
echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 1>&2
echo. 1>&2
echo Please set the JAVA_HOME variable in your environment to match the 1>&2
echo location of your Java installation. 1>&2
goto fail
@ -57,11 +57,11 @@ set JAVA_EXE=%JAVA_HOME%/bin/java.exe
if exist "%JAVA_EXE%" goto execute
echo.
echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
echo.
echo Please set the JAVA_HOME variable in your environment to match the
echo location of your Java installation.
echo. 1>&2
echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% 1>&2
echo. 1>&2
echo Please set the JAVA_HOME variable in your environment to match the 1>&2
echo location of your Java installation. 1>&2
goto fail

View file

@ -1,3 +1,30 @@
dependencies {
api project(':scram-client')
testImplementation testLibs.junit.runner
testImplementation testLibs.junit.jupiter.engine
testImplementation testLibs.bytebuddy
testImplementation testLibs.bytebuddy.agent
testImplementation testLibs.classloader.leak.test
testImplementation testLibs.testcontainers
testImplementation testLibs.testcontainers.junit.jupiter
testImplementation testLibs.testcontainers.postgresql
}
test {
systemProperty 'username', 'test'
systemProperty 'server', 'localhost'
systemProperty 'port', '5432'
systemProperty 'secondaryServer1', 'localhost'
systemProperty 'secondaryPort1', '5433'
systemProperty 'secondaryServer2', 'localhost'
systemProperty 'secondaryPort2', '5434'
systemProperty 'database', 'test'
systemProperty 'username', 'test'
systemProperty 'password', 'test'
systemProperty 'privilegedUser', 'postgres'
systemProperty 'privilegedPassword', ''
systemProperty 'sspiusername', 'testsspi'
systemProperty 'preparethreshold', '5'
systemProperty 'protocolVersion', '0'
systemProperty 'sslpassword', 'sslpwd'
}

File diff suppressed because it is too large Load diff

View file

@ -32,350 +32,349 @@ import java.util.Map;
*/
public interface PGConnection {
/**
* Creates an {@link Array} wrapping <i>elements</i>. This is similar to
* {@link java.sql.Connection#createArrayOf(String, Object[])}, but also
* provides support for primitive arrays.
*
* @param typeName
* The SQL name of the type to map the <i>elements</i> to.
* Must not be {@code null}.
* @param elements
* The array of objects to map. A {@code null} value will result in
* an {@link Array} representing {@code null}.
* @return An {@link Array} wrapping <i>elements</i>.
* @throws SQLException
* If for some reason the array cannot be created.
* @see java.sql.Connection#createArrayOf(String, Object[])
*/
Array createArrayOf(String typeName, Object elements) throws SQLException;
/**
* Creates an {@link Array} wrapping <i>elements</i>. This is similar to
* {@link java.sql.Connection#createArrayOf(String, Object[])}, but also
* provides support for primitive arrays.
*
* @param typeName The SQL name of the type to map the <i>elements</i> to.
* Must not be {@code null}.
* @param elements The array of objects to map. A {@code null} value will result in
* an {@link Array} representing {@code null}.
* @return An {@link Array} wrapping <i>elements</i>.
* @throws SQLException If for some reason the array cannot be created.
* @see java.sql.Connection#createArrayOf(String, Object[])
*/
Array createArrayOf(String typeName, Object elements) throws SQLException;
/**
* This method returns any notifications that have been received since the last call to this
* method. Returns null if there have been no notifications.
*
* @return notifications that have been received
* @throws SQLException if something wrong happens
* @since 7.3
*/
PGNotification[] getNotifications() throws SQLException;
/**
* This method returns any notifications that have been received since the last call to this
* method. Returns null if there have been no notifications.
*
* @return notifications that have been received
* @throws SQLException if something wrong happens
* @since 7.3
*/
PGNotification[] getNotifications() throws SQLException;
/**
* This method returns any notifications that have been received since the last call to this
* method. Returns null if there have been no notifications. A timeout can be specified so the
* driver waits for notifications.
*
* @param timeoutMillis when 0, blocks forever. when &gt; 0, blocks up to the specified number of millis
* or until at least one notification has been received. If more than one notification is
* about to be received, these will be returned in one batch.
* @return notifications that have been received
* @throws SQLException if something wrong happens
* @since 43
*/
PGNotification[] getNotifications(int timeoutMillis) throws SQLException;
/**
* This method returns any notifications that have been received since the last call to this
* method. Returns null if there have been no notifications. A timeout can be specified so the
* driver waits for notifications.
*
* @param timeoutMillis when 0, blocks forever. when &gt; 0, blocks up to the specified number of millis
* or until at least one notification has been received. If more than one notification is
* about to be received, these will be returned in one batch.
* @return notifications that have been received
* @throws SQLException if something wrong happens
* @since 43
*/
PGNotification[] getNotifications(int timeoutMillis) throws SQLException;
/**
* This returns the COPY API for the current connection.
*
* @return COPY API for the current connection
* @throws SQLException if something wrong happens
* @since 8.4
*/
CopyManager getCopyAPI() throws SQLException;
/**
* This returns the COPY API for the current connection.
*
* @return COPY API for the current connection
* @throws SQLException if something wrong happens
* @since 8.4
*/
CopyManager getCopyAPI() throws SQLException;
/**
* This returns the LargeObject API for the current connection.
*
* @return LargeObject API for the current connection
* @throws SQLException if something wrong happens
* @since 7.3
*/
LargeObjectManager getLargeObjectAPI() throws SQLException;
/**
* This returns the LargeObject API for the current connection.
*
* @return LargeObject API for the current connection
* @throws SQLException if something wrong happens
* @since 7.3
*/
LargeObjectManager getLargeObjectAPI() throws SQLException;
/**
* This returns the Fastpath API for the current connection.
*
* @return Fastpath API for the current connection
* @throws SQLException if something wrong happens
* @since 7.3
* @deprecated This API is somewhat obsolete, as one may achieve similar performance
* and greater functionality by setting up a prepared statement to define
* the function call. Then, executing the statement with binary transmission of parameters
* and results substitutes for a fast-path function call.
*/
@Deprecated
Fastpath getFastpathAPI() throws SQLException;
/**
* This returns the Fastpath API for the current connection.
*
* @return Fastpath API for the current connection
* @throws SQLException if something wrong happens
* @since 7.3
* @deprecated This API is somewhat obsolete, as one may achieve similar performance
* and greater functionality by setting up a prepared statement to define
* the function call. Then, executing the statement with binary transmission of parameters
* and results substitutes for a fast-path function call.
*/
@Deprecated
Fastpath getFastpathAPI() throws SQLException;
/**
* This allows client code to add a handler for one of org.postgresql's more unique data types. It
* is approximately equivalent to <code>addDataType(type, Class.forName(name))</code>.
*
* @param type JDBC type name
* @param className class name
* @throws RuntimeException if the type cannot be registered (class not found, etc).
* @deprecated As of 8.0, replaced by {@link #addDataType(String, Class)}. This deprecated method
* does not work correctly for registering classes that cannot be directly loaded by
* the JDBC driver's classloader.
*/
@Deprecated
void addDataType(String type, String className);
/**
* This allows client code to add a handler for one of org.postgresql's more unique data types. It
* is approximately equivalent to <code>addDataType(type, Class.forName(name))</code>.
*
* @param type JDBC type name
* @param className class name
* @throws RuntimeException if the type cannot be registered (class not found, etc).
* @deprecated As of 8.0, replaced by {@link #addDataType(String, Class)}. This deprecated method
* does not work correctly for registering classes that cannot be directly loaded by
* the JDBC driver's classloader.
*/
@Deprecated
void addDataType(String type, String className);
/**
* <p>This allows client code to add a handler for one of org.postgresql's more unique data types.</p>
*
* <p><b>NOTE:</b> This is not part of JDBC, but an extension.</p>
*
* <p>The best way to use this is as follows:</p>
*
* <pre>
* ...
* ((org.postgresql.PGConnection)myconn).addDataType("mytype", my.class.name.class);
* ...
* </pre>
*
* <p>where myconn is an open Connection to org.postgresql.</p>
*
* <p>The handling class must extend org.postgresql.util.PGobject</p>
*
* @param type the PostgreSQL type to register
* @param klass the class implementing the Java representation of the type; this class must
* implement {@link org.postgresql.util.PGobject}).
* @throws SQLException if <code>klass</code> does not implement
* {@link org.postgresql.util.PGobject}).
* @see org.postgresql.util.PGobject
* @since 8.0
*/
void addDataType(String type, Class<? extends PGobject> klass) throws SQLException;
/**
* <p>This allows client code to add a handler for one of org.postgresql's more unique data types.</p>
*
* <p><b>NOTE:</b> This is not part of JDBC, but an extension.</p>
*
* <p>The best way to use this is as follows:</p>
*
* <pre>
* ...
* ((org.postgresql.PGConnection)myconn).addDataType("mytype", my.class.name.class);
* ...
* </pre>
*
* <p>where myconn is an open Connection to org.postgresql.</p>
*
* <p>The handling class must extend org.postgresql.util.PGobject</p>
*
* @param type the PostgreSQL type to register
* @param klass the class implementing the Java representation of the type; this class must
* implement {@link org.postgresql.util.PGobject}).
* @throws SQLException if <code>klass</code> does not implement
* {@link org.postgresql.util.PGobject}).
* @see org.postgresql.util.PGobject
* @since 8.0
*/
void addDataType(String type, Class<? extends PGobject> klass) throws SQLException;
/**
* Set the default statement reuse threshold before enabling server-side prepare. See
* {@link org.postgresql.PGStatement#setPrepareThreshold(int)} for details.
*
* @param threshold the new threshold
* @since build 302
*/
void setPrepareThreshold(int threshold);
/**
* Get the default server-side prepare reuse threshold for statements created from this
* connection.
*
* @return the current threshold
* @since build 302
*/
int getPrepareThreshold();
/**
* Get the default server-side prepare reuse threshold for statements created from this
* connection.
*
* @return the current threshold
* @since build 302
*/
int getPrepareThreshold();
/**
* Set the default statement reuse threshold before enabling server-side prepare. See
* {@link org.postgresql.PGStatement#setPrepareThreshold(int)} for details.
*
* @param threshold the new threshold
* @since build 302
*/
void setPrepareThreshold(int threshold);
/**
* Set the default fetch size for statements created from this connection.
*
* @param fetchSize new default fetch size
* @throws SQLException if specified negative <code>fetchSize</code> parameter
* @see Statement#setFetchSize(int)
*/
void setDefaultFetchSize(int fetchSize) throws SQLException;
/**
* Get the default fetch size for statements created from this connection.
*
* @return current state for default fetch size
* @see PGProperty#DEFAULT_ROW_FETCH_SIZE
* @see Statement#getFetchSize()
*/
int getDefaultFetchSize();
/**
* Get the default fetch size for statements created from this connection.
*
* @return current state for default fetch size
* @see PGProperty#DEFAULT_ROW_FETCH_SIZE
* @see Statement#getFetchSize()
*/
int getDefaultFetchSize();
/**
* Set the default fetch size for statements created from this connection.
*
* @param fetchSize new default fetch size
* @throws SQLException if specified negative <code>fetchSize</code> parameter
* @see Statement#setFetchSize(int)
*/
void setDefaultFetchSize(int fetchSize) throws SQLException;
/**
* Return the process ID (PID) of the backend server process handling this connection.
*
* @return PID of backend server process.
*/
int getBackendPID();
/**
* Return the process ID (PID) of the backend server process handling this connection.
*
* @return PID of backend server process.
*/
int getBackendPID();
/**
* Sends a query cancellation for this connection.
* @throws SQLException if there are problems cancelling the query
*/
void cancelQuery() throws SQLException;
/**
* Sends a query cancellation for this connection.
*
* @throws SQLException if there are problems cancelling the query
*/
void cancelQuery() throws SQLException;
/**
* Return the given string suitably quoted to be used as an identifier in an SQL statement string.
* Quotes are added only if necessary (i.e., if the string contains non-identifier characters or
* would be case-folded). Embedded quotes are properly doubled.
*
* @param identifier input identifier
* @return the escaped identifier
* @throws SQLException if something goes wrong
*/
String escapeIdentifier(String identifier) throws SQLException;
/**
* Return the given string suitably quoted to be used as an identifier in an SQL statement string.
* Quotes are added only if necessary (i.e., if the string contains non-identifier characters or
* would be case-folded). Embedded quotes are properly doubled.
*
* @param identifier input identifier
* @return the escaped identifier
* @throws SQLException if something goes wrong
*/
String escapeIdentifier(String identifier) throws SQLException;
/**
* Return the given string suitably quoted to be used as a string literal in an SQL statement
* string. Embedded single-quotes and backslashes are properly doubled. Note that quote_literal
* returns null on null input.
*
* @param literal input literal
* @return the quoted literal
* @throws SQLException if something goes wrong
*/
String escapeLiteral(String literal) throws SQLException;
/**
* Return the given string suitably quoted to be used as a string literal in an SQL statement
* string. Embedded single-quotes and backslashes are properly doubled. Note that quote_literal
* returns null on null input.
*
* @param literal input literal
* @return the quoted literal
* @throws SQLException if something goes wrong
*/
String escapeLiteral(String literal) throws SQLException;
/**
* <p>Returns the query mode for this connection.</p>
*
* <p>When running in simple query mode, certain features are not available: callable statements,
* partial result set fetch, bytea type, etc.</p>
* <p>The list of supported features is subject to change.</p>
*
* @return the preferred query mode
* @see PreferQueryMode
*/
PreferQueryMode getPreferQueryMode();
/**
* <p>Returns the query mode for this connection.</p>
*
* <p>When running in simple query mode, certain features are not available: callable statements,
* partial result set fetch, bytea type, etc.</p>
* <p>The list of supported features is subject to change.</p>
*
* @return the preferred query mode
* @see PreferQueryMode
*/
PreferQueryMode getPreferQueryMode();
/**
* Connection configuration regarding automatic per-query savepoints.
*
* @return connection configuration regarding automatic per-query savepoints
* @see PGProperty#AUTOSAVE
*/
AutoSave getAutosave();
/**
* Connection configuration regarding automatic per-query savepoints.
*
* @return connection configuration regarding automatic per-query savepoints
* @see PGProperty#AUTOSAVE
*/
AutoSave getAutosave();
/**
* Configures if connection should use automatic savepoints.
* @param autoSave connection configuration regarding automatic per-query savepoints
* @see PGProperty#AUTOSAVE
*/
void setAutosave(AutoSave autoSave);
/**
* Configures if connection should use automatic savepoints.
*
* @param autoSave connection configuration regarding automatic per-query savepoints
* @see PGProperty#AUTOSAVE
*/
void setAutosave(AutoSave autoSave);
/**
* @return replication API for the current connection
*/
PGReplicationConnection getReplicationAPI();
/**
* @return replication API for the current connection
*/
PGReplicationConnection getReplicationAPI();
/**
* Change a user's password to the specified new password.
*
* <p>
* If the specific encryption type is not specified, this method defaults to querying the database server for the server's default password_encryption.
* This method does not send the new password in plain text to the server.
* Instead, it encrypts the password locally and sends the encoded hash so that the plain text password is never sent on the wire.
* </p>
*
* <p>
* Acceptable values for encryptionType are null, "md5", or "scram-sha-256".
* Users should avoid "md5" unless they are explicitly targeting an older server that does not support the more secure SCRAM.
* </p>
*
* @param user The username of the database user
* @param newPassword The new password for the database user. The implementation will zero
* out the array after use
* @param encryptionType The type of password encryption to use or null if the database server default should be used.
* @throws SQLException If the password could not be altered
*/
default void alterUserPassword(String user, char[] newPassword, String encryptionType) throws SQLException {
try (Statement stmt = ((Connection) this).createStatement()) {
if (encryptionType == null) {
try (ResultSet rs = stmt.executeQuery("SHOW password_encryption")) {
if (!rs.next()) {
throw new PSQLException(GT.tr("Expected a row when reading password_encryption but none was found"),
PSQLState.NO_DATA);
}
encryptionType = rs.getString(1);
if (encryptionType == null) {
throw new PSQLException(GT.tr("SHOW password_encryption returned null value"),
PSQLState.NO_DATA);
}
/**
* Change a user's password to the specified new password.
*
* <p>
* If the specific encryption type is not specified, this method defaults to querying the database server for the server's default password_encryption.
* This method does not send the new password in plain text to the server.
* Instead, it encrypts the password locally and sends the encoded hash so that the plain text password is never sent on the wire.
* </p>
*
* <p>
* Acceptable values for encryptionType are null, "md5", or "scram-sha-256".
* Users should avoid "md5" unless they are explicitly targeting an older server that does not support the more secure SCRAM.
* </p>
*
* @param user The username of the database user
* @param newPassword The new password for the database user. The implementation will zero
* out the array after use
* @param encryptionType The type of password encryption to use or null if the database server default should be used.
* @throws SQLException If the password could not be altered
*/
default void alterUserPassword(String user, char[] newPassword, String encryptionType) throws SQLException {
try (Statement stmt = ((Connection) this).createStatement()) {
if (encryptionType == null) {
try (ResultSet rs = stmt.executeQuery("SHOW password_encryption")) {
if (!rs.next()) {
throw new PSQLException(GT.tr("Expected a row when reading password_encryption but none was found"),
PSQLState.NO_DATA);
}
encryptionType = rs.getString(1);
if (encryptionType == null) {
throw new PSQLException(GT.tr("SHOW password_encryption returned null value"),
PSQLState.NO_DATA);
}
}
}
String sql = PasswordUtil.genAlterUserPasswordSQL(user, newPassword, encryptionType);
stmt.execute(sql);
} finally {
Arrays.fill(newPassword, (char) 0);
}
}
String sql = PasswordUtil.genAlterUserPasswordSQL(user, newPassword, encryptionType);
stmt.execute(sql);
} finally {
Arrays.fill(newPassword, (char) 0);
}
}
/**
* <p>Returns the current values of all parameters reported by the server.</p>
*
* <p>PostgreSQL reports values for a subset of parameters (GUCs) to the client
* at connect-time, then sends update messages whenever the values change
* during a session. PgJDBC records the latest values and exposes it to client
* applications via <code>getParameterStatuses()</code>.</p>
*
* <p>PgJDBC exposes individual accessors for some of these parameters as
* listed below. They are more backwards-compatible and should be preferred
* where possible.</p>
*
* <p>Not all parameters are reported, only those marked
* <code>GUC_REPORT</code> in the source code. The <code>pg_settings</code>
* view does not expose information about which parameters are reportable.
* PgJDBC's map will only contain the parameters the server reports values
* for, so you cannot use this method as a substitute for running a
* <code>SHOW paramname;</code> or <code>SELECT
* current_setting('paramname');</code> query for arbitrary parameters.</p>
*
* <p>Parameter names are <i>case-insensitive</i> and <i>case-preserving</i>
* in this map, like in PostgreSQL itself. So <code>DateStyle</code> and
* <code>datestyle</code> are the same key.</p>
*
* <p>
* As of PostgreSQL 11 the reportable parameter list, and related PgJDBC
* interfaces or assessors, are:
* </p>
*
* <ul>
* <li>
* <code>application_name</code> -
* {@link java.sql.Connection#getClientInfo()},
* {@link java.sql.Connection#setClientInfo(java.util.Properties)}
* and <code>ApplicationName</code> connection property.
* </li>
* <li>
* <code>client_encoding</code> - PgJDBC always sets this to <code>UTF8</code>.
* See <code>allowEncodingChanges</code> connection property.
* </li>
* <li><code>DateStyle</code> - PgJDBC requires this to always be set to <code>ISO</code></li>
* <li><code>standard_conforming_strings</code> - indirectly via {@link #escapeLiteral(String)}</li>
* <li>
* <code>TimeZone</code> - set from JDK timezone see {@link java.util.TimeZone#getDefault()}
* and {@link java.util.TimeZone#setDefault(TimeZone)}
* </li>
* <li><code>integer_datetimes</code></li>
* <li><code>IntervalStyle</code></li>
* <li><code>server_encoding</code></li>
* <li><code>server_version</code></li>
* <li><code>is_superuser</code> </li>
* <li><code>session_authorization</code></li>
* </ul>
*
* <p>Note that some PgJDBC operations will change server parameters
* automatically.</p>
*
* @return unmodifiable map of case-insensitive parameter names to parameter values
* @since 42.2.6
*/
Map<String, String> getParameterStatuses();
/**
* <p>Returns the current values of all parameters reported by the server.</p>
*
* <p>PostgreSQL reports values for a subset of parameters (GUCs) to the client
* at connect-time, then sends update messages whenever the values change
* during a session. PgJDBC records the latest values and exposes it to client
* applications via <code>getParameterStatuses()</code>.</p>
*
* <p>PgJDBC exposes individual accessors for some of these parameters as
* listed below. They are more backwards-compatible and should be preferred
* where possible.</p>
*
* <p>Not all parameters are reported, only those marked
* <code>GUC_REPORT</code> in the source code. The <code>pg_settings</code>
* view does not expose information about which parameters are reportable.
* PgJDBC's map will only contain the parameters the server reports values
* for, so you cannot use this method as a substitute for running a
* <code>SHOW paramname;</code> or <code>SELECT
* current_setting('paramname');</code> query for arbitrary parameters.</p>
*
* <p>Parameter names are <i>case-insensitive</i> and <i>case-preserving</i>
* in this map, like in PostgreSQL itself. So <code>DateStyle</code> and
* <code>datestyle</code> are the same key.</p>
*
* <p>
* As of PostgreSQL 11 the reportable parameter list, and related PgJDBC
* interfaces or assessors, are:
* </p>
*
* <ul>
* <li>
* <code>application_name</code> -
* {@link java.sql.Connection#getClientInfo()},
* {@link java.sql.Connection#setClientInfo(java.util.Properties)}
* and <code>ApplicationName</code> connection property.
* </li>
* <li>
* <code>client_encoding</code> - PgJDBC always sets this to <code>UTF8</code>.
* See <code>allowEncodingChanges</code> connection property.
* </li>
* <li><code>DateStyle</code> - PgJDBC requires this to always be set to <code>ISO</code></li>
* <li><code>standard_conforming_strings</code> - indirectly via {@link #escapeLiteral(String)}</li>
* <li>
* <code>TimeZone</code> - set from JDK timezone see {@link java.util.TimeZone#getDefault()}
* and {@link java.util.TimeZone#setDefault(TimeZone)}
* </li>
* <li><code>integer_datetimes</code></li>
* <li><code>IntervalStyle</code></li>
* <li><code>server_encoding</code></li>
* <li><code>server_version</code></li>
* <li><code>is_superuser</code> </li>
* <li><code>session_authorization</code></li>
* </ul>
*
* <p>Note that some PgJDBC operations will change server parameters
* automatically.</p>
*
* @return unmodifiable map of case-insensitive parameter names to parameter values
* @since 42.2.6
*/
Map<String, String> getParameterStatuses();
/**
* Shorthand for getParameterStatuses().get(...) .
*
* @param parameterName case-insensitive parameter name
* @return parameter value if defined, or null if no parameter known
* @see #getParameterStatuses
* @since 42.2.6
*/
String getParameterStatus(String parameterName);
/**
* Shorthand for getParameterStatuses().get(...) .
*
* @param parameterName case-insensitive parameter name
* @return parameter value if defined, or null if no parameter known
* @see #getParameterStatuses
* @since 42.2.6
*/
String getParameterStatus(String parameterName);
/**
* Turn on/off adaptive fetch for connection. Existing statements and resultSets won't be affected
* by change here.
*
* @param adaptiveFetch desired state of adaptive fetch.
*/
void setAdaptiveFetch(boolean adaptiveFetch);
/**
* Get state of adaptive fetch for connection.
*
* @return state of adaptive fetch (turned on or off)
*/
boolean getAdaptiveFetch();
/**
* Get state of adaptive fetch for connection.
*
* @return state of adaptive fetch (turned on or off)
*/
boolean getAdaptiveFetch();
/**
* Turn on/off adaptive fetch for connection. Existing statements and resultSets won't be affected
* by change here.
*
* @param adaptiveFetch desired state of adaptive fetch.
*/
void setAdaptiveFetch(boolean adaptiveFetch);
}

View file

@ -14,95 +14,95 @@ import java.util.Map;
*/
public enum PGEnvironment {
/**
* Specified location of password file.
*/
ORG_POSTGRESQL_PGPASSFILE(
"org.postgresql.pgpassfile",
null,
"Specified location of password file."),
/**
* Specified location of password file.
*/
ORG_POSTGRESQL_PGPASSFILE(
"org.postgresql.pgpassfile",
null,
"Specified location of password file."),
/**
* Specified location of password file.
*/
PGPASSFILE(
"PGPASSFILE",
"pgpass",
"Specified location of password file."),
/**
* Specified location of password file.
*/
PGPASSFILE(
"PGPASSFILE",
"pgpass",
"Specified location of password file."),
/**
* The connection service resource (file, url) allows connection parameters to be associated
* with a single service name.
*/
ORG_POSTGRESQL_PGSERVICEFILE(
"org.postgresql.pgservicefile",
null,
"Specifies the service resource to resolve connection properties."),
/**
* The connection service resource (file, url) allows connection parameters to be associated
* with a single service name.
*/
ORG_POSTGRESQL_PGSERVICEFILE(
"org.postgresql.pgservicefile",
null,
"Specifies the service resource to resolve connection properties."),
/**
* The connection service resource (file, url) allows connection parameters to be associated
* with a single service name.
*/
PGSERVICEFILE(
"PGSERVICEFILE",
"pg_service.conf",
"Specifies the service resource to resolve connection properties."),
/**
* The connection service resource (file, url) allows connection parameters to be associated
* with a single service name.
*/
PGSERVICEFILE(
"PGSERVICEFILE",
"pg_service.conf",
"Specifies the service resource to resolve connection properties."),
/**
* sets the directory containing the PGSERVICEFILE file and possibly other system-wide
* configuration files.
*/
PGSYSCONFDIR(
"PGSYSCONFDIR",
null,
"Specifies the directory containing the PGSERVICEFILE file"),
;
/**
* sets the directory containing the PGSERVICEFILE file and possibly other system-wide
* configuration files.
*/
PGSYSCONFDIR(
"PGSYSCONFDIR",
null,
"Specifies the directory containing the PGSERVICEFILE file"),
;
private final String name;
private final String defaultValue;
private final String description;
private static final Map<String, PGEnvironment> PROPS_BY_NAME = new HashMap<>();
PGEnvironment(String name, String defaultValue, String description) {
this.name = name;
this.defaultValue = defaultValue;
this.description = description;
}
private static final Map<String, PGEnvironment> PROPS_BY_NAME = new HashMap<>();
static {
for (PGEnvironment prop : PGEnvironment.values()) {
if (PROPS_BY_NAME.put(prop.getName(), prop) != null) {
throw new IllegalStateException("Duplicate PGProperty name: " + prop.getName());
}
static {
for (PGEnvironment prop : PGEnvironment.values()) {
if (PROPS_BY_NAME.put(prop.getName(), prop) != null) {
throw new IllegalStateException("Duplicate PGProperty name: " + prop.getName());
}
}
}
}
/**
* Returns the name of the parameter.
*
* @return the name of the parameter
*/
public String getName() {
return name;
}
private final String name;
private final String defaultValue;
private final String description;
/**
* Returns the default value for this parameter.
*
* @return the default value for this parameter or null
*/
public String getDefaultValue() {
return defaultValue;
}
PGEnvironment(String name, String defaultValue, String description) {
this.name = name;
this.defaultValue = defaultValue;
this.description = description;
}
/**
* Returns the description for this parameter.
*
* @return the description for this parameter
*/
public String getDescription() {
return description;
}
/**
* Returns the name of the parameter.
*
* @return the name of the parameter
*/
public String getName() {
return name;
}
/**
* Returns the default value for this parameter.
*
* @return the default value for this parameter or null
*/
public String getDefaultValue() {
return defaultValue;
}
/**
* Returns the description for this parameter.
*
* @return the description for this parameter
*/
public String getDescription() {
return description;
}
}

View file

@ -9,29 +9,29 @@ package org.postgresql;
* This interface defines the public PostgreSQL extension for Notifications.
*/
public interface PGNotification {
/**
* Returns name of this notification.
*
* @return name of this notification
* @since 7.3
*/
String getName();
/**
* Returns name of this notification.
*
* @return name of this notification
* @since 7.3
*/
String getName();
/**
* Returns the process id of the backend process making this notification.
*
* @return process id of the backend process making this notification
* @since 7.3
*/
int getPID();
/**
* Returns the process id of the backend process making this notification.
*
* @return process id of the backend process making this notification
* @since 7.3
*/
int getPID();
/**
* Returns additional information from the notifying process. This feature has only been
* implemented in server versions 9.0 and later, so previous versions will always return an empty
* String.
*
* @return additional information from the notifying process
* @since 8.0
*/
String getParameter();
/**
* Returns additional information from the notifying process. This feature has only been
* implemented in server versions 9.0 and later, so previous versions will always return an empty
* String.
*
* @return additional information from the notifying process
* @since 8.0
*/
String getParameter();
}

File diff suppressed because it is too large Load diff

View file

@ -9,17 +9,17 @@ package org.postgresql;
* A ref cursor based result set.
*
* @deprecated As of 8.0, this interface is only present for backwards- compatibility purposes. New
* code should call getString() on the ResultSet that contains the refcursor to obtain
* the underlying cursor name.
* code should call getString() on the ResultSet that contains the refcursor to obtain
* the underlying cursor name.
*/
@Deprecated
public interface PGRefCursorResultSet {
/**
* @return the name of the cursor.
* @deprecated As of 8.0, replaced with calling getString() on the ResultSet that this ResultSet
* was obtained from.
*/
@Deprecated
String getRefCursor();
/**
* @return the name of the cursor.
* @deprecated As of 8.0, replaced with calling getString() on the ResultSet that this ResultSet
* was obtained from.
*/
@Deprecated
String getRefCursor();
}

View file

@ -11,45 +11,45 @@ import java.sql.SQLException;
public interface PGResultSetMetaData {
/**
* Returns the underlying column name of a query result, or "" if it is unable to be determined.
*
* @param column column position (1-based)
* @return underlying column name of a query result
* @throws SQLException if something wrong happens
* @since 8.0
*/
String getBaseColumnName(int column) throws SQLException;
/**
* Returns the underlying column name of a query result, or "" if it is unable to be determined.
*
* @param column column position (1-based)
* @return underlying column name of a query result
* @throws SQLException if something wrong happens
* @since 8.0
*/
String getBaseColumnName(int column) throws SQLException;
/**
* Returns the underlying table name of query result, or "" if it is unable to be determined.
*
* @param column column position (1-based)
* @return underlying table name of query result
* @throws SQLException if something wrong happens
* @since 8.0
*/
String getBaseTableName(int column) throws SQLException;
/**
* Returns the underlying table name of query result, or "" if it is unable to be determined.
*
* @param column column position (1-based)
* @return underlying table name of query result
* @throws SQLException if something wrong happens
* @since 8.0
*/
String getBaseTableName(int column) throws SQLException;
/**
* Returns the underlying schema name of query result, or "" if it is unable to be determined.
*
* @param column column position (1-based)
* @return underlying schema name of query result
* @throws SQLException if something wrong happens
* @since 8.0
*/
String getBaseSchemaName(int column) throws SQLException;
/**
* Returns the underlying schema name of query result, or "" if it is unable to be determined.
*
* @param column column position (1-based)
* @return underlying schema name of query result
* @throws SQLException if something wrong happens
* @since 8.0
*/
String getBaseSchemaName(int column) throws SQLException;
/**
* Is a column Text or Binary?
*
* @param column column position (1-based)
* @return 0 if column data format is TEXT, or 1 if BINARY
* @throws SQLException if something wrong happens
* @see Field#BINARY_FORMAT
* @see Field#TEXT_FORMAT
* @since 9.4
*/
int getFormat(int column) throws SQLException;
/**
* Is a column Text or Binary?
*
* @param column column position (1-based)
* @return 0 if column data format is TEXT, or 1 if BINARY
* @throws SQLException if something wrong happens
* @see Field#BINARY_FORMAT
* @see Field#TEXT_FORMAT
* @since 9.4
*/
int getFormat(int column) throws SQLException;
}

View file

@ -12,86 +12,86 @@ import java.sql.SQLException;
* constructed by the PostgreSQL driver implement PGStatement.
*/
public interface PGStatement {
// We can't use Long.MAX_VALUE or Long.MIN_VALUE for java.sql.date
// because this would break the 'normalization contract' of the
// java.sql.Date API.
// The follow values are the nearest MAX/MIN values with hour,
// minute, second, millisecond set to 0 - this is used for
// -infinity / infinity representation in Java
long DATE_POSITIVE_INFINITY = 9223372036825200000L;
long DATE_NEGATIVE_INFINITY = -9223372036832400000L;
long DATE_POSITIVE_SMALLER_INFINITY = 185543533774800000L;
long DATE_NEGATIVE_SMALLER_INFINITY = -185543533774800000L;
// We can't use Long.MAX_VALUE or Long.MIN_VALUE for java.sql.date
// because this would break the 'normalization contract' of the
// java.sql.Date API.
// The follow values are the nearest MAX/MIN values with hour,
// minute, second, millisecond set to 0 - this is used for
// -infinity / infinity representation in Java
long DATE_POSITIVE_INFINITY = 9223372036825200000L;
long DATE_NEGATIVE_INFINITY = -9223372036832400000L;
long DATE_POSITIVE_SMALLER_INFINITY = 185543533774800000L;
long DATE_NEGATIVE_SMALLER_INFINITY = -185543533774800000L;
/**
* Returns the Last inserted/updated oid.