ast_debug(1,"Successfully connected to PostgreSQL database.\n");
connected=1;
/* Query the columns */
snprintf(sqlcmd,sizeof(sqlcmd),"select a.attname, t.typname, a.attlen from pg_class c, pg_attribute a, pg_type t where c.oid = a.attrelid and a.atttypid = t.oid and (a.attnum > 0) and c.relname = '%s' order by c.relname, attnum",table);
snprintf(sqlcmd,sizeof(sqlcmd),"select a.attname, t.typname, a.attlen, a.attnotnull, d.adsrc from pg_class c, pg_type t, pg_attribute a left outer join pg_attrdef d on a.atthasdef and d.adrelid = a.attrelid and d.adnum = a.attnum where c.oid = a.attrelid and a.atttypid = t.oid and (a.attnum > 0) and c.relname = '%s' order by c.relname, attnum",table);
result=PQexec(conn,sqlcmd);
if(PQresultStatus(result)!=PGRES_TUPLES_OK){
pgerror=PQresultErrorMessage(result);
@ -466,6 +477,8 @@ static int config_module(int reload)
fname=PQgetvalue(result,i,0);
ftype=PQgetvalue(result,i,1);
flen=PQgetvalue(result,i,2);
fnotnull=PQgetvalue(result,i,3);
fdef=PQgetvalue(result,i,4);
ast_verb(4,"Found column '%s' of type '%s'\n",fname,ftype);