Closed Bug 483154 Opened 15 years ago Closed 15 years ago

mozStorageStatementParams should use mozIStorageStatement API instead of calling SQLite directly

Categories

(Toolkit :: Storage, defect)

defect
Not set
normal

Tracking

()

RESOLVED FIXED
mozilla1.9.2a1

People

(Reporter: sdwilsh, Assigned: sdwilsh)

References

Details

Attachments

(1 file, 2 obsolete files)

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.
Attached patch v1.0 (obsolete) — Splinter Review
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)
Whiteboard: [needs review asuth][needs review jorendorff]
Attachment #367317 - Flags: review?(jorendorff) → review?(bent.mozilla)
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.
Attachment #367317 - Flags: review?(bugmail) → review+
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.
Whiteboard: [needs review asuth][needs review bent] → [needs review bent]
Attached patch v1.1 (obsolete) — Splinter Review
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?
Attached patch v1.2Splinter Review
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)
Attachment #368583 - Flags: review?(bent.mozilla) → review+
Whiteboard: [needs review bent] → [can land]
http://hg.mozilla.org/mozilla-central/rev/dee8dab15435
Status: ASSIGNED → RESOLVED
Closed: 15 years ago
Resolution: --- → FIXED
Whiteboard: [can land]
Target Milestone: --- → mozilla1.9.2a1
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: