"retrieve (a.oid, a.aggname, a.aggtransfn1, a.aggtransfn2, a.aggfinalfn, a.aggtranstype1, a.aggbasetype, a.aggtranstype2, a.agginitval1, a.agginitval2) from a in pg_aggregate");
* read all the user-defined functions in the system catalogs and
* return them in the FuncInfo* structure
*
* numFuncs is set to the number of functions read in
*
*
*/
FuncInfo*
getFuncs(int*numFuncs)
{
char*res;
PortalBuffer*pbuf;
intntups;
inti,j;
charquery[MAXQUERYLEN];
FuncInfo*finfo;
char*proargtypes;
inti_oid;
inti_proname;
inti_proowner;
inti_prolang;
inti_pronargs;
inti_proargtypes;
inti_prorettype;
inti_proretset;
inti_prosrc;
inti_probin;
/* find all user-defined funcs */
PQexec("begin");
/*
sprintf(query,
"SELECT oid, proname, proowner, prolang, pronargs, prorettype, proretset, proargtypes, prosrc, probin from pg_proc where oid > '%d'::oid",
g_last_builtin_oid);
*/
sprintf(query,
"retrieve (f.oid, f.proname, f.proowner, f.prolang, f.pronargs, f.prorettype, f.proretset, f.proargtypes, f.prosrc, f.probin) from f in pg_proc where f.oid > \"%d\"::oid",
* for each table in tblinfo, read its attributes types and names
*
* this is implemented in a very inefficient way right now, looping
* through the tblinfo and doing a join per table to find the attrs and their
* types
*
* modifies tblinfo
*/
void
getTableAttrs(TableInfo*tblinfo,intnumTables)
{
inti,j;
charq[MAXQUERYLEN];
inti_attname;
inti_typname;
char*res;
PortalBuffer*pbuf;
intntups;
for(i=0;i<numTables;i++){
/* find all the user attributes and their types*/
/* we must read the attribute names in attribute number order! */
/* because we will use the attnum to index into the attnames array
later */
/*
sprintf(q,"SELECT a.attnum, a.attname, t.typname from pg_attribute a, pg_type t where a.attrelid = '%s' and a.atttypid = t.oid and a.attnum > 0 order by attnum",tblinfo[i].oid);
*/
if(g_verbose)
fprintf(stderr,"%s finding the attrs and types for table: %s %s\n",
g_comment_start,
tblinfo[i].relname,
g_comment_end);
sprintf(q,"retrieve (a.attnum, a.attname, t.typname) from a in pg_attribute, t in pg_type where a.attrelid = \"%s\" and a.atttypid = t.oid and a.attnum > 0 sort by attnum",tblinfo[i].oid);
tblinfo[i].inhAttrs[j]=0;/* this flag is set in flagInhAttrs()*/
}
PQclear(res+1);
}
}
/*
* getIndices
* read all the user-defined indices information
* from the system catalogs return them in the InhInfo* structure
*
* numIndices is set to the number of indices read in
*
*
*/
IndInfo*
getIndices(int*numIndices)
{
inti;
charquery[MAXQUERYLEN];
char*res;
PortalBuffer*pbuf;
intntups;
IndInfo*indinfo;
inti_indexrelname;
inti_indrelname;
inti_indamname;
inti_indproc;
inti_indkey;
inti_indclassname;
/* find all the user-define indices.
We do not handle partial indices.
We also assume that only single key indices
this is a 5-way join !!
*/
PQexec("begin");
/*
sprintf(query,
"SELECT t1.relname as indexrelname, t2.relname as indrelname, i.indproc, i.indkey[0], o.opcname as indclassname, a.amname as indamname from pg_index i, pg_class t1, pg_class t2, pg_opclass o, pg_am a where t1.oid = i.indexrelid and t2.oid = i.indrelid and o.oid = i.indclass[0] and t1.relam = a.oid and i.indexrelid > '%d'::oid and t2.relname !~ '^pg_';",
g_last_builtin_oid);
*/
sprintf(query,
"retrieve (indexrelname = t1.relname, indrelname = t2.relname, i.indproc, i.indkey[0], indclassname = o.opcname, indamname = a.amname) from i in pg_index, t1 in pg_class, t2 in pg_class, o in pg_opclass, a in pg_am where t1.oid = i.indexrelid and t2.oid = i.indrelid and o.oid = i.indclass[0] and t1.relam = a.oid and i.indexrelid > \"%d\"::oid and t2.relname !~ \"^pg_\" and t1.relname !~ \"^Xinx\"",