Re: [sqlite] Documentation bug. Detecting NULL extension arguments.

2017-06-30 Thread Richard Hipp
On 6/30/17, petern  wrote:
> sqlite3_value_type() definitely deserves at least one document sentence

The change at https://www.sqlite.org/src/info/0db20efe201736b3 will
appear in the next release.


-- 
D. Richard Hipp
d...@sqlite.org
___
sqlite-users mailing list
sqlite-users@mailinglists.sqlite.org
http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users


Re: [sqlite] Documentation bug. Detecting NULL extension arguments.

2017-06-30 Thread petern
Thank you for the quick reply.

After reading your reply and grepping around for more examples containing
sqlite3_type_value I see now the documentation gives the impression that
return types only apply to  sqlite3_value_numeric_type().   Had I clicked
randomly on the link to https://sqlite.org/c3ref/c_blob.html in that
unrelated paragraph I would have seen this wonderful exhibit:

#define SQLITE_INTEGER  1
#define SQLITE_FLOAT2
#define SQLITE_BLOB 4
#define SQLITE_NULL 5
#ifdef SQLITE_TEXT
# undef SQLITE_TEXT
#else
# define SQLITE_TEXT 3
#endif
#define SQLITE3_TEXT 3


sqlite3_value_type() definitely deserves at least one document sentence
within https://sqlite.org/c3ref/value_blob.html containing the link to
https://sqlite.org/c3ref/c_blob.html



On Fri, Jun 30, 2017 at 10:26 AM, Richard Hipp  wrote:

> On 6/30/17, petern  wrote:
> > Is this the recommended way for any argument type?
> >
> >   zCol = (const char*)sqlite3_value_text(argv[i]);
> >   if( 0==zCol ) return;
>
> No.  What you have above detects out-of-memory errors when trying to
> convert an argument in some non-TEXT type in to TEXT, or when
> converting a UTF-16 text string into the requested UTF-8.
>
> To get the argument type, use:
>
>sqlite3_value_type(argv[i])
>
>
> >
> > Docs say protected_sqlite3_value can represent NULL but how is not
> > explained anywhere.
> >
> > https://www.sqlite.org/c3ref/value_blob.html
> > https://www.sqlite.org/c3ref/value.html
> >
> > To detect NULL arguments is it normal to test with sqlite3_value_text on
> > every type of argument including BLOB, double, int,..?   Or, are there
> some
> > special sentinel values {MAX_INT,DBL_MAX,...} for those other types?
> >
> > I'd be happily corrected if wrong, but it seems C API NULL value
> > representation is not explained anywhere in the SQLite docs. The short
> > answer to this question would make a well needed addition to one of those
> > doc pages.
> > ___
> > sqlite-users mailing list
> > sqlite-users@mailinglists.sqlite.org
> > http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users
> >
>
>
> --
> D. Richard Hipp
> d...@sqlite.org
> ___
> 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] Documentation bug. Detecting NULL extension arguments.

2017-06-30 Thread Richard Hipp
On 6/30/17, petern  wrote:
> Is this the recommended way for any argument type?
>
>   zCol = (const char*)sqlite3_value_text(argv[i]);
>   if( 0==zCol ) return;

No.  What you have above detects out-of-memory errors when trying to
convert an argument in some non-TEXT type in to TEXT, or when
converting a UTF-16 text string into the requested UTF-8.

To get the argument type, use:

   sqlite3_value_type(argv[i])


>
> Docs say protected_sqlite3_value can represent NULL but how is not
> explained anywhere.
>
> https://www.sqlite.org/c3ref/value_blob.html
> https://www.sqlite.org/c3ref/value.html
>
> To detect NULL arguments is it normal to test with sqlite3_value_text on
> every type of argument including BLOB, double, int,..?   Or, are there some
> special sentinel values {MAX_INT,DBL_MAX,...} for those other types?
>
> I'd be happily corrected if wrong, but it seems C API NULL value
> representation is not explained anywhere in the SQLite docs. The short
> answer to this question would make a well needed addition to one of those
> doc pages.
> ___
> sqlite-users mailing list
> sqlite-users@mailinglists.sqlite.org
> http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users
>


