[sqlite] Comments in VDBE program

2015-04-16 Thread Sairam Gaddam
Thanks! Comments are enabled now.

On Thu, Apr 16, 2015 at 4:41 PM, Richard Hipp  wrote:

> On 4/16/15, Sairam Gaddam  wrote:
> > I am using C SQLite interface. How to enable comments in the VDBE program
> > here?
> > because they are not enabled by default.
> > gcc -DSQLITE -DEBUG filename.c ../sqlite3.c -ldl -lpthread
> > I tried with the above line in the terminal but could not succeed in
> > enabling the comments. Can any one help me with this?
> > I am using Linux 64 bit machine.
>
> Add -DSQLITE_ENABLE_EXPLAIN_COMMENTS to the compiler command-line.
>
> > ___
> > sqlite-users mailing list
> > sqlite-users at mailinglists.sqlite.org
> > http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users
> >
>
>
> --
> D. Richard Hipp
> drh at sqlite.org
> ___
> sqlite-users mailing list
> sqlite-users at mailinglists.sqlite.org
> http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users
>


[sqlite] Problems with pragma journal_mode

2015-04-16 Thread Simon Slavin

On 16 Apr 2015, at 2:33pm, Janke, Julian  wrote:

> rc = sqlite3_step(stmt);
> --> returns SQLITE_DONE

After the above two lines, print the value returned by

sqlite3_column_text(stmt, 0)

I'm not good at C off the top of my head but I think it's something like

-

const unsigned char * theText;

[...]

rc = sqlite3_prepare_v2(db, "PRAGMA journal_mode=WAL;", 24, , NULL);

rc = sqlite3_step(stmt);
theText  = sqlite3_column_text (stmt, 0);
printf ("text returned: %s", theText);

rc = sqlite3_finalize(stmt);

-

Hope if I got it wrong someone else will tell you.  By the way, you can also 
check the values returned from sqlite3_finalize() and sqlite3_close() since 
they can tell you useful things if something went wrong.

Simon.


[sqlite] Comments in VDBE program

2015-04-16 Thread Sairam Gaddam
I am using C SQLite interface. How to enable comments in the VDBE program
here?
because they are not enabled by default.
gcc -DSQLITE -DEBUG filename.c ../sqlite3.c -ldl -lpthread
I tried with the above line in the terminal but could not succeed in
enabling the comments. Can any one help me with this?
I am using Linux 64 bit machine.


[sqlite] Problems with pragma journal_mode

2015-04-16 Thread Janke, Julian
Ok, actually I'm a little bit confused, never used prepare(), step() and 
finalize() manually before.
Maybe it's his absolute basics are missing me here, but maybe someone can still 
help me
On which point I should get "wal" back?

I changed my code to the following:

rc = sqlite3_open(dbPath, );
sqlite3_exec(db, "DROP TABLE IF EXISTS nosuchtable;", testCallbackPrint, 0, 
);
rc = sqlite3_prepare_v2(db, "PRAGMA journal_mode=WAL;", 24, , NULL);
--> returns SQLITE_OK

rc = sqlite3_step(stmt);
--> returns SQLITE_DONE

sqlite3_finalize(stmt);
sqlite3_exec(db, "DROP TABLE IF EXISTS nosuchtable;", testCallbackPrint, 0, 
);
[...]
sqlite3_close(db);


Thanks.

-Original Message-
From: sqlite-users-bounces at mailinglists.sqlite.org 
[mailto:sqlite-users-boun...@mailinglists.sqlite.org] On Behalf Of Simon Slavin
Sent: Donnerstag, 16. April 2015 14:15
To: General Discussion of SQLite Database
Subject: Re: [sqlite] Problems with pragma journal_mode


On 16 Apr 2015, at 10:10am, Janke, Julian  wrote:

> rc = sqlite3_open(dbPath, );
> rc = sqlite3_exec(db, "PRAGMA journal_mode=WAL;", testCallbackPrint,
> 0, ); [?] sqlite3_close(db);

Execute your PRAGMA as if it's a SELECT call (i.e. use sqlite3_prepare_v2(), 
sqlite3_step(), and sqlite3_finalize()) and check the value returned by 
_step().  If the command worked you should get "wal" back.

Before and after your existing PRAGMA, submit any SQL command that needs 
database access.  For example

DROP TABLE IF EXISTS nosuchtable;
PRAGMA journal_mode=WAL;
DROP TABLE IF EXISTS nosuchtable;

