Closed
Bug 483154
Opened 16 years ago
Closed 16 years ago
mozStorageStatementParams should use mozIStorageStatement API instead of calling SQLite directly
Categories
(Core :: SQLite and Embedded Database Bindings, defect)
Core
SQLite and Embedded Database Bindings
Tracking
()
RESOLVED
FIXED
mozilla1.9.2a1
People
(Reporter: sdwilsh, Assigned: sdwilsh)
References
Details
Attachments
(1 file, 2 obsolete files)
6.22 KB,
patch
|
bent.mozilla
:
review+
|
Details | Diff | Splinter Review |
There's really no reason to call SQLite directly here - we can let the storage statement class handle this (it's already setup to do so), and then we don't have to worry about duplicating logic.
Assignee | ||
Comment 1•16 years ago
|
||
This one was a lot easier than the row one...
Assignee: nobody → sdwilsh
Status: NEW → ASSIGNED
Attachment #367317 -
Flags: review?(jorendorff)
Attachment #367317 -
Flags: review?(bugmail)
Assignee | ||
Updated•16 years ago
|
Whiteboard: [needs review asuth][needs review jorendorff]
Assignee | ||
Updated•16 years ago
|
Attachment #367317 -
Flags: review?(jorendorff) → review?(bent.mozilla)
Assignee | ||
Updated•16 years ago
|
Whiteboard: [needs review asuth][needs review jorendorff] → [needs review asuth][needs review bent]
Comment on attachment 367317 [details] [diff] [review]
v1.0
> name.Append(NS_ConvertUTF16toUTF8(nsDependentString((PRUnichar *)::JS_GetStringChars(str),
> ::JS_GetStringLength(str))));
Not your new code, but there's no need for that nsDependentString, just hand NS_ConvertUTF16toUTF8 the pointer and length. In the next hunk too.
>+ if (NS_FAILED(rv)) {
> *_retval = PR_FALSE;
> return NS_ERROR_INVALID_ARG;
> }
> ...
>+ else {
> *_retval = PR_FALSE;
> }
No need to set *_retval if you're going to return a failure code. XPConnect won't even look at it. In the next hunk too.
> PRBool success = ::JS_DefineUCProperty(cx, obj, ::JS_GetStringChars(str),
So you've already gotten the string chars and length above, why not save and reuse?
>+ if (idx >= mParamCount) {
> *_retval = PR_FALSE;
> return NS_OK;
> }
So that is actually a silent, uncatchable exception right there. Is that intended? If not you should return a failure nsresult.
Updated•16 years ago
|
Attachment #367317 -
Flags: review?(bugmail) → review+
Comment 3•16 years ago
|
||
Comment on attachment 367317 [details] [diff] [review]
v1.0
>diff --git a/storage/src/mozStorageStatementParams.cpp b/storage/src/mozStorageStatementParams.cpp
> // is it out of range?
>- if (idx < 0 || idx >= (int)mParamCount) {
>+ if (idx >= mParamCount) {
> *_retval = PR_FALSE;
> return NS_OK;
> }
I agree with bent; the silent failure of assignment is probably not desired here. Suggest NS_ERROR_ILLEGAL_VALUE.
Updated•16 years ago
|
Whiteboard: [needs review asuth][needs review bent] → [needs review bent]
Assignee | ||
Comment 4•16 years ago
|
||
This should address the review comments.
Attachment #367317 -
Attachment is obsolete: true
Attachment #368577 -
Flags: review?(bent.mozilla)
Attachment #367317 -
Flags: review?(bent.mozilla)
Comment on attachment 368577 [details] [diff] [review]
v1.1
> + NS_ENSURE_ARG_MAX(idx, mParamCount - 1);
Er, this will be wrong if mParamCount is 0 because mParamCount is unsigned. Can it be 0 here?
Assignee | ||
Comment 6•16 years ago
|
||
It wouldn't be 0 in any sane calling situation, but let's be safe anyway.
Attachment #368577 -
Attachment is obsolete: true
Attachment #368583 -
Flags: review?(bent.mozilla)
Attachment #368577 -
Flags: review?(bent.mozilla)
Updated•16 years ago
|
Attachment #368583 -
Flags: review?(bent.mozilla) → review+
Comment on attachment 368583 [details] [diff] [review]
v1.2
Looks ok to me!
Assignee | ||
Updated•16 years ago
|
Whiteboard: [needs review bent] → [can land]
Assignee | ||
Comment 8•16 years ago
|
||
Status: ASSIGNED → RESOLVED
Closed: 16 years ago
Resolution: --- → FIXED
Whiteboard: [can land]
Target Milestone: --- → mozilla1.9.2a1
Updated•5 months ago
|
Product: Toolkit → Core
You need to log in
before you can comment on or make changes to this bug.
Description
•