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 "Wouter (JIRA)" <ji...@apache.org> on 2010/03/15 16:32:27 UTC

[jira] Created: (DERBY-4583) TRUE by itself is not accepted in WHERE

TRUE by itself is not accepted in WHERE
---------------------------------------

                 Key: DERBY-4583
                 URL: https://issues.apache.org/jira/browse/DERBY-4583
             Project: Derby
          Issue Type: Bug
          Components: SQL
    Affects Versions: 10.5.3.0
         Environment: n/a
            Reporter: Wouter


A SELECT query with a literal boolean value in its WHERE clause results in a syntax error.

How to reproduce:

CREATE TABLE list (value VARCHAR(10));

Given this table, the following queries result in a syntax error.

SELECT * FROM list WHERE TRUE;
SELECT * FROM list WHERE FALSE;
SELECT * FROM list WHERE value='A' OR TRUE;

Why is TRUE/FALSE not a boolean expression?


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


[jira] Commented: (DERBY-4583) TRUE by itself is not accepted in WHERE

Posted by "Rick Hillegas (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/DERBY-4583?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12875616#action_12875616 ] 

Rick Hillegas commented on DERBY-4583:
--------------------------------------

Hi Knut,

I have looked at your question again and I see that the second query does not involve BOOLEANs at all. I have looked at the SQL Standard again and I think that you are right, the UNION between a character type and a boolean type should not work at all and can be rejected at compile-time. That is, Derby should not be performing implicit casts in the query mentioned in DERBY-4684. This is my reasoning:

1) The rules for determining whether two datatypes are union compatible are stated in the SQL Standard in part 2, section 7.3 (<query expression>), syntax rule 20.b.ii.

2) That, in turn, refers the reader to section 9.3 (Result of data type combinations).

3) Section 9.3, syntax rule 3.g says that if either of two values to be merged is BOOLEAN, then both must be BOOLEAN.

> TRUE by itself is not accepted in WHERE
> ---------------------------------------
>
>                 Key: DERBY-4583
>                 URL: https://issues.apache.org/jira/browse/DERBY-4583
>             Project: Derby
>          Issue Type: Bug
>          Components: SQL
>    Affects Versions: 10.5.3.0
>         Environment: n/a
>            Reporter: Wouter
>            Assignee: Rick Hillegas
>         Attachments: derby-4583-01-ac-booleanLiterals.diff
>
>
> A SELECT query with a literal boolean value in its WHERE clause results in a syntax error.
> How to reproduce:
> CREATE TABLE list (value VARCHAR(10));
> Given this table, the following queries result in a syntax error.
> SELECT * FROM list WHERE TRUE;
> SELECT * FROM list WHERE FALSE;
> SELECT * FROM list WHERE value='A' OR TRUE;
> Why is TRUE/FALSE not a boolean expression?

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


[jira] Updated: (DERBY-4583) TRUE by itself is not accepted in WHERE

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

Rick Hillegas updated DERBY-4583:
---------------------------------

    Attachment: derby-4583-01-ad-booleanLiterals.diff

Attaching derby-4583-01-ad-booleanLiterals.diff. This updates the patch to reflect the changes introduced by DERBY-4692: The implicitConversions test now shows that CHAR and BOOLEAN types are not UNION compatible.

I plan to commit this patch if the regression tests pass cleanly.


> TRUE by itself is not accepted in WHERE
> ---------------------------------------
>
>                 Key: DERBY-4583
>                 URL: https://issues.apache.org/jira/browse/DERBY-4583
>             Project: Derby
>          Issue Type: Bug
>          Components: SQL
>    Affects Versions: 10.5.3.0
>         Environment: n/a
>            Reporter: Wouter
>            Assignee: Rick Hillegas
>         Attachments: derby-4583-01-ac-booleanLiterals.diff, derby-4583-01-ad-booleanLiterals.diff
>
>
> A SELECT query with a literal boolean value in its WHERE clause results in a syntax error.
> How to reproduce:
> CREATE TABLE list (value VARCHAR(10));
> Given this table, the following queries result in a syntax error.
> SELECT * FROM list WHERE TRUE;
> SELECT * FROM list WHERE FALSE;
> SELECT * FROM list WHERE value='A' OR TRUE;
> Why is TRUE/FALSE not a boolean expression?

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


[jira] Updated: (DERBY-4583) TRUE by itself is not accepted in WHERE

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

Rick Hillegas updated DERBY-4583:
---------------------------------

    Fix Version/s: 10.7.0.0

