You are viewing a plain text version of this content. The canonical link for it is here.
Posted to derby-dev@db.apache.org by "Oleksandr Alesinskyy (JIRA)" <de...@db.apache.org> on 2006/10/10 12:30:19 UTC

[jira] Created: (DERBY-1949) locate function returns invalid value when first parameter is empty string

locate function returns invalid value when first parameter is empty string
--------------------------------------------------------------------------

                 Key: DERBY-1949
                 URL: http://issues.apache.org/jira/browse/DERBY-1949
             Project: Derby
          Issue Type: Bug
          Components: SQL
    Affects Versions: 10.2.1.6, 10.1.3.1
         Environment: N/A
            Reporter: Oleksandr Alesinskyy


locate function returns false invalid when first parameter is empty string,
e.g. 

values(locate('','A')

results in 1, which is obviously wrong

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: http://issues.apache.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

[jira] Updated: (DERBY-1949) locate function returns invalid value when first parameter is empty string

Posted by "Bryan Pendleton (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/DERBY-1949?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Bryan Pendleton updated DERBY-1949:
-----------------------------------

    Attachment: rrefsqlj61998.html
                docs.diff

Thanks Army and Dag for the comments and suggestions.

Attached is docs.diff, a patch proposal for the docs, and the 
resulting HTML page for the LOCATE function in the ref guide
for easier review. I've tried to make it more clear which argument
is which, both by descriptive text and by adding more examples.

Please have a look and let me know what you think.

> locate function returns invalid value when first parameter is empty string
> --------------------------------------------------------------------------
>
>                 Key: DERBY-1949
>                 URL: https://issues.apache.org/jira/browse/DERBY-1949
>             Project: Derby
>          Issue Type: Bug
>          Components: SQL
>    Affects Versions: 10.1.3.1, 10.2.1.6
>         Environment: N/A
>            Reporter: Oleksandr Alesinskyy
>         Assigned To: Bryan Pendleton
>         Attachments: docs.diff, rrefsqlj61998.html
>
>
> locate function returns false invalid when first parameter is empty string,
> e.g. 
> values(locate('','A')
> results in 1, which is obviously wrong

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Commented: (DERBY-1949) locate function documentation should clarify behavior when first parameter is empty string

Posted by "Laura Stewart (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/DERBY-1949?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#action_12485517 ] 

Laura Stewart commented on DERBY-1949:
--------------------------------------

If the issue in the summary is still a problem, then it needs to be tracked as an open issue. If the issue in the original summary was not really an issue but led to the discovery of a related issue, then changing the summary to match the real issue is correct and the status should be fixed... whether it is a code or documentation fix. I don't think that we need to have a separate category for docs.

> locate function documentation should clarify behavior when first parameter is empty string
> ------------------------------------------------------------------------------------------
>
>                 Key: DERBY-1949
>                 URL: https://issues.apache.org/jira/browse/DERBY-1949
>             Project: Derby
>          Issue Type: Bug
>          Components: Documentation, SQL
>    Affects Versions: 10.1.3.1, 10.2.1.6
>         Environment: N/A
>            Reporter: Oleksandr Alesinskyy
>         Assigned To: Bryan Pendleton
>             Fix For: 10.3.0.0
>
>         Attachments: docs.diff, docs_v2.diff, rrefsqlj61998.html, rrefsqlj61998.html
>
>
> Documentation for the locate function does not clearly explain the behavior when first parameter is empty string, e.g. 
> values locate('','A')
> results in 1, and 
> values locate('', 'ABC', 5)
> returns 5, but the documentation does not clearly explain why this is so.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Updated: (DERBY-1949) locate function returns invalid value when first parameter is empty string

Posted by "Bryan Pendleton (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/DERBY-1949?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Bryan Pendleton updated DERBY-1949:
-----------------------------------

    Derby Info: [Patch Available, Existing Application Impact]  (was: [Existing Application Impact])

> locate function returns invalid value when first parameter is empty string
> --------------------------------------------------------------------------
>
>                 Key: DERBY-1949
>                 URL: https://issues.apache.org/jira/browse/DERBY-1949
>             Project: Derby
>          Issue Type: Bug
>          Components: SQL
>    Affects Versions: 10.1.3.1, 10.2.1.6
>         Environment: N/A
>            Reporter: Oleksandr Alesinskyy
>         Assigned To: Bryan Pendleton
>         Attachments: docs.diff, rrefsqlj61998.html
>
>
> locate function returns false invalid when first parameter is empty string,
> e.g. 
> values(locate('','A')
> results in 1, which is obviously wrong

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Commented: (DERBY-1949) locate function returns invalid value when first parameter is empty string

Posted by "Bryan Pendleton (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/DERBY-1949?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#action_12484283 ] 

Bryan Pendleton commented on DERBY-1949:
----------------------------------------

Hi Oleksandr, thanks for raising this issue.

Why do you think that the return value of 1 is obviously wrong?

The Derby documentation about the LOCATE function is rather brief, but it's not clear
to me what the intended result is for the case that you mention. I'm not quite sure
what it should mean to search for an empty string. My first reaction was that it would
be nice if LOCATE treated this as an error, but I don't see how LOCATE can return an
error; it can only return a non-negative integer according to the manual.

It seems to me that 1 is a valid return code, according to this definition: position 1 is
the first position where every character of the first parameter string is found starting
at that position in the second parameter string.

So maybe we should change the documentation to describe the behavior when
the first parameter is an empty string?



> locate function returns invalid value when first parameter is empty string
> --------------------------------------------------------------------------
>
>                 Key: DERBY-1949
>                 URL: https://issues.apache.org/jira/browse/DERBY-1949
>             Project: Derby
>          Issue Type: Bug
>          Components: SQL
>    Affects Versions: 10.1.3.1, 10.2.1.6
>         Environment: N/A
>            Reporter: Oleksandr Alesinskyy
>
> locate function returns false invalid when first parameter is empty string,
> e.g. 
> values(locate('','A')
> results in 1, which is obviously wrong

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Resolved: (DERBY-1949) locate function documentation should clarify behavior when first parameter is empty string

Posted by "Bryan Pendleton (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/DERBY-1949?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Bryan Pendleton resolved DERBY-1949.
------------------------------------

    Resolution: Fixed

I'm not quite sure what resolution to use. I think this was a valid problem with the documentation, so I don't think "invalid" is quite right. But we didn't change any code, so Dan feels that "fixed" is not quite right. Seems like there should be a resolution that means "resolved by improving the documentation". For now, left the resolution as "fixed".

> locate function documentation should clarify behavior when first parameter is empty string
> ------------------------------------------------------------------------------------------
>
>                 Key: DERBY-1949
>                 URL: https://issues.apache.org/jira/browse/DERBY-1949
>             Project: Derby
>          Issue Type: Bug
>          Components: Documentation, SQL
>    Affects Versions: 10.1.3.1, 10.2.1.6
>         Environment: N/A
>            Reporter: Oleksandr Alesinskyy
>         Assigned To: Bryan Pendleton
>             Fix For: 10.3.0.0
>
>         Attachments: docs.diff, docs_v2.diff, rrefsqlj61998.html, rrefsqlj61998.html
>
>
> Documentation for the locate function does not clearly explain the behavior when first parameter is empty string, e.g. 
> values locate('','A')
> results in 1, and 
> values locate('', 'ABC', 5)
> returns 5, but the documentation does not clearly explain why this is so.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Reopened: (DERBY-1949) locate function documentation should clarify behavior when first parameter is empty string

Posted by "Bryan Pendleton (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/DERBY-1949?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Bryan Pendleton reopened DERBY-1949:
------------------------------------


Reopen to change resolution type.

> locate function documentation should clarify behavior when first parameter is empty string
> ------------------------------------------------------------------------------------------
>
>                 Key: DERBY-1949
>                 URL: https://issues.apache.org/jira/browse/DERBY-1949
>             Project: Derby
>          Issue Type: Bug
>          Components: Documentation, SQL
>    Affects Versions: 10.1.3.1, 10.2.1.6
>         Environment: N/A
>            Reporter: Oleksandr Alesinskyy
>         Assigned To: Bryan Pendleton
>             Fix For: 10.3.0.0
>
>         Attachments: docs.diff, docs_v2.diff, rrefsqlj61998.html, rrefsqlj61998.html
>
>
> Documentation for the locate function does not clearly explain the behavior when first parameter is empty string, e.g. 
> values locate('','A')
> results in 1, and 
> values locate('', 'ABC', 5)
> returns 5, but the documentation does not clearly explain why this is so.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Commented: (DERBY-1949) locate function returns invalid value when first parameter is empty string

Posted by "Daniel John Debrunner (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/DERBY-1949?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#action_12485406 ] 

Daniel John Debrunner commented on DERBY-1949:
----------------------------------------------

Why is this bug marked "Existing application impact"? There's no code changes right?

Also I'm not sure marking this fixed is correct, because the issue as described in the summary was not fixed.
I agree it was good to make documentation changes, but this will now appear of the list of fixed bugs for 10.3
as the current summary. Maybe invalid is a better status even if changes were made?

> locate function returns invalid value when first parameter is empty string
> --------------------------------------------------------------------------
>
>                 Key: DERBY-1949
>                 URL: https://issues.apache.org/jira/browse/DERBY-1949
>             Project: Derby
>          Issue Type: Bug
>          Components: SQL
>    Affects Versions: 10.1.3.1, 10.2.1.6
>         Environment: N/A
>            Reporter: Oleksandr Alesinskyy
>         Assigned To: Bryan Pendleton
>             Fix For: 10.3.0.0
>
>         Attachments: docs.diff, docs_v2.diff, rrefsqlj61998.html, rrefsqlj61998.html
>
>
> locate function returns false invalid when first parameter is empty string,
> e.g. 
> values(locate('','A')
> results in 1, which is obviously wrong

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Assigned: (DERBY-1949) locate function returns invalid value when first parameter is empty string

Posted by "Bryan Pendleton (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/DERBY-1949?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Bryan Pendleton reassigned DERBY-1949:
--------------------------------------

    Assignee: Bryan Pendleton

> locate function returns invalid value when first parameter is empty string
> --------------------------------------------------------------------------
>
>                 Key: DERBY-1949
>                 URL: https://issues.apache.org/jira/browse/DERBY-1949
>             Project: Derby
>          Issue Type: Bug
>          Components: SQL
>    Affects Versions: 10.1.3.1, 10.2.1.6
>         Environment: N/A
>            Reporter: Oleksandr Alesinskyy
>         Assigned To: Bryan Pendleton
>
> locate function returns false invalid when first parameter is empty string,
> e.g. 
> values(locate('','A')
> results in 1, which is obviously wrong

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Updated: (DERBY-1949) locate function returns invalid value when first parameter is empty string

Posted by "Bryan Pendleton (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/DERBY-1949?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Bryan Pendleton updated DERBY-1949:
-----------------------------------

    Attachment: rrefsqlj61998.html
                docs_v2.diff

Thanks Oleksandr for the review and good examples. And thanks
Kristian for pointing out the code comment that makes it clear
that this is intentional behavior in the code, to match DB2's behavior.

Attached is docs_v2.diff, updated to incorporate Oleksandr's
suggestions and examples, and an updated version of the
HTML-formatted ref page for easier review.


> locate function returns invalid value when first parameter is empty string
> --------------------------------------------------------------------------
>
>                 Key: DERBY-1949
>                 URL: https://issues.apache.org/jira/browse/DERBY-1949
>             Project: Derby
>          Issue Type: Bug
>          Components: SQL
>    Affects Versions: 10.1.3.1, 10.2.1.6
>         Environment: N/A
>            Reporter: Oleksandr Alesinskyy
>         Assigned To: Bryan Pendleton
>         Attachments: docs.diff, docs_v2.diff, rrefsqlj61998.html, rrefsqlj61998.html
>
>
> locate function returns false invalid when first parameter is empty string,
> e.g. 
> values(locate('','A')
> results in 1, which is obviously wrong

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Resolved: (DERBY-1949) locate function returns invalid value when first parameter is empty string

Posted by "Bryan Pendleton (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/DERBY-1949?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Bryan Pendleton resolved DERBY-1949.
------------------------------------

       Resolution: Fixed
    Fix Version/s: 10.3.0.0
       Derby Info: [Existing Application Impact]  (was: [Existing Application Impact, Patch Available])

I committed docs_v2.diff to subversion as revision 523912.


> locate function returns invalid value when first parameter is empty string
> --------------------------------------------------------------------------
>
>                 Key: DERBY-1949
>                 URL: https://issues.apache.org/jira/browse/DERBY-1949
>             Project: Derby
>          Issue Type: Bug
>          Components: SQL
>    Affects Versions: 10.1.3.1, 10.2.1.6
>         Environment: N/A
>            Reporter: Oleksandr Alesinskyy
>         Assigned To: Bryan Pendleton
>             Fix For: 10.3.0.0
>
>         Attachments: docs.diff, docs_v2.diff, rrefsqlj61998.html, rrefsqlj61998.html
>
>
> locate function returns false invalid when first parameter is empty string,
> e.g. 
> values(locate('','A')
> results in 1, which is obviously wrong

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


Re: [jira] Commented: (DERBY-1949) locate function returns invalid value when first parameter is empty string

Posted by "Dag H. Wanvik" <Da...@Sun.COM>.
"Bryan Pendleton (JIRA)" <ji...@apache.org> writes:

>     [ https://issues.apache.org/jira/browse/DERBY-1949?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#action_12484594 ] 
>
> Bryan Pendleton commented on DERBY-1949:
> ----------------------------------------
>
>> which operand is which
>
> Thanks Army, I believe you are exactly right. The documentation does not make it clear
> which operand is which, and other databases appear to take the arguments in the other
> order. For example, here's a reference to Sybase which appears to process the arguments
> in the opposite order from Derby:
> http://manuals.sybase.com/onlinebooks/group-iq/iqg1250e/iqref/@Generic__BookTextView/34859;pt=33287
>
> It's also interesting that the Sybase documentation explicitly says:
> "Searching for a zero-length string will return 1."
>
> I propose to update the documentation to make it clear which argument is which in
> the LOCATE function, and also to note that searching for a zero-length string returns 1.

This seems right to me, including in the ('', '') case.

+1

Dag

[jira] Commented: (DERBY-1949) locate function returns invalid value when first parameter is empty string

Posted by "Bryan Pendleton (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/DERBY-1949?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#action_12484594 ] 

Bryan Pendleton commented on DERBY-1949:
----------------------------------------

> which operand is which

Thanks Army, I believe you are exactly right. The documentation does not make it clear
which operand is which, and other databases appear to take the arguments in the other
order. For example, here's a reference to Sybase which appears to process the arguments
in the opposite order from Derby:
http://manuals.sybase.com/onlinebooks/group-iq/iqg1250e/iqref/@Generic__BookTextView/34859;pt=33287

It's also interesting that the Sybase documentation explicitly says:
"Searching for a zero-length string will return 1."

I propose to update the documentation to make it clear which argument is which in
the LOCATE function, and also to note that searching for a zero-length string returns 1.

Oleksandr, does the LOCATE function's behavior make more sense when you consider
the arguments as being interpreted in the order that Army indicates?



> locate function returns invalid value when first parameter is empty string
> --------------------------------------------------------------------------
>
>                 Key: DERBY-1949
>                 URL: https://issues.apache.org/jira/browse/DERBY-1949
>             Project: Derby
>          Issue Type: Bug
>          Components: SQL
>    Affects Versions: 10.1.3.1, 10.2.1.6
>         Environment: N/A
>            Reporter: Oleksandr Alesinskyy
>         Assigned To: Bryan Pendleton
>
> locate function returns false invalid when first parameter is empty string,
> e.g. 
> values(locate('','A')
> results in 1, which is obviously wrong

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Commented: (DERBY-1949) locate function returns invalid value when first parameter is empty string

Posted by "A B (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/DERBY-1949?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#action_12484554 ] 

A B commented on DERBY-1949:
----------------------------

Bryan> I'm not quite sure what it should mean to search for an empty string. 

  ==> Implies searching a non-empty string for an empty string.

Oleksandr> there is no chance to find non-empty substring in the empty string . 

  ==> Implies searching an empty string for a non-empty string.

I think there's a disconnect between Bryan and Oleksandr with respect to which operand is which.  And unfortunately, the documentation is not very helpful.

I ran some examples and it looks like the first argument is the string *for which* we are searching, while the second argument is the string *to be searched*.  The only clear way the documentation shows this is with the example:

  VALUES LOCATE('love', 'clover')

Here we are searching the word 'clover' for the word 'love'; i.e. searching the second string for an occurence of the first string.

So if we look at Oleksandr's example:

  values(locate('','A'))

we're searching the non-empty string "A" for the empty string.

For what it's worth, I ran the following on DB2 v8:

db2 => VALUES LOCATE('love', 'clover')

1
-----------
          2

  1 record(s) selected.

db2 => values(locate('','A'))

1
-----------
          1

  1 record(s) selected.

db2 => values(locate('A',''))

1
-----------
          0

  1 record(s) selected.

db2 => values(locate('',''))

1
-----------
          1

  1 record(s) selected.

> locate function returns invalid value when first parameter is empty string
> --------------------------------------------------------------------------
>
>                 Key: DERBY-1949
>                 URL: https://issues.apache.org/jira/browse/DERBY-1949
>             Project: Derby
>          Issue Type: Bug
>          Components: SQL
>    Affects Versions: 10.1.3.1, 10.2.1.6
>         Environment: N/A
>            Reporter: Oleksandr Alesinskyy
>         Assigned To: Bryan Pendleton
>
> locate function returns false invalid when first parameter is empty string,
> e.g. 
> values(locate('','A')
> results in 1, which is obviously wrong

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Commented: (DERBY-1949) locate function returns invalid value when first parameter is empty string

Posted by "Oleksandr Alesinskyy (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/DERBY-1949?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#action_12484543 ] 

Oleksandr Alesinskyy commented on DERBY-1949:
---------------------------------------------

It seems obvious (to me :) ) that returned value shall be 0.
Derby documentation on LOCATE clearly states "If the substring is not found,
LOCATE returns 0".  And there is no chance to find non-empty substring in the empty 
string .

More subtle case is when both string and substring are empty. But even in this case
0 seems to be right value (and consistent with other DBMS as far as I know, save the 
Oracle that agains the SQL standard treats empty strings as nulls ).

Regards,
Oleksandr


> locate function returns invalid value when first parameter is empty string
> --------------------------------------------------------------------------
>
>                 Key: DERBY-1949
>                 URL: https://issues.apache.org/jira/browse/DERBY-1949
>             Project: Derby
>          Issue Type: Bug
>          Components: SQL
>    Affects Versions: 10.1.3.1, 10.2.1.6
>         Environment: N/A
>            Reporter: Oleksandr Alesinskyy
>         Assigned To: Bryan Pendleton
>
> locate function returns false invalid when first parameter is empty string,
> e.g. 
> values(locate('','A')
> results in 1, which is obviously wrong

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Commented: (DERBY-1949) locate function returns invalid value when first parameter is empty string

Posted by "Oleksandr Alesinskyy (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/DERBY-1949?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#action_12484820 ] 

Oleksandr Alesinskyy commented on DERBY-1949:
---------------------------------------------

Yes, I definitely had misread the documentation. While it is not perfect I have to admit that by really careful reading it is possible to understand what is what. The misleading is usage of "search string" term. Usually, it designates a string which is searched inside of other string and in current documentation it is used in opposite sense.

Concerning behavior - as soon as argument meaning is clear, behavior is perfect and need not be changed.

IJ Version 10.2
ij> connect 'd:/work/lms';
ij> values locate(
'1','');
1
-----------
0

1 Zeile ausgewõhlt
ij> values locate('!','"';
FEHLER 42X01: Syntaxfehler: Encountered "<EOF>" at line 1, column 21.
ij> values locate('!','"');
1
-----------
0

1 Zeile ausgewõhlt
ij> values locate('','');
1
-----------
1

1 Zeile ausgewõhlt
ij> values locate('','',2);
1
-----------
2

1 Zeile ausgewõhlt

ij> values locate('','',2);
1
-----------
2

1 Zeile ausgewõhlt
ij> values locate('1','');
1
-----------
0

1 Zeile ausgewõhlt
ij> values locate('1','',2);
1
-----------
0

1 Zeile ausgewõhlt

Concerning parameters order - it is the same as by DB2 and differs from SyBase and Oracle does not support LOCATE at all (INSTR is used instead). In my opinion, it is better to keep the current order.

Proposed documentation change is better then current documentation but still not sompletely clear.

I guess, something like to 
"First CharacterExpression is a string to search for.
Sexond CharacterExpression is a string to search in.
...
if first argument is an empty string then value of third argument is returned (or 1 if it is not specified) even if the 2nd argument is an empty string.
If any of arguments has null value then result is null."


Regards,
Oleksandr



> locate function returns invalid value when first parameter is empty string
> --------------------------------------------------------------------------
>
>                 Key: DERBY-1949
>                 URL: https://issues.apache.org/jira/browse/DERBY-1949
>             Project: Derby
>          Issue Type: Bug
>          Components: SQL
>    Affects Versions: 10.1.3.1, 10.2.1.6
>         Environment: N/A
>            Reporter: Oleksandr Alesinskyy
>         Assigned To: Bryan Pendleton
>         Attachments: docs.diff, rrefsqlj61998.html
>
>
> locate function returns false invalid when first parameter is empty string,
> e.g. 
> values(locate('','A')
> results in 1, which is obviously wrong

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Commented: (DERBY-1949) locate function returns invalid value when first parameter is empty string

Posted by "Kristian Waagan (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/DERBY-1949?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#action_12484790 ] 

Kristian Waagan commented on DERBY-1949:
----------------------------------------

In a patch I recently reviewed:
             if (searchStr == "")
                 return start; // match DB2's SQL LOCATE function

This was for a Clob method, where you specified the string to search for and the starting position in the Clob. I don't even think the start position is verified beyond making sure it is not less than 1.
The code above was not new in the patch, but has been around for a while.

> locate function returns invalid value when first parameter is empty string
> --------------------------------------------------------------------------
>
>                 Key: DERBY-1949
>                 URL: https://issues.apache.org/jira/browse/DERBY-1949
>             Project: Derby
>          Issue Type: Bug
>          Components: SQL
>    Affects Versions: 10.1.3.1, 10.2.1.6
>         Environment: N/A
>            Reporter: Oleksandr Alesinskyy
>         Assigned To: Bryan Pendleton
>         Attachments: docs.diff, rrefsqlj61998.html
>
>
> locate function returns false invalid when first parameter is empty string,
> e.g. 
> values(locate('','A')
> results in 1, which is obviously wrong

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Updated: (DERBY-1949) locate function documentation should clarify behavior when first parameter is empty string

Posted by "Bryan Pendleton (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/DERBY-1949?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Bryan Pendleton updated DERBY-1949:
-----------------------------------

    Component/s: Documentation
    Description: 
Documentation for the locate function does not clearly explain the behavior when first parameter is empty string, e.g. 

values locate('','A')

results in 1, and 

values locate('', 'ABC', 5)

returns 5, but the documentation does not clearly explain why this is so.

  was:
locate function returns false invalid when first parameter is empty string,
e.g. 

values(locate('','A')

results in 1, which is obviously wrong

     Derby Info:   (was: [Existing Application Impact])
        Summary: locate function documentation should clarify behavior when first parameter is empty string  (was: locate function returns invalid value when first parameter is empty string)

Thanks Dan. Good points. I tried to clarify the summary and description. I will also change the resolution.

> locate function documentation should clarify behavior when first parameter is empty string
> ------------------------------------------------------------------------------------------
>
>                 Key: DERBY-1949
>                 URL: https://issues.apache.org/jira/browse/DERBY-1949
>             Project: Derby
>          Issue Type: Bug
>          Components: Documentation, SQL
>    Affects Versions: 10.1.3.1, 10.2.1.6
>         Environment: N/A
>            Reporter: Oleksandr Alesinskyy
>         Assigned To: Bryan Pendleton
>             Fix For: 10.3.0.0
>
>         Attachments: docs.diff, docs_v2.diff, rrefsqlj61998.html, rrefsqlj61998.html
>
>
> Documentation for the locate function does not clearly explain the behavior when first parameter is empty string, e.g. 
> values locate('','A')
> results in 1, and 
> values locate('', 'ABC', 5)
> returns 5, but the documentation does not clearly explain why this is so.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.