You can use _exec() for these other commands.  I do not know that this is 
definitely your problem, but I seem to remember that there has to be some kind 
of file access for a journal mode change to take effect.

In connection with another post to this thread, you should be able to change 
the journal mode at any time you have the only connection to the database.  
This includes changing between traditional journal modes and WAL mode.

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



Firma: Capgemini Deutschland GmbH
Aufsichtsratsvorsitzender: Antonio Schnieder ? Gesch?ftsf?hrer: Dr. Michael 
Schulte (Sprecher) ? Jost F?rster ? Dr. Peter Lempp ? Dr. Volkmar Varnhagen

Amtsgericht Berlin-Charlottenburg, HRB 98814
This message contains information that may be privileged or confidential and is 
the property of the Capgemini Group. It is intended only for the person to whom 
it is addressed. If you are not the intended recipient, you are not authorized 
to read, print, retain, copy, disseminate, distribute, or use this message or 
any part thereof. If you receive this message in error, please notify the 
sender immediately and delete all copies of this message.


[sqlite] Problems with pragma journal_mode

2015-04-16 Thread Simon Slavin

On 16 Apr 2015, at 10:10am, Janke, Julian  wrote:

> rc = sqlite3_open(dbPath, );
> rc = sqlite3_exec(db, "PRAGMA journal_mode=WAL;", testCallbackPrint, 0, 
> );
> [?]
> sqlite3_close(db);

Execute your PRAGMA as if it's a SELECT call (i.e. use sqlite3_prepare_v2(), 
sqlite3_step(), and sqlite3_finalize()) and check the value returned by 
_step().  If the command worked you should get "wal" back.

Before and after your existing PRAGMA, submit any SQL command that needs 
database access.  For example

DROP TABLE IF EXISTS nosuchtable;
PRAGMA journal_mode=WAL;
DROP TABLE IF EXISTS nosuchtable;

You can use _exec() for these other commands.  I do not know that this is 
definitely your problem, but I seem to remember that there has to be some kind 
of file access for a journal mode change to take effect.

In connection with another post to this thread, you should be able to change 
the journal mode at any time you have the only connection to the database.  
This includes changing between traditional journal modes and WAL mode.

Simon.


[sqlite] Request: Metadata about C API constants and functions

2015-04-16 Thread James K. Lowden
On Thu, 16 Apr 2015 00:40:28 +0100
Simon Slavin  wrote:

> > It is a very productive time when you
> > get to delete code :-)
> 
> 

"[If] we wish to count lines of code, we should not regard
them as "lines produced" but as "lines spent": the current conventional
wisdom is so foolish as to book that count on the wrong side of the
ledger."
--EWD, On the cruelty of really teaching computing science
http://www.cs.utexas.edu/users/EWD/transcriptions/EWD10xx/EWD1036.html


[sqlite] Problems with pragma journal_mode

2015-04-16 Thread Clemens Ladisch
Janke, Julian wrote:
> PRAGMA journal_mode=WAL;
>
> Unfortunately, after these lines, the journal mode is not changed.
>
> -DSQLITE_OS_OTHER=1

Do you have mmap support?

 says:
| WAL normally requires that the VFS support shared-memory primitives.
| The built-in unix and windows VFSes support this but third-party
| extension VFSes for custom operating systems might not.

But  says:
| Use of WAL Without Shared-Memory
|
| Beginning in SQLite version 3.7.4, WAL databases can be created, read,
| and written even if shared memory is unavailable as long as the
| locking_mode is set to EXCLUSIVE before the first attempted access. In
| other words, a process can interact with a WAL database without using
| shared memory if that process is guaranteed to be the only process
| accessing the database. This feature allows WAL databases to be
| created, read, and written by legacy VFSes that lack the "version 2"
| shared-memory methods xShmMap, xShmLock, xShmBarrier, and xShmUnmap on
| the sqlite3_io_methods object.


Regards,
Clemens


[sqlite] Problems with pragma journal_mode

2015-04-16 Thread Dominique Devienne
On Thu, Apr 16, 2015 at 11:10 AM, Janke, Julian 
wrote:

> I want to change the journal mode of a database to WAL. So I did the
> following:
>
> rc = sqlite3_open(dbPath, );
> rc = sqlite3_exec(db, "PRAGMA journal_mode=WAL;", testCallbackPrint, 0,
> );
> [?]
> sqlite3_close(db);
>
> Unfortunately, after these lines, the journal mode is not changed. The
> sqlite3_exec function returns SQLITE_OK (0),
>

