/*------------------------------------------------------------------------- * * common.c-- * common routines between pg_dump and pg4_dump * * Copyright (c) 1994, Regents of the University of California * * * IDENTIFICATION * /usr/local/devel/pglite/cvs/src/bin/pg_dump/common.c,v 1.5 1995/06/28 22:32:35 jolly Exp * *------------------------------------------------------------------------- */ #include #include #include /* for MAXHOSTNAMELEN on most */ #if defined(sparc_solaris) || defined(i386_solaris) #include /* for MAXHOSTNAMELEN on some */ #endif #include "postgres.h" #include "libpq-fe.h" #include "libpq/auth.h" #include /* for strdup () *( #include "pg_dump.h" /* * check_conn_and_db checks the connection and the database */ void check_conn_and_db() { char *string= PQexec(" "); switch(*string) { case 'E': case 'R': PQfinish(); exit(2); break; } } /* * findTypeByOid * given an oid of a type, return its typename * * if oid is "0", return "opaque" -- this is a special case * * NOTE: should hash this, but just do linear search for now */ char* findTypeByOid(TypeInfo* tinfo, int numTypes, char* oid) { int i; if (strcmp(oid, "0") == 0) return g_opaque_type; for (i=0;i 0) { result = (char**)malloc(sizeof(char*) * numParents); j = 0; for (i=0;i= 0; i--) { tblinfo[i].parentRels = findParentsByOid(tblinfo, numTables, inhinfo, numInherits, tblinfo[i].oid, &tblinfo[i].numParents); for (k=0;k 1 && relname[1] == ','); }