Skip to content

Commit

Permalink
query fix
Browse files Browse the repository at this point in the history
  • Loading branch information
aussendorf committed Sep 18, 2018
1 parent 57b8fa4 commit 677ae3b
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
9 changes: 9 additions & 0 deletions core/src/cats/ddl/creates/postgresql.sql
Expand Up @@ -296,6 +296,15 @@ CREATE TABLE Client

CREATE UNIQUE INDEX client_name_idx ON Client (Name);

-- Get ClientId for a job, Postgres will cache results for
-- functions marked immutable
CREATE OR REPLACE FUNCTION client_of_job ( Id INTEGER) RETURNS INTEGER AS $$
BEGIN
RETURN (SELECT ClientId from Job WHERE JobId=Id);
END;
$$ LANGUAGE plpgsql IMMUTABLE;


-- Function and trigger to partition Job and File table
-- when client is inserted into Client table
CREATE OR REPLACE FUNCTION partition_by_client()
Expand Down
2 changes: 1 addition & 1 deletion core/src/cats/sql_create.cc
Expand Up @@ -865,7 +865,7 @@ bool BareosDb::WriteBatchFileRecords(JobControlRecord *jcr)
"SELECT batch.FileIndex, batch.JobId, Path.PathId, "
"batch.Name, batch.LStat, batch.MD5, batch.DeltaSeq, batch.Fhinfo, batch.Fhnode, batch.ClientId "
"FROM batch "
"JOIN Path ON (batch.Path = Path.Path) ", jcr->ClientId)) {
"JOIN Path ON (batch.Path = Path.Path) ")) {
Jmsg1(jcr, M_FATAL, 0, "Fill File table %s\n", errmsg);
goto bail_out;
}
Expand Down

0 comments on commit 677ae3b

Please sign in to comment.