Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
D
dbase
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
FairDb
dbase
Commits
9ebc00cf
Commit
9ebc00cf
authored
7 years ago
by
Evgeny Lavrik
Browse files
Options
Downloads
Patches
Plain Diff
Update FairDbRelationalParSet<T>::AllocateNextId
parent
29a71003
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
dbInterface/FairDbRelationalParSet.tpl
+18
-18
18 additions, 18 deletions
dbInterface/FairDbRelationalParSet.tpl
with
18 additions
and
18 deletions
dbInterface/FairDbRelationalParSet.tpl
+
18
−
18
View file @
9ebc00cf
...
...
@@ -74,38 +74,38 @@ void FairDbRelationalParSet<T>::PurgeCache()
template
<typename
T
>
Int_t FairDbRelationalParSet
<T>
::AllocateNextId()
{
FairDbString sql;
// needs to be uppercase
std::string tableName = this->GetTableName();
bool tableExists = this->fMultConn->TableExists(tableName, this->fDbEntry);
if ( ! tableExists ) { return 0; }
auto_ptr
<FairDbStatement>
stmtDb(this->fMultConn->CreateStatement(this->fDbEntry) );
if ( ! stmtDb.get() ) { return 0; }
if (!tableExists) {
return -1;
}
std::unique_ptr
<FairDbStatement>
statement(this->fMultConn->CreateStatement(this->fDbEntry));
if (!statement) {
return -1;
}
FairDbConnectionPool::BLock Block(this->fMultConn->CreateStatement(this->fDbEntry), tableName, tableName);
if ( ! Block.IsBLocked() ) {
DBLOG("FairDb",FairDbLog::kInfo)
<
<
"
Unable
to
lock
"
<<
tableName
<<
endl
;
return
0
;
DBLOG("FairDb",FairDbLog::kInfo)
<
<
"
FairDbRelationalParSet
<
T
>
::AllocateNextId
Unable to lock "
<
<
tableName
<<
endl
;
return
-1
;
}
sql.Clear
();
FairDbString
sql
;
sql
<<
"
SELECT
ID
FROM
"
<<
tableName
<<
"
ORDER
BY
ID
DESC
LIMIT
1";
DBLOG
("
FairDb
",
FairDbLog::kInfo
)
<<
"
tableName:
"
<<
tableName
<<
"
query:
"
<<
sql.c_str
()
<<
endl
;
TSQLStatement*
stmt =
stmtDb-
>
ExecuteQuery(sql.c_str());
stmtDb->PrintExceptions(FairDbLog::kInfo);
Int_t id = 0;
std::unique_ptr
<
TSQLStatement
>
stmt = statement->ExecuteQuery(sql.c_str());
statement->PrintExceptions(FairDbLog::kInfo);
Int_t id = -1;
if ( stmt
&&
stmt->NextResultRow() ) {
id = stmt->GetInt(0) + 1;
} else {
DBLOG("FairDb",FairDbLog::kInfo)
<
<
"
Unable
to
find
default
SeqNo
"
<<
"
due
to
above
error
"
<<
endl
;
DBLOG("FairDb", FairDbLog::kInfo)
<
<
"
FairDbRelationalParSet
<
T
>
::AllocateNextId"
<
<
"
Unable
to
allocate
the
next
Id
"
<<
"
due
to
above
error
"
<<
endl
;
}
delete
stmt
;
stmt =
0;
DBLOG
("
FairDb
",
FairDbLog::kInfo
)<<
"
query
returned
last
generated
seqno:
"
<<
id
<<
endl
;
return
id
;
}
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment