Skip to content

Commit

Permalink
Revert "fix: fix testGetSQLTypeQueryCache by searching for xid type. (#…
Browse files Browse the repository at this point in the history
…2805)" (#2807)

This reverts commit fad8664.
  • Loading branch information
davecramer committed Feb 15, 2023
1 parent fad8664 commit 9980a95
Show file tree
Hide file tree
Showing 11 changed files with 27 additions and 95 deletions.
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/) 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/maven-metadata.xml) 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: Log4J CVE Notice
version: all
---

#### CVE-2021-44228 status
Expand Down
10 changes: 2 additions & 8 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,9 +41,3 @@ 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)

94 changes: 17 additions & 77 deletions docs/content/documentation/server-prepare.md
Original file line number Diff line number Diff line change
Expand Up @@ -412,28 +412,29 @@ 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";
try (Connection conn = DriverManager.getConnection(url, "test", "")){
Connection conn = DriverManager.getConnection(url, "test", "");

try (PreparedStatement pstmt = conn.prepareStatement("SELECT ?")){
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 @@ -915,64 +916,3 @@ 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. Latest [SNAPSHOT](https://oss.sonatype.org/content/repositories/snapshots/org/postgresql/postgresql/) 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 Versions

Expand Down
2 changes: 0 additions & 2 deletions docs/content/license/_index.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@
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: 2 additions & 1 deletion docs/layouts/changelogs/list.html
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@ <h1>
{{ range .Data.Pages.ByDate.Reverse }}
<ul>
<li>
<a href="{{.Permalink}}"> {{.Params.Version}}</a>
<h5>{{.Title}}</h5>
<a href="{{.Permalink}}"> NOTES</a>
</li>
</ul>
{{ end }}
Expand Down
Binary file removed docs/static/images/slonik_duke.png
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,6 @@ 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("xid"); // this must be a type not in the hardcoded 'types' list
ti.getSQLType("box"); // 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("xid"); // this time it should be retrieved from the cache
ti.getSQLType("box"); // this time it should be retrieved from the cache
typeQueries = log.getRecordsMatching(SQL_TYPE_QUERY_LOG_FILTER);
assertEquals(1, typeQueries.size());
}
Expand Down

0 comments on commit 9980a95

Please sign in to comment.