Hello,

I'd been looking into a bug in my
application which worked down to
an issue with Bitwise AND and
bound variables in prepared
statements it seems.

The query...

SELECT *
FROM example
WHERE (intColumn & 4294901760) = ?

Where 'intColumn' is an integer
column and the parameter is
bound using sqlite3_bind_int()
always returned zero rows. Even
when that exact query returned
multiple rows from management
tools.

I realized that AND'ing the
parameter with any integer value
fixed this.  Eg...

SELECT *
FROM example
WHERE (intColumn & 4294901760) 
   = (? & 4294967295)

Note that 4294967295 is equal
to 0xFFFFFF and the parameter's
actual value is always the same
width so (? & 4294967295) should
not change the parameter's value.

The second query produces the
results I expected but I'd like
to know why the first query did
not work.

Does anyone have any ideas?

Best regards,
Kervin



-----------------------------------------------------------------------------
To unsubscribe, send email to [EMAIL PROTECTED]
-----------------------------------------------------------------------------

Reply via email to