Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
M
mpd
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Иван Мажукин
mpd
Commits
12b4a666
Commit
12b4a666
authored
Dec 12, 2014
by
Max Kellermann
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
lib/sqlite/Util: add ExecuteModified()
parent
cfdbaf33
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
23 additions
and
14 deletions
+23
-14
Util.hxx
src/lib/sqlite/Util.hxx
+11
-0
StickerDatabase.cxx
src/sticker/StickerDatabase.cxx
+12
-14
No files found.
src/lib/sqlite/Util.hxx
View file @
12b4a666
...
...
@@ -137,6 +137,17 @@ ExecuteChanges(sqlite3_stmt *stmt)
return
sqlite3_changes
(
sqlite3_db_handle
(
stmt
));
}
/**
* Wrapper for ExecuteChanges() that returns true if at least one row
* was modified. Returns false if nothing was modified or if an error
* occurred.
*/
static
inline
bool
ExecuteModified
(
sqlite3_stmt
*
stmt
)
{
return
ExecuteChanges
(
stmt
)
>
0
;
}
template
<
typename
F
>
static
inline
bool
ExecuteForEach
(
sqlite3_stmt
*
stmt
,
F
&&
f
)
...
...
src/sticker/StickerDatabase.cxx
View file @
12b4a666
...
...
@@ -224,15 +224,14 @@ sticker_update_value(const char *type, const char *uri,
if
(
!
BindAll
(
stmt
,
value
,
type
,
uri
,
name
))
return
false
;
int
ret
=
ExecuteChanges
(
stmt
);
if
(
ret
<
0
)
return
false
;
bool
modified
=
ExecuteModified
(
stmt
);
sqlite3_reset
(
stmt
);
sqlite3_clear_bindings
(
stmt
);
idle_add
(
IDLE_STICKER
);
return
ret
>
0
;
if
(
modified
)
idle_add
(
IDLE_STICKER
);
return
modified
;
}
static
bool
...
...
@@ -291,14 +290,14 @@ sticker_delete(const char *type, const char *uri)
if
(
!
BindAll
(
stmt
,
type
,
uri
))
return
false
;
if
(
!
ExecuteCommand
(
stmt
))
return
false
;
bool
modified
=
ExecuteModified
(
stmt
);
sqlite3_reset
(
stmt
);
sqlite3_clear_bindings
(
stmt
);
idle_add
(
IDLE_STICKER
);
return
true
;
if
(
modified
)
idle_add
(
IDLE_STICKER
);
return
modified
;
}
bool
...
...
@@ -313,15 +312,14 @@ sticker_delete_value(const char *type, const char *uri, const char *name)
if
(
!
BindAll
(
stmt
,
type
,
uri
,
name
))
return
false
;
int
ret
=
ExecuteChanges
(
stmt
);
if
(
ret
<
0
)
return
false
;
bool
modified
=
ExecuteModified
(
stmt
);
sqlite3_reset
(
stmt
);
sqlite3_clear_bindings
(
stmt
);
idle_add
(
IDLE_STICKER
);
return
ret
>
0
;
if
(
modified
)
idle_add
(
IDLE_STICKER
);
return
modified
;
}
void
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment