Re: [sqlite] Error: malformed database schema ...

2005-02-13 Thread D. Richard Hipp
On Sun, 2005-02-13 at 21:40 -0800, Jim Dodgen wrote:
> attach database bar as ref;
> create table ref.table_field
>(
>   name varchar(255),
>   nbr  varchar(255)
>);
> create unique index ref.table_field_name on ref.table_field (name);

Make that last line:

  create unique index ref.table_field_name 
on table_field(name);

In other words, omit the "ref." from the able name
when creating the index.

You should have gotten an error.  That will be corrected.
-- 
D. Richard Hipp <[EMAIL PROTECTED]>



[sqlite] Error: malformed database schema ...

2005-02-13 Thread Jim Dodgen
sqlite 3.0.8, windows XP
I'm attempting to create some tables and indexes in a attached database 
(bar) and after everything is complete and I go back in to the previously 
attached database and do a .schema I get the following:

"Error: malformed database schema - index table_field_name cannot reference 
objects in database ref"

the following script can be used to reproduce the problem in a windows XP 
command prompt

any ideas?
Jim
--- cut here ---
del foo bar
sqlite3 foo
create table xxx (xxx char);
.quit
sqlite3 bar
create table xxx (xxx char);
.quit
sqlite3 foo
attach database bar as ref;
create table ref.table_field
  (
 name varchar(255),
 nbr  varchar(255)
  );
create unique index ref.table_field_name on ref.table_field (name);
create table ref.alias_table_field
  (
 name varchar(255),
 alias varchar(255)
  );
create unique index ref.alias_table_field_name on ref.alias_table_field (name);
create unique index ref.alias_table_field_alias on ref.alias_table_field 
(alias);
.quit

sqlite3 bar
.schema
.quit
--- end of script --- 



[sqlite] Problem with this simple example

2005-02-13 Thread Dave Furey

Below is a very simplied example of what I'm trying to do with a recursive
routine call:

==

sqlite3_prepare (hDB,CstrCommand,strlen(CstrCommand),&ppStmt,&CstrTail);

while ( sqlite3_step(ppStmt) == SQLITE_ROW )
{ 
  sqlite3_prepare
(hDB,CstrCommand2,strlen(CstrCommand2),&ppStmt2,&CstrTail2);
  sqlite3_step(ppStmt2);
  sqlite3_finalize(ppStmt2);
}

sqlite3_finalize(ppStmt);

sqlite3_prepare (hDB,CstrCommand3,strlen(CstrCommand3),&ppStmt3,&CstrTail);
sqlite3_step(ppStmt3);
sqlite3_finalize(ppStmt3);

==

Both the "CStrCommand" and "CStrCommand2" contain SELECT query statements.
This coding example works fine with the query (not returning any errors).
However, when I get to "CStrCommand3" (which contains an INSERT statement),
the sqlite3_step() call returns SQLITE_ERROR.

Is it legal for me to have the prepare/step/finalize coding embedded as I've
shown in my simple example above? Any help would be appreciated.

Thanks,

Dave


Re: [sqlite] VACUUM question

2005-02-13 Thread D. Richard Hipp
On Fri, 2005-02-11 at 21:04 -0500, [EMAIL PROTECTED]
wrote:
> "D. Richard Hipp" <[EMAIL PROTECTED]> writes:
> 
> > While on the airplane, I was able to reproduce the problem
> > and confirm that it is possible to corrupt a database
> > as described above.  I've just checked in a tentative fix.
> > After some more testing, I will do a new release, probably
> > 3.1.2 (stable).
> 
> Do you know if this bug exist in 2.8.15 as well?  If so, is the fix
> back-portable?
> 

A similar bug exists in 2.8.  A fix has been checked
into CVS.  Version 2.8.16 will be released as soon as
I can get it built and tested.
-- 
D. Richard Hipp <[EMAIL PROTECTED]>



Re: [sqlite] Windows Unicode Support

2005-02-13 Thread Jeff Thompson
D. Richard Hipp wrote:
On Sun, 2005-02-13 at 16:18 -0600, Jeff Thompson wrote:
 

sqlite3_exec
sqlite3_mprintf
I was wondering why there are no unicode versions 
of these (and possibly others) functions?

   

sqlite3_exec is implemented in using other published
APIs.  It is a convenience wrapper provided for historical
compatibility.  If you want a UTF-16 version, make a copy
of the UTF-8 version and adjust as necessary.
 

