View Ticket
Not logged in
Ticket Hash: b42228181174ffbc9b207fd54445057790bb5146
Title: unwanted console output
Status: Closed Type: Code_Defect
Severity: Cosmetic Priority: Immediate
Subsystem: Resolution: Rejected
Last Modified: 2016-05-08 20:42:29
Version Found In: 4.3.0a
User Comments:
anonymous added on 2016-04-26 07:27:52:
Hello,

at first let me say, a lot of thanks for replying and solving the tickets so fast!
I encountered a similar console output problem as in ticket: 0471a3a1a301393f5b0998cb7986bb9b8c5c3247.
The function CreateSpatialIndex() returns a "CreateSpatialIndex() error: either "test"."geometry" isn't a Geometry column or a SpatialIndex is already defined"
This message is not wrong but in my case it is not certain if there is a SpatialIndex on the geometry and I want the function to silently fail in case of an existing SpatialIndex.

I tried reading out if there is already a table in SpatialIndex with:
SELECT count() FROM "SpatialIndex" WHERE "f_table_name" = 'test' AND "f_geometry_column" = 'geometry';
and only use the CreateSpatialIndex() function if count is greater 0. But this SELECT always returns 0. Even when the SpatialIndex exists.

sandro added on 2016-05-08 20:42:29:
1. please look inside the -/src/headers/spatialite/debug.h header file; you'll find a couple of macros intended to flexibly handle any error/warning message reported by the library itself. they are spatialite_e() and spatialite_i()
as you can easily notice the standard default behaviour is the one to print all errors on stderr and all warnings on stdout.
you are absolutely free to change such settings as you wish better.
please look at the spatialite_d() macro implementation, that is intended to completely suppress any debug message when the corresponding conditional flag isn't set.

2. your SQL query is conceptually wrong and can never work.
a more robust query intended to check if some Spatial Index is already defined or not could be this one:
   
SELECT Count(*) 
FROM geometry_columns
WHERE f_table_name = Lower('table') 
  AND f_geometry_column = Lower('geometry')
  AND spatial_index_enabled <> 0;