Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

build(deps): bump org.postgresql:postgresql from 42.7.4 to 42.7.5 #2750

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@
<dependency>
<groupId>org.postgresql</groupId>
<artifactId>postgresql</artifactId>
<version>42.7.4</version>
<version>42.7.5</version>
</dependency>
<dependency>
<groupId>com.kohlschutter.junixsocket</groupId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,10 +45,18 @@ static String replaceJdbcMetadataStatement(String sql) {
// with Spangres-compatible queries.
if (sql.startsWith(PgJdbcCatalog.PG_JDBC_EXPORTED_IMPORTED_KEYS_PREFIX)
|| sql.startsWith(PgJdbcCatalog.PG_JDBC_EXPORTED_IMPORTED_KEYS_42_0_PREFIX)) {
return replaceImportedExportedKeysQuery(sql);
return replaceImportedExportedKeysQuery(
sql, PgJdbcCatalog.PG_JDBC_EXPORTED_IMPORTED_KEYS_REPLACEMENT, "KEY_SEQ");
}
if (sql.startsWith(PgJdbcCatalog.PG_JDBC_EXPORTED_IMPORTED_KEYS_PREFIX_V42_7_5)) {
return replaceImportedExportedKeysQuery(
sql, PgJdbcCatalog.PG_JDBC_EXPORTED_IMPORTED_KEYS_REPLACEMENT_UPPER_CASE, "\"KEY_SEQ\"");
}
if (sql.startsWith(PgJdbcCatalog.PG_JDBC_GET_SCHEMAS_PREFIX)) {
return replaceGetSchemasQuery(sql);
return replaceGetSchemasQuery(sql, PgJdbcCatalog.PG_JDBC_GET_SCHEMAS_REPLACEMENT);
}
if (sql.startsWith(PgJdbcCatalog.PG_JDBC_GET_SCHEMAS_PREFIX_V42_7_5)) {
return replaceGetSchemasQuery(sql, PgJdbcCatalog.PG_JDBC_GET_SCHEMAS_REPLACEMENT_UPPER_CASE);
}
if (sql.contains(LiquibaseStatementHelper.TAG_STATEMENT_PART)) {
return LiquibaseStatementHelper.replaceTagStatement(sql);
Expand All @@ -65,10 +73,16 @@ static String replaceJdbcMetadataStatement(String sql) {
|| sql.startsWith(PgJdbcCatalog.PG_JDBC_GET_TABLES_PREFIX_5)
|| sql.startsWith(PgJdbcCatalog.PG_JDBC_GET_TABLES_PREFIX_6)
|| sql.startsWith(PgJdbcCatalog.PG_JDBC_GET_TABLES_PREFIX_7)
|| sql.startsWith(PgJdbcCatalog.PG_JDBC_GET_TABLES_PREFIX_8)) {
return replaceGetTablesQuery(sql);
|| sql.startsWith(PgJdbcCatalog.PG_JDBC_GET_TABLES_PREFIX_8)
|| sql.startsWith(PgJdbcCatalog.PG_JDBC_GET_TABLES_PREFIX_9)) {
if (sql.startsWith(PgJdbcCatalog.PG_JDBC_GET_TABLES_PREFIX_9)) {
return replaceGetTablesQuery(sql, PgJdbcCatalog.PG_JDBC_GET_TABLES_REPLACEMENT_UPPER_CASE);
} else {
return replaceGetTablesQuery(sql, PgJdbcCatalog.PG_JDBC_GET_TABLES_REPLACEMENT);
}
}
if (sql.startsWith(PgJdbcCatalog.PG_JDBC_GET_COLUMNS_PREFIX_1)
if (sql.startsWith(PgJdbcCatalog.PG_JDBC_GET_COLUMNS_PREFIX_V42_7_5)
|| sql.startsWith(PgJdbcCatalog.PG_JDBC_GET_COLUMNS_PREFIX_1)
|| sql.startsWith(PgJdbcCatalog.PG_JDBC_GET_COLUMNS_PREFIX_2)
|| sql.startsWith(PgJdbcCatalog.PG_JDBC_GET_COLUMNS_PREFIX_3)
|| sql.startsWith(PgJdbcCatalog.PG_JDBC_GET_COLUMNS_PREFIX_4)
Expand All @@ -78,39 +92,49 @@ static String replaceJdbcMetadataStatement(String sql) {
|| sql.startsWith(PgJdbcCatalog.PG_JDBC_GET_COLUMNS_PREFIX_4_1)) {
return replaceGetColumnsQuery(sql);
}
if (sql.startsWith(PgJdbcCatalog.PG_JDBC_GET_INDEXES_PREFIX_1)
if (sql.startsWith(PgJdbcCatalog.PG_JDBC_GET_INDEXES_PREFIX_V42_7_5)
|| sql.startsWith(PgJdbcCatalog.PG_JDBC_GET_INDEXES_PREFIX_1)
|| sql.startsWith(PgJdbcCatalog.PG_JDBC_GET_INDEXES_PREFIX_2)
|| sql.startsWith(PgJdbcCatalog.PG_JDBC_GET_INDEXES_PREFIX_3)
|| sql.startsWith(PgJdbcCatalog.PG_JDBC_GET_INDEXES_PREFIX_1_1)) {
return replaceGetIndexInfoQuery(sql);
}
if (sql.startsWith(PgJdbcCatalog.PG_JDBC_GET_PRIMARY_KEY_PREFIX_1)
|| sql.startsWith(PgJdbcCatalog.PG_JDBC_GET_PRIMARY_KEY_PREFIX_2)) {
|| sql.startsWith(PgJdbcCatalog.PG_JDBC_GET_PRIMARY_KEY_PREFIX_2)
|| sql.startsWith(PgJdbcCatalog.PG_JDBC_GET_PRIMARY_KEY_PREFIX_V42_7_5)) {
return replaceGetPrimaryKeyQuery(sql);
}
if (sql.startsWith(PgJdbcCatalog.PG_JDBC_GET_TABLE_PRIVILEGES_PREFIX_1)
|| sql.startsWith(PgJdbcCatalog.PG_JDBC_GET_TABLE_PRIVILEGES_PREFIX_2)) {
|| sql.startsWith(PgJdbcCatalog.PG_JDBC_GET_TABLE_PRIVILEGES_PREFIX_2)
|| sql.startsWith(PgJdbcCatalog.PG_JDBC_GET_TABLE_PRIVILEGES_PREFIX_3)) {
return PgJdbcCatalog.PG_JDBC_GET_TABLE_PRIVILEGES_REPLACEMENT;
}
if (sql.startsWith(PgJdbcCatalog.PG_JDBC_GET_COLUMN_PRIVILEGES_PREFIX_1)
|| sql.startsWith(PgJdbcCatalog.PG_JDBC_GET_COLUMN_PRIVILEGES_PREFIX_1_1)) {
|| sql.startsWith(PgJdbcCatalog.PG_JDBC_GET_COLUMN_PRIVILEGES_PREFIX_1_1)
|| sql.startsWith(PgJdbcCatalog.PG_JDBC_GET_COLUMN_PRIVILEGES_PREFIX_V42_7_5)) {
return PgJdbcCatalog.PG_JDBC_GET_TABLE_PRIVILEGES_REPLACEMENT;
}
if (sql.startsWith(PgJdbcCatalog.PG_JDBC_BEST_ROW_IDENTIFIER_PREFIX)) {
return PgJdbcCatalog.PG_JDBC_GET_BEST_ROW_IDENTIFIER_REPLACEMENT;
}

if (sql.startsWith(PgJdbcCatalog.PG_JDBC_GET_FUNCTIONS_WITH_FUNC_TYPE_PREFIX)
|| sql.startsWith(PgJdbcCatalog.PG_JDBC_GET_FUNCTIONS_WITHOUT_FUNC_TYPE_PREFIX)) {
|| sql.startsWith(PgJdbcCatalog.PG_JDBC_GET_FUNCTIONS_WITHOUT_FUNC_TYPE_PREFIX)
|| sql.startsWith(PgJdbcCatalog.PG_JDBC_GET_FUNCTIONS_UPPER_CASE_PREFIX)) {
return PgJdbcCatalog.PG_JDBC_GET_FUNCTIONS_REPLACEMENT;
}
if (sql.startsWith(PgJdbcCatalog.PG_JDBC_GET_FUNCTION_COLUMNS_PREFIX)) {
if (sql.startsWith(PgJdbcCatalog.PG_JDBC_GET_FUNCTION_COLUMNS_PREFIX)
|| sql.startsWith(PgJdbcCatalog.PG_JDBC_GET_FUNCTION_COLUMNS_PREFIX_V42_7_5)) {
return PgJdbcCatalog.PG_JDBC_GET_FUNCTION_COLUMNS_REPLACEMENT;
}
if (sql.startsWith(PgJdbcCatalog.PG_JDBC_GET_PROCEDURES_PREFIX)) {
return PgJdbcCatalog.PG_JDBC_GET_PROCEDURES_REPLACEMENT;
}
if (sql.startsWith(PgJdbcCatalog.PG_JDBC_GET_UDTS_PREFIX)) {
if (sql.startsWith(PgJdbcCatalog.PG_JDBC_GET_PROCEDURES_PREFIX_V42_7_5)) {
return PgJdbcCatalog.PG_JDBC_GET_PROCEDURES_REPLACEMENT;
}
if (sql.startsWith(PgJdbcCatalog.PG_JDBC_GET_UDTS_PREFIX)
|| sql.startsWith(PgJdbcCatalog.PG_JDBC_GET_UDTS_PREFIX_V42_7_5)) {
return PgJdbcCatalog.PG_JDBC_GET_UDTS_REPLACEMENT;
}
if (sql.startsWith(PgJdbcCatalog.PG_JDBC_GET_MAX_NAME_LENGTH_PREFIX)) {
Expand Down Expand Up @@ -204,8 +228,7 @@ private static String replacePG42_3_PkQuery_With_42_2_Query(String sql) {
return replacedSql + whereClause + " ORDER BY ct.relname, pk_name, key_seq";
}

private static String replaceGetSchemasQuery(String sql) {
String replacedSql = PgJdbcCatalog.PG_JDBC_GET_SCHEMAS_REPLACEMENT;
private static String replaceGetSchemasQuery(String sql, String replacedSql) {
int startIndex;
if (sql.contains(" AND nspname LIKE ")) {
startIndex = sql.indexOf(" AND nspname LIKE ");
Expand All @@ -218,8 +241,7 @@ private static String replaceGetSchemasQuery(String sql) {
.replace(" ORDER BY TABLE_SCHEM", " ORDER BY schema_name");
}

private static String replaceGetTablesQuery(String sql) {
String replacedSql = PgJdbcCatalog.PG_JDBC_GET_TABLES_REPLACEMENT;
private static String replaceGetTablesQuery(String sql, String replacedSql) {
int startIndex;
String wherePrefix = "WHERE c.relnamespace = n.oid";
if (sql.contains(wherePrefix)) {
Expand Down Expand Up @@ -344,6 +366,9 @@ private static String replaceGetIndexInfoQuery(String sql) {
.replace(" AND n.nspname = ", " AND IDX.TABLE_SCHEMA = ")
.replace(" AND ct.relname = ", " AND IDX.TABLE_NAME = ")
.replace(" AND i.indisunique ", " AND IDX.IS_UNIQUE='YES' ")
.replace(
") AS tmp ORDER BY \"NON_UNIQUE\", \"TYPE\", \"INDEX_NAME\", \"ORDINAL_POSITION\"",
" ORDER BY IDX.TABLE_NAME, IS_UNIQUE DESC, IDX.INDEX_NAME, CASE WHEN ORDINAL_POSITION IS NULL THEN 0 ELSE ORDINAL_POSITION END")
.replace(
") AS tmp ORDER BY NON_UNIQUE, TYPE, INDEX_NAME, ORDINAL_POSITION",
" ORDER BY IDX.TABLE_NAME, IS_UNIQUE DESC, IDX.INDEX_NAME, CASE WHEN ORDINAL_POSITION IS NULL THEN 0 ELSE ORDINAL_POSITION END")
Expand All @@ -364,6 +389,7 @@ private static String replaceGetPrimaryKeyQuery(String sql) {
replacedSql += " WHERE TRUE " + sql.substring(startIndex);
return replacedSql
.replace(") result where result.A_ATTNUM = (result.KEYS).x", "")
.replace("AND result.KEY_SEQ <= KEY_COUNT", "")
.replace(" AND n.nspname = ", " AND IDX.TABLE_SCHEMA = ")
.replace(" AND ct.relname = ", " AND IDX.TABLE_NAME = ")
.replace(" AND i.indisprimary ", " AND IDX.INDEX_TYPE='PRIMARY_KEY' ")
Expand All @@ -375,8 +401,8 @@ private static String replaceGetPrimaryKeyQuery(String sql) {
"ORDER BY COLS.TABLE_NAME, IDX.INDEX_NAME, COLS.ORDINAL_POSITION");
}

private static String replaceImportedExportedKeysQuery(String sql) {
String replacedSql = PgJdbcCatalog.PG_JDBC_EXPORTED_IMPORTED_KEYS_REPLACEMENT;
private static String replaceImportedExportedKeysQuery(
String sql, String replacedSql, String keySeq) {
int startIndex;
if (sql.contains(" AND pkn.nspname = ")) {
startIndex = sql.indexOf(" AND pkn.nspname = ");
Expand All @@ -397,9 +423,9 @@ private static String replaceImportedExportedKeysQuery(String sql) {
.replace(" AND fkc.relname = ", " AND CHILD.TABLE_NAME = ")
.replace(
" ORDER BY fkn.nspname,fkc.relname,con.conname,pos.n",
" ORDER BY CHILD.TABLE_CATALOG, CHILD.TABLE_SCHEMA, CHILD.TABLE_NAME, KEY_SEQ")
" ORDER BY CHILD.TABLE_CATALOG, CHILD.TABLE_SCHEMA, CHILD.TABLE_NAME, " + keySeq)
.replace(
" ORDER BY pkn.nspname,pkc.relname, con.conname,pos.n",
" ORDER BY PARENT.TABLE_CATALOG, PARENT.TABLE_SCHEMA, PARENT.TABLE_NAME, KEY_SEQ");
" ORDER BY PARENT.TABLE_CATALOG, PARENT.TABLE_SCHEMA, PARENT.TABLE_NAME, " + keySeq);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,9 @@
import java.util.List;
import java.util.Locale;
import java.util.Map;
import java.util.Objects;
import java.util.concurrent.atomic.AtomicBoolean;
import java.util.concurrent.atomic.AtomicReference;
import java.util.regex.Pattern;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
Expand All @@ -71,6 +73,11 @@ public class ClientAutoDetector {
public static final String PGBENCH_USAGE_HINT =
"See https://github.com/GoogleCloudPlatform/pgadapter/blob/-/docs/pgbench.md for how to use pgbench with PGAdapter";

/** Force the detector to return this client. This should only be used for testing. */
@VisibleForTesting
public static final AtomicReference<WellKnownClient> FORCE_DETECT_CLIENT =
new AtomicReference<>();

public enum WellKnownClient {
PSQL {

Expand Down Expand Up @@ -665,6 +672,9 @@ public ImmutableMap<String, String> getDefaultParameters(Map<String, String> par
public static @Nonnull WellKnownClient detectClient(
List<String> orderParameterKeys, Map<String, String> parameters) {
for (WellKnownClient client : WellKnownClient.values()) {
if (Objects.equals(client, FORCE_DETECT_CLIENT.get())) {
return client;
}
if (client.isClient(orderParameterKeys, parameters)) {
return client;
}
Expand Down
Loading
Loading