Understood... I did implement my own "exec" function in my application 
and it works fine. I was just wondering why no sqlite3_exec16 function, 
but as you pointed out, it's no big deal to handle on the app side.

I don't know how to make sqlite3_mprintf() UTF-16 aware.
 

Looking at printf.c, I'd tend to agree...
Thanks for the info.
--
jthomps


Re: [sqlite] Does anyone know why the current compiled from CVS can't run in Windows?

2005-02-13 Thread [EMAIL PROTECTED]
I have installed the cygwin, since I may need to CVS source code in the 
future as well. Please show us how to preprocessing the source-code 
checked out from CVS.

Thanks,
Ming
D. Richard Hipp wrote:
On Sun, 2005-02-13 at 19:45 -0400, [EMAIL PROTECTED] wrote:
 

Please show us how to compile the CVS source, since I couldn't find any 
instructions on the wiki website.

   

Using cygwin to do the source-code preprocessing if
you want to go that route.  Or wait a day or two.  3.1.2
will probably be released as soon as ticket #1114 is
cleared.
 



Re: [sqlite] Does anyone know why the current compiled from CVS can't run in Windows?

2005-02-13 Thread D. Richard Hipp
On Sun, 2005-02-13 at 19:45 -0400, [EMAIL PROTECTED] wrote:
> Please show us how to compile the CVS source, since I couldn't find any 
> instructions on the wiki website.
> 

Using cygwin to do the source-code preprocessing if
you want to go that route.  Or wait a day or two.  3.1.2
will probably be released as soon as ticket #1114 is
cleared.
-- 
D. Richard Hipp <[EMAIL PROTECTED]>



Re: [sqlite] Best way to check for existence of a table?

2005-02-13 Thread D. Richard Hipp
On Sun, 2005-02-13 at 22:58 +, Richard Boyd wrote:
>  
> 
> I need a way to check if a table exists from some C code. 

SELECT count(*) FROM sqlite_master WHERE
  name= AND type='table';
-- 
D. Richard Hipp <[EMAIL PROTECTED]>



Re: [sqlite] Does anyone know why the current compiled from CVS can't run in Windows?

2005-02-13 Thread [EMAIL PROTECTED]
Hi D. Richard Hipp,
Good to know that you can compile in CVS source in your system, which 
only means I did it wrong.
1. I am using windows 2000 as well, with Visual Studio 2003. Since CVS 
don't have all the file to nessory compiled in VS2003, I download the 
latest beta (3.1.1beta) from your website, any then, I check out all the 
"src" from CVS and replace all the files in 3.1.1beta with new check out.
2. After I have compiled the new updated from CVS, I have 2 errors from 
the VS compiler, one is the strcasecmp, which I replaced it with stricmp 
manual. the other one is missing OP_IfMemPos definition in opcodes.h and 
.cpp, so I added manual as well.
3. After the Step 2, I can compile successfully.

Please show us how to compile the CVS source, since I couldn't find any 
instructions on the wiki website.

Thank you for this wonderful piece of software.
Ming
---
D. Richard Hipp wrote:
On Sun, 2005-02-13 at 14:57 -0400, [EMAIL PROTECTED] wrote:
 

Hello All,
I wonder does anyone know the new compiled sqlite from CVS can't run in 
Windows, it always crashes since last week??

   

It passes all regression tests under win2k (which is
the most recent version of windows I have.)  Perhaps
you are not compiling it correctly?
 



Re: [sqlite] Windows Unicode Support

2005-02-13 Thread D. Richard Hipp
On Sun, 2005-02-13 at 16:18 -0600, Jeff Thompson wrote:
> sqlite3_exec
> sqlite3_mprintf
> 
> I was wondering why there are no unicode versions 
> of these (and possibly others) functions?
> 

sqlite3_exec is implemented in using other published
APIs.  It is a convenience wrapper provided for historical
compatibility.  If you want a UTF-16 version, make a copy
of the UTF-8 version and adjust as necessary.

I don't know how to make sqlite3_mprintf() UTF-16 aware.
-- 
D. Richard Hipp <[EMAIL PROTECTED]>



Re: [sqlite] Does anyone know why the current compiled from CVS can't run in Windows?

2005-02-13 Thread D. Richard Hipp
On Sun, 2005-02-13 at 14:57 -0400, [EMAIL PROTECTED] wrote:
> Hello All,
> 
> I wonder does anyone know the new compiled sqlite from CVS can't run in 
> Windows, it always crashes since last week??
> 