>From http://www.sqlite.org/pragma.html#pragma_journal_mode:
The WAL journaling mode is persistent; after being set it stays in effect
across multiple database connections and after closing and reopening the
database

And once set, you cannot change it I believe. You decide on WAL or non-WAL
before creating any object in the DB, and from that point on, you can't
change it. --DD


[sqlite] Hex literals not working?

2015-04-16 Thread Ketil Froyn
Thanks, I should have searched the changelog!

On 16 April 2015 at 10:34, Zsb?n Ambrus  wrote:
> On Thu, Apr 16, 2015 at 10:29 AM, Ketil Froyn  wrote:
>> Hexadecimal integer literals follow the C-language notation of
>> "0x" or "0X" followed
>> by hexadecimal digits. For example, 0x1234 means the same as 4660...
>>
>> Am I doing sometihng wrong? Or is this a feature that is newer than
>> Ubuntu 14.04's bundled sqlite3, which is 3.8.2?
>
> See http://sqlite.org/changes.html which tells you that hexadecimal
> literals are available from sqlite version 3.8.6.
>
> -- ambrus
> ___
> sqlite-users mailing list
> sqlite-users at mailinglists.sqlite.org
> http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users



-- 
-Ketil


[sqlite] Hex literals not working?

2015-04-16 Thread Zsbán Ambrus
On Thu, Apr 16, 2015 at 10:29 AM, Ketil Froyn  wrote:
> Hexadecimal integer literals follow the C-language notation of
> "0x" or "0X" followed
> by hexadecimal digits. For example, 0x1234 means the same as 4660...
>
> Am I doing sometihng wrong? Or is this a feature that is newer than
> Ubuntu 14.04's bundled sqlite3, which is 3.8.2?

See http://sqlite.org/changes.html which tells you that hexadecimal
literals are available from sqlite version 3.8.6.

-- ambrus


[sqlite] Hex literals not working?

2015-04-16 Thread Ketil Froyn
On https://sqlite.org/lang_expr.html under "Literal Values (Constants)", I read:

Hexadecimal integer literals follow the C-language notation of
"0x" or "0X" followed
by hexadecimal digits. For example, 0x1234 means the same as 4660...

However, this doesn't seem to work for me:

sqlite> select 12;
12
sqlite> select 0x12;
Error: unrecognized token: "0x12"

Am I doing sometihng wrong? Or is this a feature that is newer than
Ubuntu 14.04's bundled sqlite3, which is 3.8.2?

-Ketil


[sqlite] Problems with pragma journal_mode

2015-04-16 Thread Simon Davies
On 16 April 2015 at 10:10, Janke, Julian  wrote:
> Hi everyone,
>
> I'm relatively new to SQLite and currently I'm experimenting a little bit 
> with the SQLite database on an embedded system.
> I want to change the journal mode of a database to WAL. So I did the 
> following:
>
> rc = sqlite3_open(dbPath, );
> rc = sqlite3_exec(db, "PRAGMA journal_mode=WAL;", testCallbackPrint, 0, 
> );
> [?]
> sqlite3_close(db);
>
> Unfortunately, after these lines, the journal mode is not changed. The 
> sqlite3_exec function returns SQLITE_OK (0),
> testCallbackPrint is never called and the error message is empty.
> Also reading the value of journal mode with ?PRAGMA journal_mode;? leads to 
> the same result (rc=0, callback noch called and error message is empty).

What version of SQLite?

...
>
> Thanks.

Regards,
Smon


[sqlite] lemon problem with two versions of lempar.c

2015-04-16 Thread Neo Anderson
I am utilizing lemon in one of my Apple Store Apps. My parser works fine with 
the 'old' lempar.c found in source tree TRUNK/tool/.I also found a 
newer version in TRUNK/src, but when I compile myparser.c generated using this 
lempar.c, I got compilation errors:test.c:376:7: error: use of 
undeclared identifier 'NEVER' if( NEVER(pParser-yyidx0) ) 
return 0;How can I solve this error? BTW, does this newer lempar.c 
benefit my parser more than the old one?



[sqlite] Problems with pragma journal_mode

2015-04-16 Thread Janke, Julian
No there are no mmap support in the vfs.
So I need also -DSQLITE_DEFAULT_LOCKING_MODE=1 in my compile time options, 
right?

Recompile and retested it, but still the same behavior (also on an empty new 
db).

I am surprised that

