postgresql - Handling Exception From C Function -


i have function calling function c library. there anyway can catch exception postgres function that's calling c function?

here's function i'm calling:

-- function: public.st_makevalid(geometry)  -- drop function public.st_makevalid(geometry);  create or replace function public.st_makevalid(geometry)  returns geometry '$libdir/postgis-2.0', 'st_makevalid'   language c immutable strict   cost 100; alter function public.st_makevalid(geometry) owner postgres; comment on function public.st_makevalid(geometry) 'args: input - attempts make         invalid geometry valid w/out loosing vertices.'; 

here function i'm calling from:

create or replace function public.mango_repair(geometry)   returns geometry $body$     declare         the_geom geometry := $1;         reason text := st_isvalidreason(the_geom);     begin         if reason 'self-intersection%'             the_geom = st_makevalid(st_boundary(the_geom));         end if;         return the_geom;     exception         when others             raise notice 'something went wrong';             return the_geom;     end; $body$   language plpgsql stable strict   cost 100; alter function public.mango_repair(geometry) owner postgres; 

and here's how i'm calling sql:

update "test_layer" set the_geom = mango_repair(the_geom) not st_isvalid(the_geom); 

when run sql following error , mango_repair function doesn't enter exception block expected.

here error message i'm receiving:

error:  geometry type (multilinestring) not match column type (multipolygon)   ********** error **********  error: geometry type (multilinestring) not match column type (multipolygon) sql state: 22023 

if i'm guessing mean correctly, suspect have postgresql function implemented in c raising postgresql exception. if so, can't catch , handle in normal sql - can use pl/pgsql begin ... exception block. see pl/pgsql documentation details on exception handling features.

further discussion revealed real problem nothing exception handling, , in fact mismatch between geometry types in update query function being called from.


Comments

Popular posts from this blog

Why does Ruby on Rails generate add a blank line to the end of a file? -

keyboard - Smiles and long press feature in Android -

node.js - Bad Request - node js ajax post -