[sqlite] Re: Re: End of Search Notification to Collation function

2007-09-30 Thread Igor Tandetnik

RaghavendraK 70574
<[EMAIL PROTECTED]> wrote:

Subject: Re: Re: End of Search Notification to Collation function

i have one new collation function TestEq.
I register this with sqlite. Also provide a context
structure.

Now i write query as below,

select * from table where col = 'xxx' collate TestEq
and  col2='xxx' collate TestEq and col3='xxx' collate TestEq;

Now in the TestEq impl i need to know the column for
which am doing the comparison.


It's not clear why you would want that, but maybe something like this 
would work:


select * from table where col = '1xxx' collate TestEq
and  col2='2xxx' collate TestEq and col3='3xxx' collate TestEq;

The implementation of TestEq would look at the first character of the 
second argument and know which column is being used.


Alternatively, instead of a custom collation, implement a custom 
function taking three parameters and returning a boolean:


select * from table where TestEq(col, 'xxx', 1)
and  TestEq(co2, 'xxx', 2) and TestEq(col3, 'xxx', 3);

The last parameter again indicates which column is being handled.


Now most would suggest have different functions,but thats not
possible because table creation and ppl writing the query is dynamic
(not controlled by me). I can only bundle my TestEq function and
provide api desc abt what it does.


But why does it care which column it is acting on? What if it isn't a 
single column at all, e.g.


select * from table where col || ',' || col2 == 'xxx,yyy' collate 
TestEq;


Precisely what does it have to do differently when comparing col vs 
comparing col2 vs comparing some expression that cannot be traced to a 
single column?



So is there a way to get column

information for which am running the collate function?
it is logical to have the column names as part
of the collate function.


Except that a collation isn't always applied to a column. It can be 
applied to a pair of arbitrary expressions.



Second Part: Collate function needs a end of search notification,as
Collate function can do a re-drill down or up based on the saved
context.


Re-drill? This phrase doesn't make any sense to me, sorry.

Igor Tandetnik 



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



Re: [sqlite] Re: End of Search Notification to Collation function

2007-09-30 Thread RaghavendraK 70574

Hi,

its like this,

i have one new collation function TestEq.
I register this with sqlite. Also provide a context 
structure.

Now i write query as below,

select * from table where col = 'xxx' collate TestEq 
and  col2='xxx' collate TestEq and col3='xxx' collate TestEq;

Now in the TestEq impl i need to know the column for
which am doing the comparison.

Now most would suggest have different functions,but thats not possible because 
table creation and ppl writing the query is dynamic (not controlled by me). I 
can only bundle my TestEq function and provide api desc abt what it does. End 
users would club it as above in the sql statement and use it. So is there a way 
to get column information for which am running the collate function?
it is logical to have the column names as part
of the collate function.

Second Part: Collate function needs a end of search notification,as Collate 
function can do a re-drill down or up based on the saved context.

All these increases the performance as it happens within sqlite boundary. 

regards
ragha
**
 This email and its attachments contain confidential information from HUAWEI, 
which is intended only for the person or entity whose address is listed above. 
Any use of the information contained herein in any way (including, but not 
limited to, total or partial disclosure, reproduction, or dissemination) by 
persons other than the intended recipient(s) is prohibited. If you receive this 
e-mail in error, please notify the sender by phone or email immediately and 
delete it!
 
*

- Original Message -
From: Igor Tandetnik <[EMAIL PROTECTED]>
Date: Sunday, September 30, 2007 6:41 pm
Subject: [sqlite] Re: End of Search Notification to Collation function

> RaghavendraK 70574
> <[EMAIL PROTECTED]> wrote: 
> > Can any suggest a way to notify collation function "end of search"
> > from 
> > control algorthim?
> 
> What for? What exactly are you trying to achieve?
> 
> Igor Tandetnik
> 
> 
> -
> To unsubscribe, send email to [EMAIL PROTECTED]
> 
> -
> 
> 

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



Re: [sqlite] C API trouble

2007-09-30 Thread Andrew Sledge
Hi Mike,

That did the trick.  I am new to C, but I have used SQLite in Perl and
Python.  Thanks!*


List:   sqlite-users 
Subject:Re: [sqlite] C API trouble
From:   "Mike Polyakov" 

Date:   2007-09-30 23:49:36

Message-ID: f18b74060709301649q4a439ed2pe0a2f6d7d0934cea () mail !
gmail ! com 

[Download message RAW
]*



Besides the unneded function calls, and a lot of checks for valid
data, the problem here is that you have to copy data using memcpy or
somthing similar:

instead of chCommand = (const char*)sqlite3_column_text(ptrSel,2);

do

memcpy(chCommand, sqlite3_column_text(ptrSel,2),
sqlite3_column_bytes(ptrSel,2));
chCommand[sqlite3_column_bytes(ptrSel,2)] = 0;

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



-- 
Andrew Sledge


Re: [sqlite] C API trouble

2007-09-30 Thread Mike Polyakov
Besides the unneded function calls, and a lot of checks for valid
data, the problem here is that you have to copy data using memcpy or
somthing similar:

instead of chCommand = (const char*)sqlite3_column_text(ptrSel,2);

do

memcpy(chCommand, sqlite3_column_text(ptrSel,2),
sqlite3_column_bytes(ptrSel,2));
chCommand[sqlite3_column_bytes(ptrSel,2)] = 0;

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



[sqlite] C API trouble

2007-09-30 Thread Andrew Sledge
Hi, first off thank you to all of the regulars who have made my life easier
:).

I have a C program that pulls data from a SQLite3 database into a variable
and then uses that data to do other things.  However, when I iterate through
the returns (no matter how many) the data never gets outside of my while
loop.  The code below should explain more:

sqlite3_exec(ptrDatabase, "BEGIN TRANSACTION;", 0, 0, 0);
intRc = sqlite3_prepare(ptrDatabase, chQuery,
strlen(chQuery), &ptrSel, NULL);
sqlite3_bind_parameter_count(ptrSel);
intRc = sqlite3_step(ptrSel);
while (intRc == SQLITE_ROW) {
int id;

sqlite3_data_count(ptrSel);
sqlite3_column_count(ptrSel);
sqlite3_column_type(ptrSel, 0);
sqlite3_column_bytes(ptrSel, 0);
id = sqlite3_column_int(ptrSel, 0);

sqlite3_column_type(ptrSel, 2);
sqlite3_column_bytes(ptrSel, 2);

chCommand = (const char
*)calloc(sqlite3_column_bytes(ptrSel, 2)+ 1, sizeof(char));
chCommand = (const char*)sqlite3_column_text(ptrSel,
2);
/* Prints successfully here */
printf("%s\n", chCommand);
intRc = sqlite3_step(ptrSel);
}

sqlite3_exec(ptrDatabase, "COMMIT TRANSACTION;", 0, 0, 0);
/* Does NOT print here */
printf("%s\n",chCommand);


Thanks in advance for any and all help.

--
Sledge


[sqlite] Re: End of Search Notification to Collation function

2007-09-30 Thread Igor Tandetnik

RaghavendraK 70574
<[EMAIL PROTECTED]> wrote: 

Can any suggest a way to notify collation function "end of search"
from 
control algorthim?


What for? What exactly are you trying to achieve?

Igor Tandetnik

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