diff --git a/metadata_db.go b/metadata_db.go index c0be1af..8ac5cd5 100644 --- a/metadata_db.go +++ b/metadata_db.go @@ -751,11 +751,10 @@ func (mdb *MetadataDb) createDataObject( return 0, oph.RecordError(err) } - sqlStmt = fmt.Sprintf(` - INSERT INTO namespace - VALUES ('%s', '%s', '%d', '%d');`, - parentDir, fname, nsDataObjType, inode) - if _, err := oph.txn.Exec(sqlStmt); err != nil { + sqlStatementPrep, _ := oph.txn.Prepare(`INSERT INTO namespace + VALUES ($1, $2, $3, $4);`) + defer sqlStatementPrep.Close() + if _, err := sqlStatementPrep.Exec(parentDir, fname, nsDataObjType, inode); err != nil { mdb.log("Error inserting %s/%s into the namespace table err=%s", parentDir, fname, err.Error()) return 0, oph.RecordError(err) } @@ -1132,12 +1131,13 @@ func (mdb *MetadataDb) LookupInDir(ctx context.Context, oph *OpHandle, dir *Dir, } // point lookup in the namespace - sqlStmt := fmt.Sprintf(` - SELECT obj_type,inode - FROM namespace - WHERE parent = '%s' AND name = '%s';`, - dir.FullPath, dirOrFileName) - rows, err := oph.txn.Query(sqlStmt) + sqlStmtPrep, _ := oph.txn.Prepare(` + SELECT obj_type,inode + FROM namespace + WHERE parent = ? AND name = ?;`) + defer sqlStmtPrep.Close() + rows, err := sqlStmtPrep.Query(dir.FullPath, dirOrFileName) + if err != nil { return nil, false, oph.RecordError(err) } diff --git a/test/correctness/code.sh b/test/correctness/code.sh index 2593c4e..87f4a4f 100644 --- a/test/correctness/code.sh +++ b/test/correctness/code.sh @@ -532,11 +532,11 @@ main() { mkdir -p $mountpoint # generate random alphanumeric strings - base_dir=$(cat /dev/urandom | tr -dc 'a-zA-Z0-9' | fold -w 12 | head -n 1) + base_dir=$(dd if=/dev/urandom bs=15 count=1 2>/dev/null| base64 | tr -dc 'a-zA-Z0-9'|fold -w 12|head -n1) base_dir="base_$base_dir" - faux_dir=$(cat /dev/urandom | tr -dc 'a-zA-Z0-9' | fold -w 12 | head -n 1) + faux_dir=$(dd if=/dev/urandom bs=15 count=1 2>/dev/null| base64 | tr -dc 'a-zA-Z0-9'|fold -w 12|head -n1) faux_dir="faux_$faux_dir" - expr_dir=$(cat /dev/urandom | tr -dc 'a-zA-Z0-9' | fold -w 12 | head -n 1) + expr_dir=$(dd if=/dev/urandom bs=15 count=1 2>/dev/null| base64 | tr -dc 'a-zA-Z0-9'|fold -w 12|head -n1) expr_dir="expr_$expr_dir" writeable_dirs=($base_dir $faux_dir $expr_dir) for d in ${writeable_dirs[@]}; do diff --git a/util.go b/util.go index 3b206bd..ef5cc48 100644 --- a/util.go +++ b/util.go @@ -29,7 +29,7 @@ const ( MaxDirSize = 255 * 1000 MaxNumFileHandles = 1000 * 1000 NumRetriesDefault = 10 - Version = "v0.24.1" + Version = "v0.24.2" ) const ( InodeInvalid = 0