public class SessionState
SessionState contains all session variables for a connection.
Constructors
SessionState(OptionsMetadata options)
public SessionState(OptionsMetadata options)
Parameter | |
---|---|
Name | Description |
options | OptionsMetadata |
Methods
commit()
public void commit()
Commits the current transaction and persists any changes to the settings (except local changes).
generatePGSettingsCte()
public String generatePGSettingsCte()
Generates a Common Table Expression that represents the pg_settings table. Note that the generated query adds two additional CTEs that could in theory hide existing user tables. It is however strongly recommended that user tables never start with 'pg_', as all system tables in PostgreSQL start with 'pg_' and 'pg_catalog' is by design always included in the search_path and is by default the first entry on the search_path. This means that user tables that start with 'pg_' always risk being hidden by user tables, unless pg_catalog has been explicitly added to the search_path after one or more user schemas.
Returns | |
---|---|
Type | Description |
String |
get(String extension, String name)
public PGSetting get(String extension, String name)
Returns the current value of the specified setting.
Parameters | |
---|---|
Name | Description |
extension | String |
name | String |
Returns | |
---|---|
Type | Description |
PGSetting |
getAll()
public List<PGSetting> getAll()
Returns all settings and their current values.
Returns | |
---|---|
Type | Description |
List<PGSetting> |
getDdlTransactionMode()
public OptionsMetadata.DdlTransactionMode getDdlTransactionMode()
Returns the DdlTransactionMode that is used for this connection at this time.
Returns | |
---|---|
Type | Description |
OptionsMetadata.DdlTransactionMode |
getLogSlowStatementThreshold()
public Duration getLogSlowStatementThreshold()
Returns the threshold for when a query should be considered slow and should be logged.
Returns | |
---|---|
Type | Description |
Duration |
getServerVersion()
public String getServerVersion()
Returns the PostgreSQL version.
Returns | |
---|---|
Type | Description |
String |
getTimezone()
public ZoneId getTimezone()
Returns the ZoneId of the current timezone for this session.
Returns | |
---|---|
Type | Description |
ZoneId |
isAutoAddLimitClause()
public boolean isAutoAddLimitClause()
Returns whether statements with an OFFSET clause that uses a parameter should be automatically appended with a LIMIT clause. The LIMIT clause will use the literal Long.MAX_VALUE for unbound statements, and Long.MAX_VALUE - offset for bound statements.
This method will be removed in the future.
Returns | |
---|---|
Type | Description |
boolean |
isEmulatePgClassTables()
public boolean isEmulatePgClassTables()
Returns the current setting for replacing pg_class tables with common table expressions that use the object name as OID.
Returns | |
---|---|
Type | Description |
boolean |
isForceAutocommit()
public boolean isForceAutocommit()
Returns whether transaction statements should be ignored and all statements should be executed in autocommit mode.
Returns | |
---|---|
Type | Description |
boolean |
isReplaceForUpdateClause()
public boolean isReplaceForUpdateClause()
Returns whether FOR UPDATE
clauses will automatically be replaced with a
LOCK_SCANNED_RANGES=exclusive hint. These statements are sometimes generated by ORMs, like for
example Hibernate.
This method will be removed in the future.
Returns | |
---|---|
Type | Description |
boolean |
isReplacePgCatalogTables()
public boolean isReplacePgCatalogTables()
Returns the current setting for replacing pg_catalog tables with common table expressions.
Returns | |
---|---|
Type | Description |
boolean |
isSupportDropCascade()
public boolean isSupportDropCascade()
Returns whether DROP ... CASCADE statements are supported. This also includes implicit cascading operations, such as dropping indexes of tables that are being dropped.
Returns | |
---|---|
Type | Description |
boolean |
resetAll()
public void resetAll()
Resets all values to their 'reset' value.
rollback()
public void rollback()
Rolls back the current transaction and abandons any pending changes to the settings.
set(String extension, String name, String setting)
public void set(String extension, String name, String setting)
Sets the value of the specified setting. The new value will be persisted if the current transaction is committed. The value will be lost if the transaction is rolled back.
Parameters | |
---|---|
Name | Description |
extension | String |
name | String |
setting | String |
setConnectionStartupValue(String extension, String name, String value)
public void setConnectionStartupValue(String extension, String name, String value)
Sets the value of the specified setting at connection startup.
Parameters | |
---|---|
Name | Description |
extension | String |
name | String |
value | String |
setLocal(String extension, String name, String setting)
public void setLocal(String extension, String name, String setting)
Sets the value of the specified setting for the current transaction. This value is lost when the transaction is committed or rolled back.
Parameters | |
---|---|
Name | Description |
extension | String |
name | String |
setting | String |
tryGet(String extension, String name)
public PGSetting tryGet(String extension, String name)
Returns the current value of the specified setting or null if undefined.
Parameters | |
---|---|
Name | Description |
extension | String |
name | String |
Returns | |
---|---|
Type | Description |
PGSetting |