> TRUE by itself is not accepted in WHERE
> ---------------------------------------
>
>                 Key: DERBY-4583
>                 URL: https://issues.apache.org/jira/browse/DERBY-4583
>             Project: Derby
>          Issue Type: Bug
>          Components: SQL
>    Affects Versions: 10.5.3.0
>         Environment: n/a
>            Reporter: Wouter
>            Assignee: Rick Hillegas
>             Fix For: 10.7.0.0
>
>         Attachments: derby-4583-01-ac-booleanLiterals.diff, derby-4583-01-ad-booleanLiterals.diff
>
>
> A SELECT query with a literal boolean value in its WHERE clause results in a syntax error.
> How to reproduce:
> CREATE TABLE list (value VARCHAR(10));
> Given this table, the following queries result in a syntax error.
> SELECT * FROM list WHERE TRUE;
> SELECT * FROM list WHERE FALSE;
> SELECT * FROM list WHERE value='A' OR TRUE;
> Why is TRUE/FALSE not a boolean expression?

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


[jira] Updated: (DERBY-4583) TRUE by itself is not accepted in WHERE

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

Rick Hillegas updated DERBY-4583:
---------------------------------

    Attachment: derby-4583-01-ac-booleanLiterals.diff

Attaching derby-4583-01-ac-booleanLiterals.diff. This patch re-enables the boolean literals TRUE and FALSE. The regression tests passed for me after applying this patch.

Touches the following files:

---------

M      java/engine/org/apache/derby/impl/sql/compile/sqlgrammar.jj

Small edit to enable the literals.

---------

M      java/testing/org/apache/derbyTesting/functionTests/tests/lang/BooleanValuesTest.java

New test case to verify that the literals work again.

---------

M      java/testing/org/apache/derbyTesting/functionTests/tests/lang/db2Compatibility.sql
M      java/testing/org/apache/derbyTesting/functionTests/master/db2Compatibility.out
M      java/testing/org/apache/derbyTesting/functionTests/master/implicitConversions.out

Tweaks to other regression tests to reflect the new behavior.


> TRUE by itself is not accepted in WHERE
> ---------------------------------------
>
>                 Key: DERBY-4583
>                 URL: https://issues.apache.org/jira/browse/DERBY-4583
>             Project: Derby
>          Issue Type: Bug
>          Components: SQL
>    Affects Versions: 10.5.3.0
>         Environment: n/a
>            Reporter: Wouter
>            Assignee: Rick Hillegas
>         Attachments: derby-4583-01-ac-booleanLiterals.diff
>
>
> A SELECT query with a literal boolean value in its WHERE clause results in a syntax error.
> How to reproduce:
> CREATE TABLE list (value VARCHAR(10));
> Given this table, the following queries result in a syntax error.
> SELECT * FROM list WHERE TRUE;
> SELECT * FROM list WHERE FALSE;
> SELECT * FROM list WHERE value='A' OR TRUE;
> Why is TRUE/FALSE not a boolean expression?

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


[jira] Commented: (DERBY-4583) TRUE by itself is not accepted in WHERE

Posted by "Kathey Marsden (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/DERBY-4583?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12845395#action_12845395 ] 

Kathey Marsden commented on DERBY-4583:
---------------------------------------

You should be able to use SELECT * FROM list WHERE 1=1;


> TRUE by itself is not accepted in WHERE
> ---------------------------------------
>
>                 Key: DERBY-4583
>                 URL: https://issues.apache.org/jira/browse/DERBY-4583
>             Project: Derby
>          Issue Type: Bug
>          Components: SQL
>    Affects Versions: 10.5.3.0
>         Environment: n/a
>            Reporter: Wouter
>
> A SELECT query with a literal boolean value in its WHERE clause results in a syntax error.
> How to reproduce:
> CREATE TABLE list (value VARCHAR(10));
> Given this table, the following queries result in a syntax error.
> SELECT * FROM list WHERE TRUE;
> SELECT * FROM list WHERE FALSE;
> SELECT * FROM list WHERE value='A' OR TRUE;
> Why is TRUE/FALSE not a boolean expression?

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


[jira] Commented: (DERBY-4583) TRUE by itself is not accepted in WHERE

Posted by "Knut Anders Hatlen (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/DERBY-4583?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12875558#action_12875558 ] 

Knut Anders Hatlen commented on DERBY-4583:
-------------------------------------------

The fix looks good to me, but I was a little puzzled by the update of the master for implicitConversion.sql.

ij> values true, 'a';
1    
-----
true 
ERROR 22018: Invalid character string format for type BOOLEAN.
ij> values 'a', true;
1    
-----
ERROR 22018: Invalid character string format for type BOOLEAN.