It passes all regression tests under win2k (which is
the most recent version of windows I have.)  Perhaps
you are not compiling it correctly?
-- 
D. Richard Hipp <[EMAIL PROTECTED]>



[sqlite] Best way to check for existence of a table?

2005-02-13 Thread Richard Boyd








Hi,

 

I need a way to check if a table exists from some C
code. I wrote some code to try to select a row from a table and then checked
the error result. However, the error code is always ‘1’ (which is just
a general SQLITE_ERROR) if the table does not exist. Is there any way I can
differentiate between the error code meaning ‘no table found’ and
other errors?? Or is there a neater way to check for existence of a table?

 

TIA,

Richard.






No virus found in this outgoing message.
Checked by AVG Anti-Virus.
Version: 7.0.300 / Virus Database: 265.8.7 - Release Date: 10/02/2005


[sqlite] Windows Unicode Support

2005-02-13 Thread Jeff Thompson
Hi, I've recently gone through the work to convert my windows 
application to unicode. A ran across a couple of the sqlite3 API calls 
that don't seem to have unicode versions, namely:

sqlite3_exec
sqlite3_mprintf
I switched all of my sqlite3_mprintf/sqlite3_exec calls to 
sqlite3_prepare16/sqlite3_step calls and use sqlite3_bind_text16 to bind 
parameters instead of using the '%q' quoted string support provided by 
sqlite3_mprintf.

While this works fine, I was wondering why there are no unicode versions 
of these (and possibly others) functions?

Thanks,
jthomps


[sqlite] Questions regarding sqlite3_column_decltype

2005-02-13 Thread Michael Ruck
Hi,

Maybe someone can answer me a couple of questions regarding above function:

I've seen that it doesn't return the declaration type for views in 3.0.8. 
Is this by design?

Are there any plans to change this so that queries against views return 
the column types of the tables? I've looked at the opcodes executed and 
the two are quite different, I can't (currently) figure out how to change 
this myself. (I'd be glad to post this as a patch for inclusion.)

As a workaround I'm currently executing the SELECT, which is performed by 
the view manually to gain the column type information. I'm wondering if 
there is any speed difference (any at all?) in doing so. I don't need exact 
timings just a rough understating of whats different would help me. (The
view 
joins together approx. 5 tables, pulling a total of 20 columns.)

Any help is appreciated,

Michael






[sqlite] Does anyone know why the current compiled from CVS can't run in Windows?

2005-02-13 Thread [EMAIL PROTECTED]
Hello All,
I wonder does anyone know the new compiled sqlite from CVS can't run in 
Windows, it always crashes since last week??

Thanks,
Ming


Re: [sqlite] VACUUM question

2005-02-13 Thread Derrell . Lipman
Clay Dowling <[EMAIL PROTECTED]> writes:

> [EMAIL PROTECTED] wrote:
>
>>Do you know if this bug exist in 2.8.15 as well?  If so, is the fix
>>back-portable?
>>
>>
> Darrell,
>
> I believe that the VACUUM statement didn't exist in 2.8.x, so there shouldn't
> be a problem.

Sure it does.  I use it in 2.8.15, so I'm quite interested in whether the bug
existed in it as well.

Derrell


Re: [sqlite] VACUUM question

2005-02-13 Thread Ulrik Petersen
Clay and Derrell,
Clay Dowling wrote:
[EMAIL PROTECTED] wrote:
Do you know if this bug exist in 2.8.15 as well?  If so, is the fix
back-portable?
 

Darrell,
I believe that the VACUUM statement didn't exist in 2.8.x, so there 
shouldn't be a problem.
That's not true.  It did exist in 2.8.15.  I've used it many times, and 
my Emdros project, which uses SQLite 2.8.15, takes advantage of it.

I don't know whether the problem Derrell was referring to exists in 
2.8.15, though.

Ulrik P.
--
Ulrik Petersen, Denmark
Emdros -- the text database engine for analyzed or annotated text
http://emdros.org/


Re: [sqlite] VACUUM question

2005-02-13 Thread Clay Dowling
[EMAIL PROTECTED] wrote:
Do you know if this bug exist in 2.8.15 as well?  If so, is the fix
back-portable?
 

Darrell,
I believe that the VACUUM statement didn't exist in 2.8.x, so there 
shouldn't be a problem.

Clay