Skip to content

Commit bec6c12

Browse files
authored
Allow Nowait and lock retry count in PostgreSQL without using savepoints. (#941)
Issue 203358
1 parent cfd886a commit bec6c12

File tree

3 files changed

+6
-23
lines changed

3 files changed

+6
-23
lines changed

java/src/main/java/com/genexus/db/DataStoreProvider.java

Lines changed: 0 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -274,9 +274,7 @@ private void execute(int cursorIdx, Object[] parms, boolean preExecute)
274274
cursor.status = 0;
275275
try
276276
{
277-
executeSavePointOperation("SAVEPOINT gxselectforupdate", cursor);
278277
cursor.postExecute(this, getDataSource());
279-
executeSavePointOperation("RELEASE SAVEPOINT gxselectforupdate", cursor);
280278
}
281279
catch (SQLException e)
282280
{
@@ -346,7 +344,6 @@ private void execute(int cursorIdx, Object[] parms, boolean preExecute)
346344
{
347345
}
348346
}
349-
executeSavePointOperation("ROLLBACK TO SAVEPOINT gxselectforupdate", cursor);
350347
}
351348
}
352349
retryCount = retryCount + 1;
@@ -432,23 +429,6 @@ private void setParameters(int cursorIdx, Object[] parms, Cursor cursor,
432429
}
433430
}
434431

435-
436-
private void executeSavePointOperation(String operation, Cursor cursor)
437-
{
438-
if (getDataSource().dbms.getId() == GXDBMS.DBMS_POSTGRESQL && GXutil.dbmsVersion( context, remoteHandle, getDataSource().name) > 7 && cursor instanceof ForEachCursor && cursor.isCurrentOf())
439-
{
440-
try
441-
{
442-
SentenceProvider.executeStatement(this, operation);
443-
}
444-
catch (Exception ex)
445-
{
446-
System.err.println(operation + " error " + ex.getMessage());
447-
ex.printStackTrace();
448-
}
449-
}
450-
}
451-
452432
static Object lock = new Object();
453433

454434
public void readNext(int cursorIdx)

java/src/main/java/com/genexus/db/DefaultExceptionErrorHandler.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,8 @@ public static void handleSQLError1(IErrorHandler errorHandler, SQLException e, M
3939
}
4040
if (!context.inErrorHandler)
4141
{
42+
if (e.getCause() != null && e.getCause() instanceof SQLException)
43+
e = ((SQLException)e.getCause());
4244
if (errorHandler != null)
4345
{
4446
context.globals.Gx_err = (short) cursor.status;

java/src/main/java/com/genexus/db/driver/GXDBMSpostgresql.java

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -96,9 +96,10 @@ public boolean DuplicateKeyValue(SQLException e)
9696
public boolean ObjectLocked(SQLException e)
9797
{
9898
String sqlstate = e.getSQLState().toLowerCase();
99-
if (sqlstate.indexOf("55p03")>=0)
100-
return true;
101-
return false;
99+
String sqlstateCause = "";
100+
if (e.getCause() != null && e.getCause() instanceof SQLException)
101+
sqlstateCause = ((SQLException)e.getCause()).getSQLState().toLowerCase();
102+
return sqlstate.contains("55p03") || sqlstateCause.contains("55p03");
102103
}
103104

104105
public boolean ObjectNotFound(SQLException e)

0 commit comments

Comments
 (0)