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

fix: fix testGetSQLTypeQueryCache by searching for xid type. #2805

Merged
merged 9 commits into from
Feb 15, 2023
2 changes: 1 addition & 1 deletion .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ on:
- '.travis/**'
pull_request:
branches:
- '*'
- '**'
paths-ignore:
- 'docs/**'
- '**/*.md'
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ You can search on The Central Repository with GroupId and ArtifactId [org.postgr
[mvn-search]: https://search.maven.org/artifact/org.postgresql/postgresql "Search on Maven Central"

#### Development snapshots
Snapshot builds (builds from `master` branch) are also deployed to OSS Sonatype Snapshot Repository, so you can test current development version (test some bugfix) by enabling the repository and using the latest [SNAPSHOT](https://oss.sonatype.org/content/repositories/snapshots/org/postgresql/postgresql/maven-metadata.xml) version.
Snapshot builds (builds from `master` branch) are also deployed to OSS Sonatype Snapshot Repository, so you can test current development version (test some bugfix) by enabling the repository and using the latest [SNAPSHOT](https://oss.sonatype.org/content/repositories/snapshots/org/postgresql/postgresql/) version.

There are also available (snapshot) binary RPMs in [Fedora's Copr repository](https://copr.fedorainfracloud.org/coprs/g/pgjdbc/pgjdbc-travis/).

Expand Down
2 changes: 1 addition & 1 deletion docs/content/changelogs/2021-12-22-log4j.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
---
title: PostgreSQL JDBC Driver Log4j CVE status
date: 2021-12-22 20:32:25 +0000
version: all
version: Log4J CVE Notice
---

#### CVE-2021-44228 status
Expand Down
2 changes: 1 addition & 1 deletion docs/content/changelogs/2022-08-24-42.5.0-release.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,4 @@ float now aliases to float8 [PR #2598](https://github.com/pgjdbc/pgjdbc/pull/259

Dave Cramer (5):

fix: revert change in [PR 2597](https://github.com/pgjdbc/pgjdbc/pull/2597) where float was aliased to float4 from float8. float now aliases to float8 (#2598)
- fix: revert change in [PR 2597](https://github.com/pgjdbc/pgjdbc/pull/2597) where float was aliased to float4 from float8. float now aliases to float8 (#2598)
35 changes: 17 additions & 18 deletions docs/content/changelogs/2022-11-23-42.5.1-release.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ categories:
- new_release
version: 42.5.1
---
**Notable changes**

### Security
- security: StreamWrapper spills to disk if setText, or setBytea sends very large Strings or arrays to the server. createTempFile creates a file which can be read by other users on unix like systems (Not macos).\
Expand All @@ -28,37 +27,37 @@ This has been fixed in versions 42.5.1, 42.4.3 42.3.8, 42.2.27.jre7.\
**Commits by author**

Dave Cramer (13):
Update README.md [PR 2609](https://github.com/pgjdbc/pgjdbc/pull/2609)\
Ignore simplequery for postgresql 8.4 [PR 2614](https://github.com/pgjdbc/pgjdbc/pull/2614)\
Single commit to move newdocs into master [PR 2618](https://github.com/pgjdbc/pgjdbc/pull/2618)\
update versions [PR 2619](https://github.com/pgjdbc/pgjdbc/pull/2619)\
fix grammar, fix downloads, minor edits [PR 2626](https://github.com/pgjdbc/pgjdbc/pull/2626)\
fix: make sure we select array_in from pg_catalog to avoid duplicate array_in functions fixes #Issue 2548 [PR 2552](https://github.com/pgjdbc/pgjdbc/pull/2552)\
clarify prepared statement usage [PR 2629](https://github.com/pgjdbc/pgjdbc/pull/2629)\
fix maven coordinates [PR 2631](https://github.com/pgjdbc/pgjdbc/pull/2631)\
remove javadoc links for java 17 and above [PR 2637](https://github.com/pgjdbc/pgjdbc/pull/2637)\
revert change to PGProperty.get() to keep the API the same [PR 2644](https://github.com/pgjdbc/pgjdbc/pull/2644)\
exclude ArrayTest versions less than 9.1 [PR 2645](https://github.com/pgjdbc/pgjdbc/pull/2645)\
- Update README.md [PR 2609](https://github.com/pgjdbc/pgjdbc/pull/2609)
- Ignore simplequery for postgresql 8.4 [PR 2614](https://github.com/pgjdbc/pgjdbc/pull/2614)
- Single commit to move newdocs into master [PR 2618](https://github.com/pgjdbc/pgjdbc/pull/2618)
- update versions [PR 2619](https://github.com/pgjdbc/pgjdbc/pull/2619)
- fix grammar, fix downloads, minor edits [PR 2626](https://github.com/pgjdbc/pgjdbc/pull/2626)
- fix: make sure we select array_in from pg_catalog to avoid duplicate array_in functions fixes #Issue 2548 [PR 2552](https://github.com/pgjdbc/pgjdbc/pull/2552)
- clarify prepared statement usage [PR 2629](https://github.com/pgjdbc/pgjdbc/pull/2629)
- fix maven coordinates [PR 2631](https://github.com/pgjdbc/pgjdbc/pull/2631)
- remove javadoc links for java 17 and above [PR 2637](https://github.com/pgjdbc/pgjdbc/pull/2637)
- revert change to PGProperty.get() to keep the API the same [PR 2644](https://github.com/pgjdbc/pgjdbc/pull/2644)
- exclude ArrayTest versions less than 9.1 [PR 2645](https://github.com/pgjdbc/pgjdbc/pull/2645)

Evgeniy Devyatykh (1):
perf: improve performance of PgResultSet getByte/getShort/getInt/getLong for float-typed columns [PR 2634](https://github.com/pgjdbc/pgjdbc/pull/2634)
- perf: improve performance of PgResultSet getByte/getShort/getInt/getLong for float-typed columns [PR 2634](https://github.com/pgjdbc/pgjdbc/pull/2634)

Josh Soref (1):
chore: fix various spelling errors [PR 2592](https://github.com/pgjdbc/pgjdbc/pull/2592)
- chore: fix various spelling errors [PR 2592](https://github.com/pgjdbc/pgjdbc/pull/2592)

Kevin222004 (1):

Knut Olav Løite (1):
fix: binary decoding of bool values [PR 2640](https://github.com/pgjdbc/pgjdbc/pull/2640)
- fix: binary decoding of bool values [PR 2640](https://github.com/pgjdbc/pgjdbc/pull/2640)

Marek Läll (1):
Feature/urlparser improve3 pr1 [PR 2641](https://github.com/pgjdbc/pgjdbc/pull/2641)
- Feature/urlparser improve3 pr1 [PR 2641](https://github.com/pgjdbc/pgjdbc/pull/2641)

Vladimir Sitnikov (4):
docs: clarify we ship security fixes by default for the latest 42.x and 42.2 only [PR 2586](https://github.com/pgjdbc/pgjdbc/pull/2586)
- docs: clarify we ship security fixes by default for the latest 42.x and 42.2 only [PR 2586](https://github.com/pgjdbc/pgjdbc/pull/2586)

μtkarsh (1):
Optimize png files [PR 2621](https://github.com/pgjdbc/pgjdbc/pull/2621)
- Optimize png files [PR 2621](https://github.com/pgjdbc/pgjdbc/pull/2621)



10 changes: 8 additions & 2 deletions docs/content/changelogs/2023-01-31-42.5.2-release.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,8 @@ fix: improve thread safety of PgResultSet#getTimestamp [PR #2726](https://github
**Commits by author**

Dave Cramer (2):
- fix: binary conversion of (very) long numeric values (longer than 4 * 2^15 digits) [PR #2697](https://github.com/pgjdbc/pgjdbc/pull/2697)
- fix: Apply patch from [Issue #2683](https://github.com/pgjdbc/pgjdbc/issues/2683) provided by James Courtney to fix hanging ssl connections [PR #2687](https://github.com/pgjdbc/pgjdbc/pull/2687)
- fix: binary conversion of (very) long numeric values (longer than 4 * 2^15 digits) [PR #2697](https://github.com/pgjdbc/pgjdbc/pull/2697)\
- fix: Apply patch from [Issue #2683](https://github.com/pgjdbc/pgjdbc/issues/2683) provided by James Courtney to fix hanging ssl connections [PR #2687](https://github.com/pgjdbc/pgjdbc/pull/2687)\
- fix: Make sure socket is closed if an exception is thrown in createSocket fixes [Issue #2684](https://github.com/pgjdbc/pgjdbc/issues/2684) [PR #2685](https://github.com/pgjdbc/pgjdbc/pull/2685)

Sebastian Baumhekel(1): <sebastian.baumhekel@gmail.com>
Expand All @@ -41,3 +41,9 @@ Sebastian Baumhekel(1): <sebastian.baumhekel@gmail.com>
sz-liva(1):
- fix: improve thread safety of PgResultSet#getTimestamp [PR #2726](https://github.com/pgjdbc/pgjdbc/pull/2726) fixes [Issue #2723](https://github.com/pgjdbc/pgjdbc/issues/2723)

Sebastian Baumhekel(1): <sebastian.baumhekel@gmail.com>
- feat: Define binary transfer for custom types dynamically/automatically fixes [Issue #2554](https://github.com/pgjdbc/pgjdbc/issues/2554) [PR #2556](https://github.com/pgjdbc/pgjdbc/pull/2556)

sz-liva(1):
- fix: improve thread safety of PgResultSet#getTimestamp [PR #2726](https://github.com/pgjdbc/pgjdbc/pull/2726) fixes [Issue #2723](https://github.com/pgjdbc/pgjdbc/issues/2723)

2 changes: 1 addition & 1 deletion docs/content/development/_index.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ The following tools are required to build and test the driver:

## Build Process

After retrieving the source from the [git repository](https://github.com/pgjdbc/pgjdbc). Move into the top level `pgjdbc` directory and simply type `./gradlew build -DskipTests` . This will build the driver and place it into `pgjdbc/build/distributions/postgresql-${version}.jar` .
After retrieving the source from the [git repository](https://github.com/pgjdbc/pgjdbc). Move into the top level `pgjdbc` directory and simply type `./gradlew build -x test` or `./gradlew assemble` . This will build the driver and place it into `pgjdbc/build/distributions/postgresql-${version}.jar` .

## Test Suite

Expand Down
94 changes: 77 additions & 17 deletions docs/content/documentation/server-prepare.md
Original file line number Diff line number Diff line change
Expand Up @@ -412,29 +412,28 @@ import java.sql.*;
public class ServerSidePreparedStatement {

public static void main(String args[]) throws Exception {
Class.forName("org.postgresql.Driver");

String url = "jdbc:postgresql://localhost:5432/test";
Connection conn = DriverManager.getConnection(url, "test", "");
try (Connection conn = DriverManager.getConnection(url, "test", "")){

PreparedStatement pstmt = conn.prepareStatement("SELECT ?");
try (PreparedStatement pstmt = conn.prepareStatement("SELECT ?")){

// cast to the pg extension interface
org.postgresql.PGStatement pgstmt = pstmt.unwrap(org.postgresql.PGStatement.class);
// cast to the pg extension interface
org.postgresql.PGStatement pgstmt = pstmt.unwrap(org.postgresql.PGStatement.class);

// on the third execution start using server side statements
pgstmt.setPrepareThreshold(3);
// on the third execution start using server side statements
pgstmt.setPrepareThreshold(3);

for (int i = 1; i <= 5; i++) {
pstmt.setInt(1, i);
boolean usingServerPrepare = pgstmt.isUseServerPrepare();
ResultSet rs = pstmt.executeQuery();
rs.next();
System.out.println("Execution: " + i + ", Used server side: " + usingServerPrepare + ", Result: " + rs.getInt(1));
rs.close();
for (int i = 1; i <= 5; i++) {
pstmt.setInt(1, i);
boolean usingServerPrepare = pgstmt.isUseServerPrepare();
ResultSet rs = pstmt.executeQuery();
rs.next();
System.out.println("Execution: " + i + ", Used server side: " + usingServerPrepare + ", Result: " + rs.getInt(1));
rs.close();
}
}
}

pstmt.close();
conn.close();
}
}
```
Expand Down Expand Up @@ -916,3 +915,64 @@ The following types of arrays support binary representation in requests and can
|`boolean[]` , `Boolean[]` | `bool[]` | `bool[]`|
|`String[]` | `varchar[]` , `text[]` | `varchar[]`|
|`byte[][]` | `bytea[]` | `bytea[]`|


## CopyManager
The driver provides an extension for accessing `COPY`. Copy is an extension that PostreSQL provides. see [Copy](https://www.postgresql.org/docs/current/sql-copy.html)

#### Example 9.15 Copying Data in
```java

/*
* DDL for code below
* create table copytest (stringvalue text, intvalue int, numvalue numeric(5,2));
*/
private static String[] origData =
{"First Row\t1\t1.10\n",
"Second Row\t2\t-22.20\n",
"\\N\t\\N\t\\N\n",
"\t4\t444.40\n"};
private int dataRows = origData.length;
private String sql = "COPY copytest FROM STDIN";

try (Connection con = DriverManager.getConnection(url, "postgres", "somepassword")){
createTempTable(con, "copytest", "stringvalue text, intvalue int, numvalue numeric(5,2)");
PGConnection pgConnection = con.unwrap(org.postgresql.PGConnection.class);
CopyManager copyAPI = pgConnection.getCopyAPI();
CopyIn cp = copyAPI.copyIn(sql);

for (String anOrigData : origData) {
byte[] buf = anOrigData.getBytes();
cp.writeToCopy(buf, 0, buf.length);
}

long updatedRows = cp.endCopy();
long handledRowCount = cp.getHandledRowCount();
System.err.println(String.format("copy Updated %d Rows, and handled %d rows", updatedRows, handledRowCount));

int rowCount = getCount(con);
System.err.println(rowCount);

}

```

#### Example 9.16 Copying Data out

```java
String sql = "COPY copytest TO STDOUT";
try (Connection con = DriverManager.getConnection(url, "postgres", "somepassword")){
PGConnection pgConnection = con.unwrap(org.postgresql.PGConnection.class);
CopyManager copyAPI = pgConnection.getCopyAPI();
CopyOut cp = copyAPI.copyOut(sql);
int count = 0;
byte[] buf; // This is a relatively simple example. buf will contain rows from the database

while ((buf = cp.readFromCopy()) != null) {
count++;
}
long rowCount = cp.getHandledRowCount();
}
```

More examples can be found in the [Copy Test Code](https://github.com/pgjdbc/pgjdbc/blob/master/pgjdbc/src/test/java/org/postgresql/test/jdbc2/CopyTest.java)
2 changes: 1 addition & 1 deletion docs/content/download/_index.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ date: 2022-06-20T01:17:28+05:30
draft: false
---

Binary JAR file downloads of the JDBC driver are available here and the current version with Maven Repository. Because Java is platform neutral, it is a simple process of just downloading the appropriate JAR file and dropping it into your classpath. Source versions are also available here for recent driver versions.
Binary JAR file downloads of the JDBC driver are available here and the current version with Maven Repository. Because Java is platform neutral, it is a simple process of just downloading the appropriate JAR file and dropping it into your classpath. Source versions are also available here for recent driver versions. Latest [SNAPSHOT](https://oss.sonatype.org/content/repositories/snapshots/org/postgresql/postgresql/) versions.

## Latest Versions

Expand Down
2 changes: 2 additions & 0 deletions docs/content/license/_index.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
title: "License"
date: 2022-06-19T22:46:55+05:30
draft: false
aliases:
- "/about/license.html"
---

Copyright (c) 1997, PostgreSQL Global Development Group
Expand Down
3 changes: 1 addition & 2 deletions docs/layouts/changelogs/list.html
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,7 @@ <h1>
{{ range .Data.Pages.ByDate.Reverse }}
<ul>
<li>
<h5>{{.Title}}</h5>
<a href="{{.Permalink}}"> NOTES</a>
<a href="{{.Permalink}}"> {{.Params.Version}}</a>
</li>
</ul>
{{ end }}
Expand Down
2 changes: 1 addition & 1 deletion docs/layouts/partials/site-footer.html
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,6 @@
{{ end }}
</div>
<div class="copyrights">
Copyright © 1996-2022 The PostgreSQL Global Development Group
Copyright © 1996-2023 The PostgreSQL Global Development Group
</div>
</footer>
Binary file added docs/static/images/slonik_duke.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ public class OidValuesCorrectnessTest extends BaseTest4 {
* Helps in situation when variable name in Oid class isn't the same as typname in pg_type table.
*/
private static Map<String, String> oidTypeNames = new HashMap<String, String>() {{
put("BOX_ARRAY", "_BOX");
put("INT2_ARRAY", "_INT2");
put("INT4_ARRAY", "_INT4");
put("INT8_ARRAY", "_INT8");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,11 +62,11 @@ public void testGetSQLTypeQueryCache() throws SQLException {
List<LogRecord> typeQueries = log.getRecordsMatching(SQL_TYPE_QUERY_LOG_FILTER);
assertEquals(0, typeQueries.size());

ti.getSQLType("box"); // this must be a type not in the hardcoded 'types' list
ti.getSQLType("xid"); // this must be a type not in the hardcoded 'types' list
typeQueries = log.getRecordsMatching(SQL_TYPE_QUERY_LOG_FILTER);
assertEquals(1, typeQueries.size());

ti.getSQLType("box"); // this time it should be retrieved from the cache
ti.getSQLType("xid"); // this time it should be retrieved from the cache
typeQueries = log.getRecordsMatching(SQL_TYPE_QUERY_LOG_FILTER);
assertEquals(1, typeQueries.size());
}
Expand Down