I would have expected that these statements had failed at compile-time, just like this similar statement:

ij> values 'a', 1.1;
ERROR 42X61: Types 'CHAR' and 'DECIMAL' are not UNION compatible.

Do you know what causes this difference?

> TRUE by itself is not accepted in WHERE
> ---------------------------------------
>
>                 Key: DERBY-4583
>                 URL: https://issues.apache.org/jira/browse/DERBY-4583
>             Project: Derby
>          Issue Type: Bug
>          Components: SQL
>    Affects Versions: 10.5.3.0
>         Environment: n/a
>            Reporter: Wouter
>            Assignee: Rick Hillegas
>         Attachments: derby-4583-01-ac-booleanLiterals.diff
>
>
> A SELECT query with a literal boolean value in its WHERE clause results in a syntax error.
> How to reproduce:
> CREATE TABLE list (value VARCHAR(10));
> Given this table, the following queries result in a syntax error.
> SELECT * FROM list WHERE TRUE;
> SELECT * FROM list WHERE FALSE;
> SELECT * FROM list WHERE value='A' OR TRUE;
> Why is TRUE/FALSE not a boolean expression?

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


[jira] Resolved: (DERBY-4583) TRUE by itself is not accepted in WHERE

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

Rick Hillegas resolved DERBY-4583.
----------------------------------

    Issue & fix info:   (was: [Patch Available])
          Resolution: Fixed

Committed derby-4583-01-ad-booleanLiterals.diff at subversion revision 952348. The tests ran cleanly for me except for the following error in NetworkServerMBeanTest. The test passed when I re-ran it standalone. I believe that the error is a timing-related heisenbug in that test and is not related to the changes in this patch.

There was 1 error:
1) testAttributeAccumulatedConnectionCount(org.apache.derbyTesting.functionTests.tests.management.NetworkServerMBeanTest)java.security.PrivilegedActionException: javax.management.InstanceNotFoundException: org.apache.derby:type=NetworkServer,system=c013800d-0129-1374-c722-ffffe1d7aa3e
	at java.security.AccessController.doPrivileged(Native Method)
	at org.apache.derbyTesting.functionTests.tests.management.MBeanTest.getAttribute(MBeanTest.java:379)
	at org.apache.derbyTesting.functionTests.tests.management.NetworkServerMBeanTest.testAttributeAccumulatedConnectionCount(NetworkServerMBeanTest.java:93)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
	at org.apache.derbyTesting.junit.BaseTestCase.runBare(BaseTestCase.java:109)
	at junit.extensions.TestDecorator.basicRun(TestDecorator.java:24)
	at junit.extensions.TestSetup$1.protect(TestSetup.java:21)
	at junit.extensions.TestSetup.run(TestSetup.java:25)
	at org.apache.derbyTesting.junit.BaseTestSetup.run(BaseTestSetup.java:57)
	at junit.extensions.TestDecorator.basicRun(TestDecorator.java:24)
	at junit.extensions.TestSetup$1.protect(TestSetup.java:21)
	at junit.extensions.TestSetup.run(TestSetup.java:25)
	at junit.extensions.TestDecorator.basicRun(TestDecorator.java:24)
	at junit.extensions.TestSetup$1.protect(TestSetup.java:21)
	at junit.extensions.TestSetup.run(TestSetup.java:25)
	at org.apache.derbyTesting.junit.BaseTestSetup.run(BaseTestSetup.java:57)
Caused by: javax.management.InstanceNotFoundException: org.apache.derby:type=NetworkServer,system=c013800d-0129-1374-c722-ffffe1d7aa3e
	at com.sun.jmx.interceptor.DefaultMBeanServerInterceptor.getMBean(DefaultMBeanServerInterceptor.java:1010)
	at com.sun.jmx.interceptor.DefaultMBeanServerInterceptor.getAttribute(DefaultMBeanServerInterceptor.java:627)
	at com.sun.jmx.mbeanserver.JmxMBeanServer.getAttribute(JmxMBeanServer.java:659)
	at org.apache.derbyTesting.functionTests.tests.management.MBeanTest$4.run(MBeanTest.java:382)
	... 41 more


> TRUE by itself is not accepted in WHERE
> ---------------------------------------
>
>                 Key: DERBY-4583
>                 URL: https://issues.apache.org/jira/browse/DERBY-4583
>             Project: Derby
>          Issue Type: Bug
>          Components: SQL
>    Affects Versions: 10.5.3.0
>         Environment: n/a
>            Reporter: Wouter
>            Assignee: Rick Hillegas
>         Attachments: derby-4583-01-ac-booleanLiterals.diff, derby-4583-01-ad-booleanLiterals.diff
>
>
> A SELECT query with a literal boolean value in its WHERE clause results in a syntax error.
> How to reproduce:
> CREATE TABLE list (value VARCHAR(10));
> Given this table, the following queries result in a syntax error.
> SELECT * FROM list WHERE TRUE;
> SELECT * FROM list WHERE FALSE;
> SELECT * FROM list WHERE value='A' OR TRUE;
> Why is TRUE/FALSE not a boolean expression?

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