sqlite3_exec(db, "PRAGMA journal_mode;", testCallbackPrint, 0, );

has absolutly no effect.
Should I not get at least the default journal mode as answer?



-Original Message-
From: sqlite-users-bounces at mailinglists.sqlite.org 
[mailto:sqlite-users-boun...@mailinglists.sqlite.org] On Behalf Of Clemens 
Ladisch
Sent: Donnerstag, 16. April 2015 11:23
To: sqlite-users at mailinglists.sqlite.org
Subject: Re: [sqlite] Problems with pragma journal_mode

Janke, Julian wrote:
> PRAGMA journal_mode=WAL;
>
> Unfortunately, after these lines, the journal mode is not changed.
>
> -DSQLITE_OS_OTHER=1

Do you have mmap support?

 says:
| WAL normally requires that the VFS support shared-memory primitives.
| The built-in unix and windows VFSes support this but third-party
| extension VFSes for custom operating systems might not.

But  says:
| Use of WAL Without Shared-Memory
|
| Beginning in SQLite version 3.7.4, WAL databases can be created, read,
| and written even if shared memory is unavailable as long as the
| locking_mode is set to EXCLUSIVE before the first attempted access. In
| other words, a process can interact with a WAL database without using
| shared memory if that process is guaranteed to be the only process
| accessing the database. This feature allows WAL databases to be
| created, read, and written by legacy VFSes that lack the "version 2"
| shared-memory methods xShmMap, xShmLock, xShmBarrier, and xShmUnmap on
| the sqlite3_io_methods object.


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



Firma: Capgemini Deutschland GmbH
Aufsichtsratsvorsitzender: Antonio Schnieder ? Gesch?ftsf?hrer: Dr. Michael 
Schulte (Sprecher) ? Jost F?rster ? Dr. Peter Lempp ? Dr. Volkmar Varnhagen

Amtsgericht Berlin-Charlottenburg, HRB 98814
This message contains information that may be privileged or confidential and is 
the property of the Capgemini Group. It is intended only for the person to whom 
it is addressed. If you are not the intended recipient, you are not authorized 
to read, print, retain, copy, disseminate, distribute, or use this message or 
any part thereof. If you receive this message in error, please notify the 
sender immediately and delete all copies of this message.


[sqlite] Problems with pragma journal_mode

2015-04-16 Thread Janke, Julian
I use the version SQLITE_VERSION "3.8.8.3"

-Original Message-
From: sqlite-users-bounces at mailinglists.sqlite.org 
[mailto:sqlite-users-boun...@mailinglists.sqlite.org] On Behalf Of Simon Davies
Sent: Donnerstag, 16. April 2015 11:20
To: General Discussion of SQLite Database
Subject: Re: [sqlite] Problems with pragma journal_mode

On 16 April 2015 at 10:10, Janke, Julian  wrote:
> Hi everyone,
>
> I'm relatively new to SQLite and currently I'm experimenting a little bit 
> with the SQLite database on an embedded system.
> I want to change the journal mode of a database to WAL. So I did the 
> following:
>
> rc = sqlite3_open(dbPath, );
> rc = sqlite3_exec(db, "PRAGMA journal_mode=WAL;", testCallbackPrint,
> 0, ); [?] sqlite3_close(db);
>
> Unfortunately, after these lines, the journal mode is not changed. The
> sqlite3_exec function returns SQLITE_OK (0), testCallbackPrint is never 
> called and the error message is empty.
> Also reading the value of journal mode with ?PRAGMA journal_mode;? leads to 
> the same result (rc=0, callback noch called and error message is empty).

What version of SQLite?

...
>
> Thanks.

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



Firma: Capgemini Deutschland GmbH
Aufsichtsratsvorsitzender: Antonio Schnieder ? Gesch?ftsf?hrer: Dr. Michael 
Schulte (Sprecher) ? Jost F?rster ? Dr. Peter Lempp ? Dr. Volkmar Varnhagen

Amtsgericht Berlin-Charlottenburg, HRB 98814
This message contains information that may be privileged or confidential and is 
the property of the Capgemini Group. It is intended only for the person to whom 
it is addressed. If you are not the intended recipient, you are not authorized 
to read, print, retain, copy, disseminate, distribute, or use this message or 
any part thereof. If you receive this message in error, please notify the 
sender immediately and delete all copies of this message.


[sqlite] Problems with pragma journal_mode

2015-04-16 Thread Janke, Julian
Hi everyone,

