Skip to content

Commit

Permalink
chimera: fix PostgreSQL optimization for labels
Browse files Browse the repository at this point in the history
current code is broken as looks for wrong constrain and passes invalid
number of arguments.

Acked-by: Marina Sahakyan
Target: master, 9.0, 8.2
Require-book: no
Require-notes: yes
  • Loading branch information
kofemann committed Mar 15, 2023
1 parent 725eda7 commit 002c280
Showing 1 changed file with 4 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -349,8 +349,8 @@ void addLabel(FsInode inode, String labelname) throws ChimeraFsException {
int n = _jdbc.update(
con -> {
PreparedStatement ps = con.prepareStatement(
"INSERT INTO t_labels ( labelname) VALUES (?)"
+ "ON CONFLICT ON CONSTRAINT labelname DO NOTHING",
"INSERT INTO t_labels (labelname) VALUES (?)"
+ "ON CONFLICT ON CONSTRAINT t_labels_labelname_key DO NOTHING",
Statement.RETURN_GENERATED_KEYS);
ps.setString(1, labelname);

Expand All @@ -363,23 +363,14 @@ void addLabel(FsInode inode, String labelname) throws ChimeraFsException {
label_id, inode.ino());

} else {


Long label_id = getLabel(labelname);

long label_id = getLabel(labelname);
_jdbc.update(
"INSERT INTO t_labels_ref (label_id, inumber) (SELECT * FROM (VALUES (?,?)) "
"INSERT INTO t_labels_ref (label_id, inumber) VALUES (?,?) "
+ "ON CONFLICT ON CONSTRAINT i_label_pkey DO NOTHING",

ps -> {
ps.setLong(1, label_id);
ps.setLong(2, inode.ino());
ps.setLong(3, label_id);
ps.setLong(4, inode.ino());

});


}

} catch (EmptyResultDataAccessException e) {
Expand Down

0 comments on commit 002c280

Please sign in to comment.