impossibl / pgjdbc-ng

A new JDBC driver for PostgreSQL aimed at supporting the advanced features of JDBC and Postgres
https://impossibl.github.io/pgjdbc-ng
Other
600 stars 107 forks source link

Syntax Error with Statement.RETURN_GENERATED_KEYS #594

Open dwenking opened 10 months ago

dwenking commented 10 months ago

In the provided test case, a CREATE TABLE SQL statement is executed using stmt.executeUpdate(createTableSql, Statement.RETURN_GENERATED_KEYS). This execution unexpectedly results in a syntax error: "syntax error at or near 'RETURNING'". This behavior is inconsistent with Postgres JDBC.

@Test
public void test() {
    try (Connection con = DriverManager.getConnection("jdbc:pgsql://localhost:5432/test0", "user", "password")) {
        Statement stmt = con.createStatement();
        String createTableSql = "CREATE TABLE table0_0(id INT PRIMARY KEY, value VARCHAR(5));";
        stmt.executeUpdate(createTableSql, Statement.RETURN_GENERATED_KEYS);
    } catch (SQLException e) {
        e.printStackTrace(); // syntax error at or near "RETURNING"
    }
}