Opened 10 years ago
Closed 10 years ago
#2457 closed defect (wontfix)
DBF driver: stub functions for SQL TRANSACTION
Reported by: | neteler | Owned by: | |
---|---|---|---|
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)
Change History (13)
follow-up: 2 comment:1 by , 10 years ago
comment:2 by , 10 years ago
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."
follow-up: 4 comment:3 by , 10 years ago
Thanks, attached patch updated which now compiles. Still not reaching the desired effect to simply ignore the SQL transaction when using a DBF driver...
follow-up: 5 comment:4 by , 10 years ago
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.
follow-up: 6 comment:5 by , 10 years ago
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...
follow-up: 7 comment:6 by , 10 years ago
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 by , 10 years ago
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
by , 10 years ago
Attachment: | grass64_dbf_driver_transactions.2.diff added |
---|
stub transaction functions for DBF driver
by , 10 years ago
Attachment: | grass64_dbf_driver_transactions.diff added |
---|
stub transaction functions for DBF driver
comment:8 by , 10 years ago
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.
follow-up: 10 comment:9 by , 10 years ago
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 by , 10 years ago
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 by , 10 years ago
Resolution: | → wontfix |
---|---|
Status: | new → closed |
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.
I modified the patch but don't know where to add these two items:
I suppose they need to go somewhere into lib/db/ ?