Skip to content

Commit 25b7753

Browse files
committed
Allow Nowait and lock retry count in PostgreSQL without using savepoints. (#941)
Issue 203358 (cherry picked from commit bec6c12)
1 parent 5387e77 commit 25b7753

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
@@ -272,9 +272,7 @@ private void execute(int cursorIdx, Object[] parms, boolean preExecute)
272272
cursor.status = 0;
273273
try
274274
{
275-
executeSavePointOperation("SAVEPOINT gxselectforupdate", cursor);
276275
cursor.postExecute(this, getDataSource());
277-
executeSavePointOperation("RELEASE SAVEPOINT gxselectforupdate", cursor);
278276
}
279277
catch (SQLException e)
280278
{
@@ -344,7 +342,6 @@ private void execute(int cursorIdx, Object[] parms, boolean preExecute)
344342
{
345343
}
346344
}
347-
executeSavePointOperation("ROLLBACK TO SAVEPOINT gxselectforupdate", cursor);
348345
}
349346
}
350347
retryCount = retryCount + 1;
@@ -430,23 +427,6 @@ private void setParameters(int cursorIdx, Object[] parms, Cursor cursor,
430427
}
431428
}
432429

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

452432
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)