[postgis-devel] improvement to raster2pgsql error output

Graeme B. Bell grb at skogoglandskap.no
Tue Jun 18 01:42:54 PDT 2013


Hello all,

All users, particularly beginners, rely on raster2pgsql to get raster data into postgis. If you attempt to add a raster twice by mistake or re-use the same name (a common error), you get some horrible output as follows (see end of email).

I'm referring to the part starting 'invalid command'. 

Unfortunately, it's not possible for raster2pgsql itself to know if a table will exist in the DB when the emitted SQL is run. 

However, my feeling is that it would be more helpful if the emitted SQL detects if the relation already exists and aborts cleanly with a helpful message, rather than spewing numbers and raising a question of the quality of the emitted SQL ("invalid command \."). 

Unfortunately, I do not have the time to implement this myself, but I'd like to add it as a low priority TODO. Does anyone else agree/disagree about whether this would provide a small improvement for users?

Graeme. 

=========
root at slack64:/home/software/geo/raster# raster2pgsql
 -t 100x100 -I -C -M -Y bogota.tif bogota | psql -d test
Processing 1/1: bogota.tif
BEGIN
NOTICE:  CREATE TABLE will create implicit sequence "bogota_rid_seq1" for serial column "bogota.rid"
ERROR:  relation "bogota" already exists
ERROR:  current transaction is aborted, commands ignored until end of transaction block
invalid command \.
ERROR:  syntax error at or near "01000001000000000000004E400000000000004"
LINE 1: 01000001000000000000004E400000000000004EC00000000040E61A4100...
        ^
ERROR:  current transaction is aborted, commands ignored until end of transaction block
ERROR:  current transaction is aborted, commands ignored until end of transaction block
ROLLBACK
VACUUM
======


More information about the postgis-devel mailing list