transaction savepoint q:
# lucee
d
transaction savepoint q:
I have a transaction savepoint that Lucee gladly accepts and then immediately forgets about:
Copy code
transaction {
    transaction action="setSavePoint" savepoint="SOME_SAVEPOINT_NAME";
    queryExecute("select 42")
    // There are no savepoint with name [some_savepoint_name] set
    transaction action="rollback" savepoint="SOME_SAVEPOINT_NAME"; 
}
It is unfortunate because it works fine inside some coldbox tests we've got, but then on contact with the real world it flops over. It looks somewhat related to https://luceeserver.atlassian.net/browse/LDEV-3657 ("savepoints not supported on ORM transactions") ... If it is "orm" related, is there a way to: • know if I'm in an ORM transaction? • commit/cancel/tear-down/etc. the ORM transaction if inside one?
in DataSourceManagerImpl.java we early return when setting the savepoint
Copy code
// FUTURE
	public void savepoint(String savePointName) throws DatabaseException {
		if (autoCommit || _size() == 0) return;
autoCommit
is false
_size()
is
0
so we bail
Copy code
private int _size() {
	return /*0*/ transConnsORM.size() + /*0*/ transConnsReg.size();
}
but why
Copy code
transaction {
	queryExecute("select 42") // prime the pump
	transaction action="setSavePoint" savepoint="SOME_SAVEPOINT_NAME";
	queryExecute("select 42")
	transaction action="rollback" savepoint="SOME_SAVEPOINT_NAME";
}
now
Copy code
private int _size() {
	return /*0*/ transConnsORM.size() + /*1*/ transConnsReg.size();
}
so that works, but it seems unfortunate that it's necessary
don't know if it works for real but in a contrived test it does anyway
well kudos to the team for making it easy to checkout the specific version via git tag and have
ant fast
work no problem.