table creation using backend functions

From: Alice Lottini <alice_lottini(at)yahoo(dot)it>
To: PostgreSQL Mailing List Hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: table creation using backend functions
Date: 2003-04-24 18:19:00
Message-ID: 20030424181900.27807.qmail@web13706.mail.yahoo.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Hi everybody,
We've created a dynamically loadable module which
reads data by directly invoking the access methods;
now we need to create a new table and to write data in
it by calling backend functions, as we cannot use SQL
statements.

Here is our function body:

...

/* DUMMY_TUPLE is a tuple of our newly-defined type
(whose creation is successful) */
tupdesc=RelationNameGetTupleDesc(DUMMY_TUPLE);

/* newtabcreate is our function's name */
namelist=textToQualifiedNameList(relname,"newtabcreate");
rangevar=makeRangeVarFromNameList(namelist);
relnamespace=RangeVarGetCreationNamespace(rangevar);
if (!IsBootstrapProcessingMode())
{

aclresult=pg_namespace_aclcheck(relnamespace,GetUserId(),ACL_CREATE);
if (aclresult != ACLCHECK_OK)

aclcheck_error(aclresult,get_namespace_name(relnamespace));
}
namestring=NameListToString(namelist);
reloid=heap_create_with_catalog(namestring,relnamespace,tupdesc,RELKIND_RELATION,false,allowSystemTableMods);
CommandCounterIncrement();
result=ObjectIdGetDatum(reloid);

...

As we try and execute the function, some fatal error
occurs and the server terminates and restarts again.
Obviously the table hasn't been created, but the
strange thing is that both relnamespace (the namespace
Oid) and reloid (the relation oid) seem to be valid
(they do not match with the InvalidOid).
We've also seen that there is the function
DefineRelation which maybe could be useful, but we do
not know how to directly fill the CreateStmt structure
(in particular: how do we have to set NodeTag and
TableElts?).
Thanks in advance for your help!

alice and lorena

______________________________________________________________________
Yahoo! Cellulari: loghi, suonerie, picture message per il tuo telefonino
http://it.yahoo.com/mail_it/foot/?http://it.mobile.yahoo.com/index2002.html

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Bruce Momjian 2003-04-24 18:35:02 close() vs. closesocket()
Previous Message Kurt Roeckx 2003-04-24 18:07:44 Re: query optimization scenarios 17,701 times faster!!!