Skip to content

Commit

Permalink
Add parent_file_id and protect against null values
Browse files Browse the repository at this point in the history
  • Loading branch information
vkuznet committed Mar 2, 2022
1 parent 00473bd commit e4dea81
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 1 deletion.
11 changes: 10 additions & 1 deletion dbs/blockdump.go
Original file line number Diff line number Diff line change
Expand Up @@ -403,10 +403,19 @@ func getFileParentList(blk string, wg *sync.WaitGroup, fileParentList *FileParen
defer rows.Close()
for rows.Next() {
fileParent := FileParentRecord{}
var pid sql.NullInt64
var pfn sql.NullString
err = rows.Scan(
&fileParent.LogicalFileName,
&fileParent.ParentLogicalFileName,
&pid,
&pfn,
)
if pid.Valid {
fileParent.ParentFileId = pid.Int64
}
if pfn.Valid {
fileParent.ParentLogicalFileName = pfn.String
}
if err != nil {
log.Println("unable to scan rows", err)
return
Expand Down
1 change: 1 addition & 0 deletions dbs/fileparents.go
Original file line number Diff line number Diff line change
Expand Up @@ -368,6 +368,7 @@ func (a *API) InsertFileParentsBlockTxt(tx *sql.Tx) error {
// used by bulkblock API
type FileParentRecord struct {
LogicalFileName string `json:"this_logical_file_name"`
ParentFileId int64 `json:"parent_file_id"`
ParentLogicalFileName string `json:"parent_logical_file_name"`
}

Expand Down
1 change: 1 addition & 0 deletions static/sql/blockdump_fileparents.sql
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
SELECT
F.LOGICAL_FILE_NAME,
PF.FILE_ID,
PF.LOGICAL_FILE_NAME
FROM {{.Owner}}.FILES PF
JOIN {{.Owner}}.FILE_PARENTS FP ON FP.PARENT_FILE_ID = PF.FILE_ID
Expand Down

0 comments on commit e4dea81

Please sign in to comment.