--- Ken <[EMAIL PROTECTED]> wrote:
> SQLite documentation indicates that "!" is a unary prefix operator. Is this
> a bug?
Yeah, the docs seem to indicate that SQLite supports '!'.
http://sqlite.org/lang_expr.html:
Supported unary prefix operators are these:
- + ! ~ NOT
If you care to have this operator, see attached patch.
This unary '!' operator works like the NOT operator except
it has the same precedence level as the unary bitwise not
operator '~'.
sqlite> select !!23;
1
sqlite> select !0 + !0;
2
sqlite> select not 0 + not 0;
0
____________________________________________________________________________________
Be a better pen pal.
Text or chat with friends inside Yahoo! Mail. See how.
http://overview.mail.yahoo.com/
Index: src/parse.y
===================================================================
RCS file: /sqlite/sqlite/src/parse.y,v
retrieving revision 1.236
diff -u -3 -p -r1.236 parse.y
--- src/parse.y 17 Nov 2007 22:23:28 -0000 1.236
+++ src/parse.y 18 Nov 2007 05:33:03 -0000
@@ -205,7 +205,7 @@ id(A) ::= ID(X). {A = X;}
%left STAR SLASH REM.
%left CONCAT.
%left COLLATE.
-%right UMINUS UPLUS BITNOT.
+%right UMINUS UPLUS BITNOT UNOT.
// And "ids" is an identifer-or-string.
//
@@ -746,6 +746,10 @@ expr(A) ::= BITNOT(B) expr(X). {
A = sqlite3PExpr(pParse, @B, X, 0, 0);
sqlite3ExprSpan(A,&B,&X->span);
}
+expr(A) ::= UNOT(B) expr(X). {
+ A = sqlite3PExpr(pParse, TK_NOT, X, 0, 0);
+ sqlite3ExprSpan(A,&B,&X->span);
+}
expr(A) ::= MINUS(B) expr(X). [UMINUS] {
A = sqlite3PExpr(pParse, TK_UMINUS, X, 0, 0);
sqlite3ExprSpan(A,&B,&X->span);
Index: src/tokenize.c
===================================================================
RCS file: /sqlite/sqlite/src/tokenize.c,v
retrieving revision 1.136
diff -u -3 -p -r1.136 tokenize.c
--- src/tokenize.c 27 Aug 2007 23:26:59 -0000 1.136
+++ src/tokenize.c 18 Nov 2007 05:33:03 -0000
@@ -203,12 +203,12 @@ static int getToken(const unsigned char
}
}
case '!': {
- if( z[1]!='=' ){
- *tokenType = TK_ILLEGAL;
- return 2;
- }else{
+ if( z[1]=='=' ){
*tokenType = TK_NE;
return 2;
+ }else{
+ *tokenType = TK_UNOT;
+ return 1;
}
}
case '|': {
Index: test/main.test
===================================================================
RCS file: /sqlite/sqlite/test/main.test,v
retrieving revision 1.27
diff -u -3 -p -r1.27 main.test
--- test/main.test 3 Sep 2007 15:42:48 -0000 1.27
+++ test/main.test 18 Nov 2007 05:33:03 -0000
@@ -267,7 +267,7 @@ do_test main-3.1 {
sqlite3 db testdb
set v [catch {execsql {SELECT * from T1 where x!!5}} msg]
lappend v $msg
-} {1 {unrecognized token: "!!"}}
+} {1 {near "!": syntax error}}
do_test main-3.2 {
catch {db close}
foreach f [glob -nocomplain testdb/*] {file delete -force $f}
-----------------------------------------------------------------------------
To unsubscribe, send email to [EMAIL PROTECTED]
-----------------------------------------------------------------------------