I'm relatively new to SQLite and currently I'm experimenting a little bit with 
the SQLite database on an embedded system.
I want to change the journal mode of a database to WAL. So I did the following:

rc = sqlite3_open(dbPath, );
rc = sqlite3_exec(db, "PRAGMA journal_mode=WAL;", testCallbackPrint, 0, 
);
[?]
sqlite3_close(db);

Unfortunately, after these lines, the journal mode is not changed. The 
sqlite3_exec function returns SQLITE_OK (0),
testCallbackPrint is never called and the error message is empty.
Also reading the value of journal mode with ?PRAGMA journal_mode;? leads to the 
same result (rc=0, callback noch called and error message is empty).

It seems as if the pragma is ignored completely, so I tested other pragmas, 
with the same result.

So what am I doing wrong?

To compile, I use the following options
-DSQLITE_ENABLE_MEMSYS5
-DSQLITE_ENABLE_8_3_NAMES=2
-DSQLITE_THREADSAFE=0
-DSQLITE_OS_OTHER=1
-DSQLITE_ENABLE_API_ARMOR
-DSQLITE_DEFAULT_MMAP_SIZE=0
-DSQLITE_TEMP_STORE=0
-DSQLITE_DEFAULT_CACHE_SIZE=500


Thanks.





Firma: Capgemini Deutschland GmbH
Aufsichtsratsvorsitzender: Antonio Schnieder ? Gesch?ftsf?hrer: Dr. Michael 
Schulte (Sprecher) ? Jost F?rster ? Dr. Peter Lempp ? Dr. Volkmar Varnhagen

Amtsgericht Berlin-Charlottenburg, HRB 98814
This message contains information that may be privileged or confidential and is 
the property of the Capgemini Group. It is intended only for the person to whom 
it is addressed. If you are not the intended recipient, you are not authorized 
to read, print, retain, copy, disseminate, distribute, or use this message or 
any part thereof. If you receive this message in error, please notify the 
sender immediately and delete all copies of this message.


[sqlite] Comments in VDBE program

2015-04-16 Thread Richard Hipp
On 4/16/15, Sairam Gaddam  wrote:
> I am using C SQLite interface. How to enable comments in the VDBE program
> here?
> because they are not enabled by default.
> gcc -DSQLITE -DEBUG filename.c ../sqlite3.c -ldl -lpthread
> I tried with the above line in the terminal but could not succeed in
> enabling the comments. Can any one help me with this?
> I am using Linux 64 bit machine.

Add -DSQLITE_ENABLE_EXPLAIN_COMMENTS to the compiler command-line.

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


-- 
D. Richard Hipp
drh at sqlite.org


[sqlite] Request: Metadata about C API constants and functions

2015-04-16 Thread Simon Slavin
On 2015-04-10 04:11 PM, Richard Hipp wrote:

> https://www.sqlite.org/toc.db

I download this and do the following:

164:~ simon$ sqlite3 /Users/simon/Desktop/toc.db 
SQLite version 3.8.5 2014-08-15 22:37:57
Enter ".help" for usage hints.
sqlite> .mode column
sqlite> select * from toc limit 10;
sqlite3 object  0   Database Connection Handle  
c3ref/sqlite3.html
sqlite3_in  object  0   64-Bit Integer Types
c3ref/int64.html  
sqlite3_ui  object  0   64-Bit Integer Types
c3ref/int64.html  
sqlite_int  object  0   64-Bit Integer Types
c3ref/int64.html  
sqlite_uin  object  0   64-Bit Integer Types
c3ref/int64.html  
sqlite3_fi  object  0   OS Interface Open File Han  c3ref/file.html 
  
sqlite3_io  object  0   OS Interface File Virtual   
c3ref/io_methods.h
sqlite3_mu  object  0   Mutex Handle
c3ref/mutex.html  
sqlite3_vf  object  0   OS Interface Object c3ref/vfs.html  
  
sqlite3_me  object  0   Memory Allocation Routines  
c3ref/mem_methods.


I know that the .width command exists, but why is the first column so short ?  
Is the shell tool set to use width 10 for the first column ?  All the columns 
except for the numeric one are defined as TEXT but they're given different 
widths.

Simon.


[sqlite] Request: Metadata about C API constants and functions

2015-04-16 Thread Simon Slavin

On 16 Apr 2015, at 12:31am, Roger Binns  wrote:

> It is a very productive time when you
> get to delete code :-)



See the paragraph "How do you measure programmer productivity?" half way down 
the page, just before the Epilogue.

Simon.