[jira] Assigned: (DERBY-4583) TRUE by itself is not accepted in WHERE

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

Rick Hillegas reassigned DERBY-4583:
------------------------------------

    Assignee: Rick Hillegas

> TRUE by itself is not accepted in WHERE
> ---------------------------------------
>
>                 Key: DERBY-4583
>                 URL: https://issues.apache.org/jira/browse/DERBY-4583
>             Project: Derby
>          Issue Type: Bug
>          Components: SQL
>    Affects Versions: 10.5.3.0
>         Environment: n/a
>            Reporter: Wouter
>            Assignee: Rick Hillegas
>
> A SELECT query with a literal boolean value in its WHERE clause results in a syntax error.
> How to reproduce:
> CREATE TABLE list (value VARCHAR(10));
> Given this table, the following queries result in a syntax error.
> SELECT * FROM list WHERE TRUE;
> SELECT * FROM list WHERE FALSE;
> SELECT * FROM list WHERE value='A' OR TRUE;
> Why is TRUE/FALSE not a boolean expression?

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


[jira] Updated: (DERBY-4583) TRUE by itself is not accepted in WHERE

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

Rick Hillegas updated DERBY-4583:
---------------------------------

    Issue & fix info: [Patch Available]

> TRUE by itself is not accepted in WHERE
> ---------------------------------------
>
>                 Key: DERBY-4583
>                 URL: https://issues.apache.org/jira/browse/DERBY-4583
>             Project: Derby
>          Issue Type: Bug
>          Components: SQL
>    Affects Versions: 10.5.3.0
>         Environment: n/a
>            Reporter: Wouter
>            Assignee: Rick Hillegas
>         Attachments: derby-4583-01-ac-booleanLiterals.diff
>
>
> A SELECT query with a literal boolean value in its WHERE clause results in a syntax error.
> How to reproduce:
> CREATE TABLE list (value VARCHAR(10));
> Given this table, the following queries result in a syntax error.
> SELECT * FROM list WHERE TRUE;
> SELECT * FROM list WHERE FALSE;
> SELECT * FROM list WHERE value='A' OR TRUE;
> Why is TRUE/FALSE not a boolean expression?

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


[jira] Commented: (DERBY-4583) TRUE by itself is not accepted in WHERE

Posted by "Knut Anders Hatlen (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/DERBY-4583?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12845378#action_12845378 ] 

Knut Anders Hatlen commented on DERBY-4583:
-------------------------------------------

Derby does not support the BOOLEAN data type. See DERBY-499.

> TRUE by itself is not accepted in WHERE
> ---------------------------------------
>
>                 Key: DERBY-4583
>                 URL: https://issues.apache.org/jira/browse/DERBY-4583
>             Project: Derby
>          Issue Type: Bug
>          Components: SQL
>    Affects Versions: 10.5.3.0
>         Environment: n/a
>            Reporter: Wouter
>
> A SELECT query with a literal boolean value in its WHERE clause results in a syntax error.
> How to reproduce:
> CREATE TABLE list (value VARCHAR(10));
> Given this table, the following queries result in a syntax error.
> SELECT * FROM list WHERE TRUE;
> SELECT * FROM list WHERE FALSE;
> SELECT * FROM list WHERE value='A' OR TRUE;
> Why is TRUE/FALSE not a boolean expression?

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


[jira] Commented: (DERBY-4583) TRUE by itself is not accepted in WHERE

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

Bryan Pendleton commented on DERBY-4583:
----------------------------------------

Or just use SELECT * FROM list. The WHERE clause is optional.

> TRUE by itself is not accepted in WHERE
> ---------------------------------------
>
>                 Key: DERBY-4583
>                 URL: https://issues.apache.org/jira/browse/DERBY-4583
>             Project: Derby
>          Issue Type: Bug
>          Components: SQL
>    Affects Versions: 10.5.3.0
>         Environment: n/a
>            Reporter: Wouter
>
> A SELECT query with a literal boolean value in its WHERE clause results in a syntax error.
> How to reproduce:
> CREATE TABLE list (value VARCHAR(10));
> Given this table, the following queries result in a syntax error.
> SELECT * FROM list WHERE TRUE;
> SELECT * FROM list WHERE FALSE;
> SELECT * FROM list WHERE value='A' OR TRUE;
> Why is TRUE/FALSE not a boolean expression?

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


