Skip to content

Commit 65cd6c4

Browse files
committed
Changed m_inventory dumping behavior to exclude when values is null
Previously an empty values column in m_inventory such as when a host has not reported would cause corrupt SQL to be dumped. In this case we should simply not include that host in the output in a similar way that __inventory is built from v_inventory in latest schema. Changelog: Title Ticket: ENT-5562
1 parent e7442ee commit 65cd6c4

1 file changed

Lines changed: 2 additions & 1 deletion

File tree

  • templates/federated_reporting

templates/federated_reporting/dump.sh

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,8 @@ log "Dumping tables: $CFE_FR_TABLES"
5858

5959
# in case of 3.12 must copy m_inventory as if it was __inventory
6060
if [[ "$CFE_VERSION" =~ "3.12." ]]; then
61-
"$CFE_BIN_DIR"/psql cfdb -c "COPY (SELECT * FROM m_inventory) TO STDOUT CSV QUOTE '''' FORCE QUOTE *" |
61+
# pg_dump will not dump the contents of views so we must run the following SQL:
62+
"$CFE_BIN_DIR"/psql cfdb -c "COPY (SELECT * FROM m_inventory WHERE values IS NOT NULL) TO STDOUT CSV QUOTE '''' FORCE QUOTE *" |
6263
sed -e 's.^.INSERT INTO __inventory (hostkey, values) VALUES (.' \
6364
-e 's.$.);.'
6465
fi

0 commit comments

Comments
 (0)