-- 
D. Richard Hipp
d...@sqlite.org
___
sqlite-users mailing list
sqlite-users@mailinglists.sqlite.org
http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users


[sqlite] Documentation bug. Detecting NULL extension arguments.

2017-06-30 Thread petern
Is this the recommended way for any argument type?

  zCol = (const char*)sqlite3_value_text(argv[i]);
  if( 0==zCol ) return;

Docs say protected_sqlite3_value can represent NULL but how is not
explained anywhere.

https://www.sqlite.org/c3ref/value_blob.html
https://www.sqlite.org/c3ref/value.html

To detect NULL arguments is it normal to test with sqlite3_value_text on
every type of argument including BLOB, double, int,..?   Or, are there some
special sentinel values {MAX_INT,DBL_MAX,...} for those other types?

I'd be happily corrected if wrong, but it seems C API NULL value
representation is not explained anywhere in the SQLite docs. The short
answer to this question would make a well needed addition to one of those
doc pages.
___
sqlite-users mailing list
sqlite-users@mailinglists.sqlite.org
http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users


Re: [sqlite] [OT] UTF8-BOM and text encoding detection (was: UTF8-BOM not disregarded in CSV import)

2017-06-30 Thread Niall O'Reilly

On 29 Jun 2017, at 20:19, Peter da Silva wrote:

The DECsystem 10 guys also referred to the other subdivisions of their 
36 bit words as bytes, sometimes, they could be 6, 7, 8, or 9 bits 
long. I think they had special instructions for operating on them, but 
they weren’t directly addressable.


  A byte could be 1..36 bits long.

  The special instructions used a data structure called a byte pointer
  to reference the field within a word where the byte was to be placed
  or retrieved.  Four different formats of byte pointer existed, not 
all

  supporting the full range of possible byte sizes.

  One of these days, when I really have too much free time, I must run
  up a VM with the Panda TOPS-20 distro and find some examples of
  interesting byte sizes which were actually used for something. 8-)

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


Re: [sqlite] INSERT ... VALUES / want to "skip" default values

2017-06-30 Thread Robert M. Münch
On 29 Jun 2017, at 19:06, Jens Alfke wrote:

>> On Jun 29, 2017, at 12:13 AM, Hick Gunter  wrote:
>>
>> Double quotes is specifically for building identifiers that "look strange" 
>> (i.e. embedded spaces, keywords, ...) which IMHO should be avoided because 
>> it tends to clutter up the statement.
>
> I agree that if you’re generating the schema by hand you should avoid 
> creating names that require quoting.
>
> However, if tables/columns/indexes are being generated dynamically, it can be 
> very convenient to name them based on the external item that uses them, and 
> that name might involve “strange” characters.

Yes, I wrote a big function that strips all non-conforming chars, words etc. 
from column names (since we use '...' and I got some errors) because we import 
CSV user data into a table where the columns are the CSV columns.

I might x-check to see if I can switch to "..." and avoid all the hassle at all.


> In my case, I create indexes on the fly based on JSON paths like 
> “address[0].zipcode”, so I use the path as part of the index name. This is 
> simpler than escaping the punctuation, using a digest of the path, or making 
> up an identifier that then has to be stored somewhere else.

Good point. We need to do the same in the future.

> It also makes the schema a lot easier to understand when looking at generated 
> statements or poking around in the sqlite3 tool.

True too.

-- 

Robert M. Münch, CEO
M: +41 79 65 11 49 6

Saphirion AG
smarter | better | faster

http://www.saphirion.com
http://www.nlpp.ch


signature.asc
Description: OpenPGP digital signature
___
sqlite-users mailing list
sqlite-users@mailinglists.sqlite.org
http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users