CREATE FUNCTION "nextval8" (varchar) RETURNS int8 AS '


spi_exec "select count(relname) as table_exists from pg_class where relname = ''pgr_lsite''"
if { $table_exists == 0 } {
set lsid 0
} else {
set lsid 0
spi_exec "SELECT pgr_sid as lsid from pgr_lsite"
}
spi_exec "select int8(int8($lsid) * 4294967296::int8) + int8(nextval(''$1'')) as retvalue"
return $retvalue
' LANGUAGE 'pltcl';
