[GRASS-dev] adding 'desc' to dbf sql driver

Moritz Lennert mlennert at club.worldonline.be
Tue Oct 10 04:29:35 EDT 2006


Glynn Clements wrote:
> Moritz Lennert wrote:
> 
>>> 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 ?
> 
> y_order_asc:
> 		NAME		{ sqpOrderColumn( $1, SORT_ASC ); }
> 	|	NAME ASC	{ sqpOrderColumn( $1, SORT_ASC ); }
> 	;
> 
> The | splits a definition into separate rules. Each rule has its own
> action; if none is given, the default action is "{ $$ = $1; }". So, in
> your original version, the specified action only applied to the
> "NAME ASC" rule, while "NAME" got the default action.

This is how I did it in fact. Thanks.

I have just committed the series of changes necessary for the support of 
the ASC/DESC keywords in the ORDER BY clause in the dbf driver.

For me it works, so I thought the best would be to commit it so that 
others could test it.

The only issue I still have is with the test case in lib/db/sqlp/test/, 
but I don't know if that is a problem with my code, or with the testing...

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

Moritz




More information about the grass-dev mailing list