Hi, I'm trying to implement my own access method. Now I've implemented and compiled it but I've problems when I try to use it. I got folowing AM function definitions: CREATE OR REPLACE FUNCTION atomrtgettuple (INTERNAL ,INT4) RETURNS BOOL AS 'E:\\pgsource\\postgresql-8.0.7\\contrib\\atomrtree\\libatomrtree.dll', 'atomrtgettuple' LANGUAGE 'C'; CREATE OR REPLACE FUNCTION atomrtinsert (INTERNAL ,INTERNAL, INTERNAL, INTERNAL) RETURNS INTERNAL AS 'E:\\pgsource\\postgresql-8.0.7\\contrib\\atomrtree\\libatomrtree.dll', 'atomrtinsert' LANGUAGE 'C'; CREATE OR REPLACE FUNCTION atomrtbeginscan (INTERNAL ,INT4, INTERNAL) RETURNS INTERNAL AS 'E:\\pgsource\\postgresql-8.0.7\\contrib\\atomrtree\\libatomrtree.dll', 'atomrtbeginscan' LANGUAGE 'C'; CREATE OR REPLACE FUNCTION atomrtrescan (INTERNAL ,INTERNAL) RETURNS VOID AS 'E:\\pgsource\\postgresql-8.0.7\\contrib\\atomrtree\\libatomrtree.dll', 'atomrtrescan' LANGUAGE 'C'; CREATE OR REPLACE FUNCTION atomrtendscan (INTERNAL) RETURNS VOID AS 'E:\\pgsource\\postgresql-8.0.7\\contrib\\atomrtree\\libatomrtree.dll', 'atomrtendscan' LANGUAGE 'C'; CREATE OR REPLACE FUNCTION atomrtmarkpos (INTERNAL) RETURNS VOID AS 'E:\\pgsource\\postgresql-8.0.7\\contrib\\atomrtree\\libatomrtree.dll', 'atomrtmarkpos' LANGUAGE 'C'; CREATE OR REPLACE FUNCTION atomrtrestrpos (INTERNAL) RETURNS VOID AS 'E:\\pgsource\\postgresql-8.0.7\\contrib\\atomrtree\\libatomrtree.dll', 'atomrtrestrpos' LANGUAGE 'C'; CREATE OR REPLACE FUNCTION atomrtbuild (INTERNAL ,INTERNAL, INTERNAL) RETURNS VOID AS 'E:\\pgsource\\postgresql-8.0.7\\contrib\\atomrtree\\libatomrtree.dll', 'atomrtbuild' LANGUAGE 'C'; CREATE OR REPLACE FUNCTION atomrtbulkdelete (INTERNAL ,INTERNAL, INTERNAL) RETURNS INTERNAL AS 'E:\\pgsource\\postgresql-8.0.7\\contrib\\atomrtree\\libatomrtree.dll', 'atomrtbulkdelete' LANGUAGE 'C'; CREATE OR REPLACE FUNCTION atomrtcostestimate (INTERNAL, INTERNAL, INTERNAL, INTERNAL, INTERNAL, INTERNAL, INTERNAL, INTERNAL) RETURNS VOID AS 'E:\\pgsource\\postgresql-8.0.7\\contrib\\atomrtree\\libatomrtree.dll', 'atomrtcostestimate' LANGUAGE 'C'; Then I insert record into pg_am: insert into pg_am( amname, amowner, amstrategies, amsupport, amorderstrategy, amcanunique, amcanmulticol, amindexnulls, amconcurrent, amgettuple, aminsert, ambeginscan, amrescan, amendscan, ammarkpos, amrestrpos, ambuild, ambulkdelete, amvacuumcleanup, amcostestimate) values ( 'atomrtree', (select usesysid from pg_shadow where usename = current_user), 1, 0, 0, 'f', 't', 't', 'f', 'atomrtgettuple', 'atomrtinsert', 'atomrtbeginscan', 'atomrtrescan', 'atomrtendscan', 'atomrtmarkpos', 'atomrtrestrpos', 'atomrtbuild', 'atomrtbulkdelete', '-', 'atomrtcostestimate' ); And when i try to set atomrtree index (create index idx_atom1 on test using atomrtree(col1);), I get error telling me that I can't read on address xxxx. The problem is in the atomrtbuild function, which fails, when I try to work with index_relation variable, which is parameter of that function. The fucntion seems like: Datum atomrtbuild(PG_FUNCTION_ARGS) { Relation heap_rel = (Relation) PG_GETARG_POINTER(0); Relation index_rel = (Relation) PG_GETARG_POINTER(1); IndexInfo *indexInfo = (IndexInfo *) PG_GETARG_POINTER(2); double reltuples; AtomRTBuildState buildstate; Buffer buffer; BlockNumber block_num; Page page; AtomRTreePageOpaque page_opaque; WriteToMyLog("Entering atomrtbuild"); /* no locking is needed */ WriteToMyLog("Before initAtomRTState"); initAtomRTState(&buildstate.atomrtstate, index_rel); WriteToMyLog("After initAtomRTState"); if (index_rel == NULL) WriteToMyLog("index_rel is null"); else WriteToMyLog("index_rel is NOT null"); WriteToMyLog("Before RelationGetNumberOfBlocks(index_rel)"); if (RelationGetNumberOfBlocks(index_rel) != 0) elog(ERROR, "index_rel \"%s\" already contains data", RelationGetRelationName(index_rel)); And RelationGetNumberOfBlocks(index_rel) is the place, where it fails (the index_rel variable is not null). The same problem is, when I try to use heap_rel. I really can't find, where's the problem. I use almost the same code as btree or rtree does. Isn't the problem in the way I create the functions? I mean if the parameter type INTERNAL in: CREATE OR REPLACE FUNCTION atomrtbuild (INTERNAL ,INTERNAL, INTERNAL) RETURNS VOID AS 'E:\\pgsource\\postgresql-8.0.7\\contrib\\atomrtree\\libatomrtree.dll', 'atomrtbuild' LANGUAGE 'C'; is OK? I spent whole afternoon trying to change the params for OPAQUE aso., but nothing works:( Thanks, David Hoksza