[GRASS-dev] adding 'desc' to dbf sql driver
Moritz Lennert
mlennert at club.worldonline.be
Mon Oct 9 07:53:51 EDT 2006
Forgot to attach the latest patch. Here it is.
Moritz
Moritz Lennert wrote:
> Daniel Calvelo wrote:
>> Hi Moritz,
>>
>> Looks good to me. In the yac.y patch, you don't need to duplicate the
>> code for ORDER BY NAME and ORDER BY NAME ASC.
>
> How do I take care of the case where neither asc nor desc are given in
> the sql ? This should default to asc, but this:
>
> +y_order_asc:
> + NAME | NAME ASC {
> sqpOrderColumn( $1, SORT_ASC ); }
>
> does not work, i.e. results of 'order by' without asc are not sorted.
>
> So how does this need to be formulated ?
>
>
>> For cmp_row_desc, you
>> could just return( - cmp_row_asc) with the same arguments. Glynn, a
>> cursory look?
>
> Did that and it seems to work.
>
>>
>> FYI, the text file in lib/db/sqlp/test/test allows for some testing of
>> the parser. That may help you find any hidden bugs in the sqlp part of
>> your patch.
>
>
> I get
>
> Input row: -->>INSERT INTO pok ( c1, c2,c3) VALUES ( 'abc', +32, +56.7 );
> <<--
> Input statement: -->>INSERT INTO pok ( c1, c2,c3) VALUES ( 'abc', +32,
> +56.7 )<<--
> Error: statement was not parsed successfully.
>
> Don't know how this would be related to my changes.
>
> (BTW
>
> INSERT INTO pok ( c1, c2,c3) VALUES ( 'abc', -32, -56.7 );
>
> does not cause any problems.)
>
> If I remove the above insert statement and add:
>
> SELECT c1,c3 FROM pok order by c1;
>
> it runs perfectly.
>
> However, when I insert
>
> SELECT c1,c3 FROM pok order by c1 ASC;
> or
> SELECT c1,c3 FROM pok order by c1 DESC;
>
> I get a segmentation fault:
>
> Input row: -->>SELECT c1,c3 FROM pok order by c1 ASC;
> <<--
> Input statement: -->>SELECT c1,c3 FROM pok order by c1 ASC<<--
> ********** SQL PARSER RESULT **********
> INPUT: SELECT c1,c3 FROM pok order by c1 ASC
> COMMAND: SELECT
> TABLE: pok
> COLUMN 1: c1
> COLUMN 2: c3
> ./test2: line 15: 32474 Done echo "SELECT c1,c3 FROM
> pok where c3 <> 34 and c5 = 2.3;
> SELECT c1,c3 FROM pok order by c1 ASC;
> INSERT INTO pok VALUES ( 'abc', 32, 56.7 );
> INSERT INTO pok ( c1, c2,c3) VALUES ( 'abc', 32, 56.7 );
> INSERT INTO pok ( c1, c2,c3) VALUES ( 'abc', -32, -56.7 );
> upDAte pok SET c2 = '5', c3 = 1 WHERE c1 = '1' AND c5 = 6;
> delete FROM pok WHERE c1 = '1' and c2=3 AND c5 <= 4.35;
> CREATE TABLE pok ( c1 INT, c2 VARCHAR (5), c3 DOUBLE );
> DROP TABLE pok;
> ALTER TABLE pok ADD COLUMN id int;
> ALTER TABLE pok ADD popis varchar(10);
> UPDATE pok SET c2 = NULL, c1=c2, c3=(-c3+12)/c1 where c1 NOT NULL;
> update pok set c1=c2,c2=c1,c3=NULL where c1+2>1/cat+0.5 and not (c1=1 or
> c2=2);" 32475 Segmentation fault | ./sqlptest
>
>
> I'm a bit lost here. What is print.c used for ?
>
>> You might also wish to update print.c to accomodate for
>> asc/desc (it's a one-line change near the end).
>
> Did that, but not sure if correctly. Should I check for the existance of
> orderDir before using it, i.e. should it rather be
>
> if ( sqlpStmt->command == SQLP_SELECT ) {
> if ( sqlpStmt->orderDir )
> {
> fprintf( stderr, "ORDER BY: %s %s\n", sqlpStmt->orderCol,
> sqlpStmt->orderDir );
> } else {
> fprintf( stderr, "ORDER BY: %s\n", sqlpStmt->orderCol );
> }
>
> or is this not necessary ?
>
>
>>
>> And of course, after testing, this has to be documented :)
>>
>
> Obviously... :-)
>
> Moritz
>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: dbf.diff.tgz
Type: application/x-gtar
Size: 1853 bytes
Desc: not available
Url : http://lists.osgeo.org/pipermail/grass-dev/attachments/20061009/96a55de3/dbf.diff.gtar
More information about the grass-dev
mailing list