[jira] Commented: (DERBY-4583) TRUE by itself is not accepted in WHERE

Posted by "Knut Anders Hatlen (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/DERBY-4583?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12875610#action_12875610 ] 

Knut Anders Hatlen commented on DERBY-4583:
-------------------------------------------

I see. Thanks for explaining. So the statement below is valid and should return two booleans?

    VALUES 'TRUE', TRUE

If so, the behaviour makes sense. +1 from me.

> TRUE by itself is not accepted in WHERE
> ---------------------------------------
>
>                 Key: DERBY-4583
>                 URL: https://issues.apache.org/jira/browse/DERBY-4583
>             Project: Derby
>          Issue Type: Bug
>          Components: SQL
>    Affects Versions: 10.5.3.0
>         Environment: n/a
>            Reporter: Wouter
>            Assignee: Rick Hillegas
>         Attachments: derby-4583-01-ac-booleanLiterals.diff
>
>
> A SELECT query with a literal boolean value in its WHERE clause results in a syntax error.
> How to reproduce:
> CREATE TABLE list (value VARCHAR(10));
> Given this table, the following queries result in a syntax error.
> SELECT * FROM list WHERE TRUE;
> SELECT * FROM list WHERE FALSE;
> SELECT * FROM list WHERE value='A' OR TRUE;
> Why is TRUE/FALSE not a boolean expression?

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


[jira] Commented: (DERBY-4583) TRUE by itself is not accepted in WHERE

Posted by "Wouter (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/DERBY-4583?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12845394#action_12845394 ] 

Wouter commented on DERBY-4583:
-------------------------------

Fair enough. But in this particular case Derby actually demands a boolean expression.

ij(CONNECTION1)> SELECT * FROM list WHERE 1;
ERROR 42X19: The WHERE or HAVING clause or CHECK CONSTRAINT definition is a 'INTEGER' expression.  It must be a BOOLEAN expression.

Which is rather confusing if there is no support for booleans...

> TRUE by itself is not accepted in WHERE
> ---------------------------------------
>
>                 Key: DERBY-4583
>                 URL: https://issues.apache.org/jira/browse/DERBY-4583
>             Project: Derby
>          Issue Type: Bug
>          Components: SQL
>    Affects Versions: 10.5.3.0
>         Environment: n/a
>            Reporter: Wouter
>
> A SELECT query with a literal boolean value in its WHERE clause results in a syntax error.
> How to reproduce:
> CREATE TABLE list (value VARCHAR(10));
> Given this table, the following queries result in a syntax error.
> SELECT * FROM list WHERE TRUE;
> SELECT * FROM list WHERE FALSE;
> SELECT * FROM list WHERE value='A' OR TRUE;
> Why is TRUE/FALSE not a boolean expression?

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


[jira] Commented: (DERBY-4583) TRUE by itself is not accepted in WHERE

Posted by "Rick Hillegas (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/DERBY-4583?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12875593#action_12875593 ] 

Rick Hillegas commented on DERBY-4583:
--------------------------------------

Hi Knut,

Thanks for taking a look at the patch. The short answer is that the compiler merely relies on type information to raise that error. The compiler knows that a numeric can never be cast to a BOOLEAN and so can reject the latter query early on. In contrast, some strings can be cast to BOOLEAN (e.g., 'TRUE' and 'FALSE'). Derby waits until execution-time to check this. It's true that the compiler could be smart enough to run the execution-time checks on string constants. Derby just isn't that smart today.

> TRUE by itself is not accepted in WHERE
> ---------------------------------------
>
>                 Key: DERBY-4583
>                 URL: https://issues.apache.org/jira/browse/DERBY-4583
>             Project: Derby
>          Issue Type: Bug
>          Components: SQL
>    Affects Versions: 10.5.3.0
>         Environment: n/a
>            Reporter: Wouter
>            Assignee: Rick Hillegas
>         Attachments: derby-4583-01-ac-booleanLiterals.diff
>
>
> A SELECT query with a literal boolean value in its WHERE clause results in a syntax error.
> How to reproduce:
> CREATE TABLE list (value VARCHAR(10));
> Given this table, the following queries result in a syntax error.
> SELECT * FROM list WHERE TRUE;
> SELECT * FROM list WHERE FALSE;
> SELECT * FROM list WHERE value='A' OR TRUE;
> Why is TRUE/FALSE not a boolean expression?

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