Opened 5 years ago

Closed 5 years ago

#2457 closed defect (wontfix)

DBF driver: stub functions for SQL TRANSACTION

Reported by: neteler Owned by: grass-dev@…
Priority: normal Milestone: 6.4.5
Component: Database Version: svn-releasebranch64
Keywords: dbf, sql Cc:
CPU: Unspecified Platform: All

Description

On some systems (here: Ubuntu, user report on grass-user), it is not possible to run v.rast.stats properly when using the DBF driver as it is internally executing a SQL transaction:

v.rast.stats -c vector=basin_250@PERMANENT raster=rainfall_idw@PERMANENT colprefix=z
Updating the database ...
DBMI-DBF driver error:
SQL parser error: syntax error, unexpected NAME processing
'BEGIN'
in statement:
BEGIN TRANSACTION
Error in db_execute_immediate()
ERROR: Error while executing: 'BEGIN TRANSACTION'

I would suggest to add stub functions for

  • db_begin_transaction()
  • db_commit_transaction()

to db/drivers/dbf/execute.c to make the DBMI interface happy.

Is attached patch ok? If yes, also add to GRASS 7?

Attachments (2)

grass64_dbf_driver_transactions.2.diff (4.4 KB) - added by neteler 5 years ago.
stub transaction functions for DBF driver
grass64_dbf_driver_transactions.diff (4.4 KB) - added by neteler 5 years ago.
stub transaction functions for DBF driver

Download all attachments as: .zip

Change History (13)

comment:1 Changed 5 years ago by neteler

I modified the patch but don't know where to add these two items:

  • SQLP_BEGIN_TRANSACTION
  • SQLP_COMMIT_TRANSACTION
dbfexe.c:251:11: error: ‘SQLP_BEGIN_TRANSACTION’ undeclared (first use in this function)
     case (SQLP_BEGIN_TRANSACTION):

dbfexe.c:252:11: error: ‘SQLP_COMMIT_TRANSACTION’ undeclared (first use in this function)
     case (SQLP_COMMIT_TRANSACTION):

I suppose they need to go somewhere into lib/db/ ?

comment:2 in reply to:  1 Changed 5 years ago by mlennert

Replying to neteler:

I modified the patch but don't know where to add these two items:

  • SQLP_BEGIN_TRANSACTION
  • SQLP_COMMIT_TRANSACTION

According to lib/db/sqlp/README:

"New types have to be added in yac.y, lex.l, print.c and ../../../include/sqlp.h."

comment:3 Changed 5 years ago by neteler

Thanks, attached patch updated which now compiles. Still not reaching the desired effect to simply ignore the SQL transaction when using a DBF driver...

comment:4 in reply to:  3 ; Changed 5 years ago by mlennert

Replying to neteler:

Thanks, attached patch updated which now compiles. Still not reaching the desired effect to simply ignore the SQL transaction when using a DBF driver...

You still are missing the additions to the other files mentioned. AFAICT, with the current patch, st->command will never take the values SQLP_BEGIN_TRANSACTION or SQLP_COMMIT_TRANSACTION as they are not recognized by the parser, so your case statement will always be false.

comment:5 in reply to:  4 ; Changed 5 years ago by neteler

Replying to mlennert:

You still are missing the additions to the other files mentioned.

Ops, right. Updated patch attached, now it complains about double defined BEGIN...

comment:6 in reply to:  5 ; Changed 5 years ago by mlennert

Replying to neteler:

Replying to mlennert:

You still are missing the additions to the other files mentioned.

Ops, right. Updated patch attached, now it complains about double defined BEGIN...

After running make in lib/db/sqlp/ there is a file lex.yy.c which has the following line 125:

#define BEGIN (yy_start) = 1 + 2 *

My wild guess is that this causes your problem, but I'm way out of my league here (don't even know where this line comes from in that file), so you would have to consult with a lex/yacc guru.

Moritz

comment:7 in reply to:  6 Changed 5 years ago by glynn

After running make in lib/db/sqlp/ there is a file lex.yy.c which has the following line 125:

#define BEGIN (yy_start) = 1 + 2 *

My wild guess is that this causes your problem, but I'm way out of my league here (don't even know where this line comes from in that file),

It's part of the boilerplate code which built into flex itself.

The bottom line is that you can't use "BEGIN" as a token identifier (REJECT, ECHO and INITIAL are also unavailable; the other macro names are unlikely to result in innocent collisions). Add a trailing underscore or change the case to avoid a conflict.

Also the patch attempts to define the TRANSACTION token twice:

%token BEGIN TRANSACTION 
%token COMMIT TRANSACTION 

Changed 5 years ago by neteler

stub transaction functions for DBF driver

Changed 5 years ago by neteler

stub transaction functions for DBF driver

comment:8 Changed 5 years ago by neteler

Thanks, getting closer:

GRASS 6.4.4svn (nc_spm_08):~ > v.rast.stats myzipcodes_wake raster=elevation colprefix=elev -c
 100%
Updating the database ...
DBMI-DBF driver error:
Table '' doesn't exist.
Error in db_execute_immediate()

ERROR: Error while executing: 'BEGIN TRANSACTION'

Something is yet messed up in the updated patch.

comment:9 Changed 5 years ago by renatomichel

Hello,

I copied the file v.rast.stats Version 6.4.3 in the apps/grass/grass-6.4.4/scripts successfully, I no longer have the error message. These scipts are different with quotes usage ?

my system (windows, qgis 2.6.1)

comment:10 in reply to:  9 Changed 5 years ago by neteler

Instead of trying to add SQL TRANSACTIONS to the DBF driver, I have now simply conditionalized it in r63789. This will go into a future GRASS GIS 6.4.5.

Please try the updated script from here: https://svn.osgeo.org/grass/grass/branches/releasebranch_6_4/scripts/v.rast.stats/v.rast.stats

Thanks for reporting it. The ticket may be closed if the updated script works ok for you.

comment:11 Changed 5 years ago by neteler

Resolution: wontfix
Status: newclosed

The last comment did not belong here but to the list.

Since adding SQL TRANSACTIONs to the DBF driver appears to be too complicated and essentially useless, I take liberty to close my own ticket as wontfix. Thanks for the support, though.

Note: See TracTickets for help on using tickets.