prepareStatement.executeUpdate(deleteQuery) returns 1 even when no data deleted.

Поиск
Список
Период
Сортировка
От pgsql-bugs@postgresql.org
Тема prepareStatement.executeUpdate(deleteQuery) returns 1 even when no data deleted.
Дата
Msg-id 200008291802.e7TI26h98836@hub.org
обсуждение исходный текст
Список pgsql-bugs
Samuel Minne (sminne@allis.fr) reports a bug with a severity of 2
The lower the number the more severe it is.

Short Description
prepareStatement.executeUpdate(deleteQuery) returns 1 even  when no data deleted.

Long Description
With a delete query, prepareStatement.executeUpdate() should return the number of deleted rows.
It returns 1 even when no data were deleted by the query.
The prepareStatement.getUpdateCount() returns -1 before the call to executeUpdate(), and 1 after.
This problem was found by my regression test program, which insert its own data on tables. The same program works with
mysqland mm jdbc driver. 
I think the problem come from the jdbc driver.

Sample Code
    public synchronized boolean removeLink(Element doc,Integer tagId)
            throws SQLException, ElementNotSupportedException {
        boolean linkRemoved=true;
        if ( doc.getType() != Element.DOCUMENT) throw new ElementNotSupportedException();
        Document myDocument= (Document)doc;

        // Suppression du lien existant
        StringBuffer query=new StringBuffer();
        query.append("delete from lien_sequence");
        query.append(" where doc_id=?" );
        query.append(" and tag_id=?" );
//System.out.println("Docid "+myDocument.id + ": Tag "+tagId.intValue());

        Connection con= myConnectionPoolManager.requestConnection(myUpdateConnectionPool);
        PreparedStatement myPreparedStatement= con.prepareStatement(query.toString());
        myPreparedStatement.setInt(1,myDocument.id);
        myPreparedStatement.setObject(2,tagId); // Gère la valeur NULL de l'Integer
//System.out.println("Query "+query.toString());

        if (myPreparedStatement.executeUpdate() != 1) linkRemoved= false;
//System.out.println("updatecount=" +myPreparedStatement.getUpdateCount());
//System.out.println("updatecount=" +myPreparedStatement.executeUpdate());
//System.out.println("updatecount=" +myPreparedStatement.getUpdateCount());
//System.exit(-1);
        myConnectionPoolManager.closeStatement(myPreparedStatement);
        myConnectionPoolManager.returnConnection(myUpdateConnectionPool,con);
//System.out.println("Docid "+myDocument.id + ": Tag "+tagId.intValue());
//System.out.println("Result "+linkRemoved);

        return linkRemoved;
    }

No file was uploaded with this report

В списке pgsql-bugs по дате отправления:

Предыдущее
От: pgsql-bugs@postgresql.org
Дата:
Сообщение: Callable Statements are not supported at this time.
Следующее
От: pgsql-bugs@postgresql.org
Дата:
Сообщение: initdb -t trashes the entire database system