The 'batch' table is a temporary one, which only exists during a backup and is only visible from the session that created it.
I think the error is misleading: the 9 fields in the failing row are those of the file table itself, i.e. starting with fileid, not the 7 fields listed in the insert statement. The fileid cannot be null and is supposed to be generated by postgresql by a sequence counter. It looks like you didn't manually perform all of the steps in update_postgres_tables, in particular the parts about file_fileid_seq. At this point, I think you should just start over because the schema in the catalog is in an unknown state. __Martin >>>>> On Fri, 20 Nov 2026 14:19:10 -0500, Brian said: > > So, some updates on this saga. It's not resolved yet. > > I backed up the database and started hacking... Eventually I was able > to manually perform the steps that had been missed when the > update_postgres_tables script was run, through a combination of > resetting the version.versionid and commenting out parts of the script > that did originally succeed and are not idempotent (several ALTER TABLE, > etc). > > Now I'm faced with a new SQL error at the end of a backup job: > > > Fatal error: sql_create.c:911 Fill File table Query failed: INSERT INTO > > File (FileIndex, JobId, PathId, Filename, LStat, MD5, DeltaSeq) SELECT > > batch.FileIndex, batch.JobId, Path.PathId, batch.Name, batch.LStat, > > batch.MD5, batch.DeltaSeq FROM batch JOIN Path ON (batch.Path = Path.Path) > > : ERR=ERROR: null value in column "fileid" of relation "file" violates > > not-null constraint > > DETAIL: Failing row contains (null, -1134, 50, 143537, > > nftables.conf.dpkg-new, 0, 0, A A A A A A A A A A A BoSHWT Bq5jFt A A C, 0) > > There's no 'batch' table (and none mentioned in update_postgres_tables), > so I can't figure out how to debug this query. What's 'batch'? A > temporary table created by an earlier query, maybe? Why might it have a > 'null' in its FileIndex field? Those other integer values look sketchy, > too; is it expected that JobId might be a negative number? Have I just > completely hosed my system and I should start over? > > Thanks, > -B > > On 11/10/26 14:13, Martin Simmons wrote: > > What are the columns of the file table? E.g. run "psql -U bacula bacula" > > and > > use the "\d file" command. > > > > If the columns include filenameid and not filename, then I suspect part of > > the > > update_postgres_tables script was never run, because that is supposed to fix > > these columns. > > > > __Martin > > > > > >>>>>> On Tue, 10 Nov 2026 11:50:00 -0500, Brian said: > >> > >> (I've been having some trouble with my outbound e-mail; please excuse if > >> this is a repost) > >> > >> Hello, > >> > >> This past weekend I upgraded a Debian 12 server to Debian 13 with > >> `apt-get full-upgrade`. There were errors involving upgrading > >> postgresql and bacula, seemingly because dpkg tried to configure > >> packages in the wrong order. A few iterations eventually led to no > >> further errors from apt-get or dpkg. > >> > >> I had to manually run the update_postgres_tables script, and that > >> required modding the script to correct for the fact that bash will > >> convert "$$" into the current PID, breaking psql if-blocks. > >> > >> Bacula no longer complains about database versions (found 1019, want > >> 1026, etc), but now all my backup jobs fail at the end with the > >> following log message: > >> > >> JobId 48: Fatal error: backup.c:343 [DE0028] Query failed: DECLARE > >> _bac_cursor CURSOR FOR SELECT Path, Filename, FileIndex, JobId, LStat, > >> DeltaSeq , JobTDate FROM ((SELECT Path.Path, T1.Filename, > >> T1.FileIndex, T1.JobId, LStat, DeltaSeq , JobTDate FROM ( SELECT > >> DISTINCT ON (Filename, PathId) JobTDate, JobId, FileId, FileIndex, > >> PathId, Filename, LStat , DeltaSeq FROM (SELECT FileId, JobId, > >> PathId, Filename, FileIndex, LStat , DeltaSeq FROM File WHERE JobId > >> IN (1,23) UNION ALL SELECT File.FileId, File.JobId, PathId, Filename, > >> File.FileIndex, LStat , DeltaSeq FROM BaseFiles JOIN File USING > >> (FileId) WHERE BaseFiles.JobId IN (1,23) ) AS T JOIN Job USING (JobId) > >> ORDER BY Filename, PathId, JobTDate DESC ) AS T1 JOIN Path ON > >> (Path.PathId = T1.PathId) WHERE FileIndex > 0 ) ) AS U1 ORDER BY > >> JobTDate, FileIndex ASC: ERR=ERROR: column "filename" does not exist > >> LINE 1: ... , DeltaSeq FROM (SELECT FileId, JobId, PathId, Filename, ... > >> > >> Googling gives results that talk about fixing SQL files that don't exist > >> on my system and/or do not contain the quoted query. > >> > >> All tips on what to do next will be greatly appreciated. > >> > >> Bacula version 15.0.3 as packaged for Debian Trixie (13). > >> Postgresql version 13. > >> > >> Thanks, > >> -Brian > >> > >> > >> _______________________________________________ > >> Bacula-users mailing list > >> [email protected] > >> https://lists.sourceforge.net/lists/listinfo/bacula-users > >> > > > > _______________________________________________ > Bacula-users mailing list > [email protected] > https://lists.sourceforge.net/lists/listinfo/bacula-users > _______________________________________________ Bacula-users mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/bacula-users
