Re: [sqlite] Invalid Blob Length Error Message

2018-08-17 Thread Clemens Ladisch
Casey Rodarmor wrote:> Hi all,
> unrecognized token: "x'01234'
>
> I know now that the problem was that the blob's length was not a
> multiple of two. However, the error message didn't give me an
> indication of that. Would it be possible to make the error message
> more explicit, to help users debug this error?

Blob literals are parsed in sqlite3GetToken():

case CC_X: {
#ifndef SQLITE_OMIT_BLOB_LITERAL
  testcase( z[0]=='x' ); testcase( z[0]=='X' );
  if( z[1]=='\'' ){
*tokenType = TK_BLOB;
for(i=2; sqlite3Isxdigit(z[i]); i++){}
if( z[i]!='\'' || i%2 ){
  *tokenType = TK_ILLEGAL;
  while( z[i] && z[i]!='\'' ){ i++; }
}
if( z[i] ) i++;
return i;
  }
#endif

At the moment, this function has no mechanism to return an error message;
the only return value is TK_ILLEGAL (resulting in "unrecognized token").

It would be possible to add another parameter, or to introduce several
different TK_ILLEGAL_xxx codes.  However, blob literals are almost never
written by hand, so I doubt that the additional code and maintenance
effort are deemed worth the effort.


Regards,
Clemens
___
sqlite-users mailing list
sqlite-users@mailinglists.sqlite.org
http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users


Re: [sqlite] Invalid Blob Length Error Message

2018-08-17 Thread J Decker
On Fri, Aug 17, 2018 at 5:14 AM Tim Streater  wrote:

> On 17 Aug 2018, at 01:24, Casey Rodarmor  wrote:
>
> > I wrote an erroneous update statement:
> >
> > ```
> > UPDATE foo SET bar = x'01234';
> > ```
> >
> > The error message was:
> >
> > ```
> > unrecognized token: "x'01234'
> > ```
> >
> > *I know now *that the problem was that the blob's length was not a
> > multiple of two. However, the error message didn't give me an
> > indication of that. Would it be possible to make the error message
> > more explicit, to help users debug this error?
>
> I expect the error message is correct, and that what you meant to write
> was:
>
> while 'correct' it's not meaningful is what the OP meant, I beleive.
something like

bad encoding: "x'01234'

would be much more meaningful(?)


> update foo set bar = 0x1234;
>
>
> See:
>
> 
>
> and scroll down to the part about Literal Values (Constants).
>
>
>
>
> --
> Cheers  --  Tim
> ___
> sqlite-users mailing list
> sqlite-users@mailinglists.sqlite.org
> http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users
>
___
sqlite-users mailing list
sqlite-users@mailinglists.sqlite.org
http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users


Re: [sqlite] Invalid Blob Length Error Message

2018-08-17 Thread Tim Streater
On 17 Aug 2018, at 01:24, Casey Rodarmor  wrote:

> I wrote an erroneous update statement:
>
> ```
> UPDATE foo SET bar = x'01234';
> ```
>
> The error message was:
>
> ```
> unrecognized token: "x'01234'
> ```
>
> I know now that the problem was that the blob's length was not a
> multiple of two. However, the error message didn't give me an
> indication of that. Would it be possible to make the error message
> more explicit, to help users debug this error?

I expect the error message is correct, and that what you meant to write was:

update foo set bar = 0x1234;


See:



and scroll down to the part about Literal Values (Constants).




-- 
Cheers  --  Tim
___
sqlite-users mailing list
sqlite-users@mailinglists.sqlite.org
http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users


[sqlite] Invalid Blob Length Error Message

2018-08-17 Thread Casey Rodarmor
Hi all,

I wrote an erroneous update statement:

```
UPDATE foo SET bar = x'01234';
```

The error message was:

```
unrecognized token: "x'01234'
```

I know now that the problem was that the blob's length was not a
multiple of two. However, the error message didn't give me an
indication of that. Would it be possible to make the error message
more explicit, to help users debug this error?

Thanks!

Cordially,
Casey Rodarmor
___
sqlite-users mailing list
sqlite-users@mailinglists.sqlite.org
http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users