Index: doc/src/sgml/ref/pg_dump.sgml =================================================================== RCS file: /projects/cvsroot/pgsql/doc/src/sgml/ref/pg_dump.sgml,v retrieving revision 1.80 diff -c -r1.80 pg_dump.sgml *** doc/src/sgml/ref/pg_dump.sgml 25 Jul 2005 22:12:31 -0000 1.80 --- doc/src/sgml/ref/pg_dump.sgml 23 Sep 2005 07:12:52 -0000 *************** *** 388,406 **** Dump data for table ! only. It is possible for there to be ! multiple tables with the same name in different schemas; if that ! is the case, all matching tables will be dumped. Specify both ! ! In this mode, pg_dump makes no ! attempt to dump any other database objects that the selected table ! may depend upon. Therefore, there is no guarantee ! that the results of a single-table dump can be successfully ! restored by themselves into a clean database. --- 388,408 ---- Dump data for table ! only. This option can be repeated to get more than one table. ! It is possible for there to be multiple tables with the same name in ! different schemas. If that is the case, pg_dump will dump all ! matching tables. Specify both ! In this mode, pg_dump makes no ! attempt to dump any other database objects that the selected ! tables may depend upon. Therefore, there is no guarantee that ! the results of a selected-table dump can be successfully ! restored by themselves into a clean database. Index: src/bin/pg_dump/pg_dump.c =================================================================== RCS file: /projects/cvsroot/pgsql/src/bin/pg_dump/pg_dump.c,v retrieving revision 1.421 diff -c -r1.421 pg_dump.c *** src/bin/pg_dump/pg_dump.c 21 Sep 2005 19:58:02 -0000 1.421 --- src/bin/pg_dump/pg_dump.c 23 Sep 2005 07:13:02 -0000 *************** *** 93,100 **** /* obsolete as of 7.3: */ static Oid g_last_builtin_oid; /* value of the last builtin oid */ ! static char *selectTableName = NULL; /* name of a single table to dump */ ! static char *selectSchemaName = NULL; /* name of a single schema to dump */ char g_opaque_type[10]; /* name for the opaque type */ --- 93,102 ---- /* obsolete as of 7.3: */ static Oid g_last_builtin_oid; /* value of the last builtin oid */ ! static char **selectTableNames = NULL; /* name(s) of specified table(s) to dump */ ! static int tab_max = 0, tab_idx = 0; ! static char **selectSchemaNames = NULL; /* name(s) of specified schema(s) to dump */ ! static int schem_max = 0, schem_idx = 0; char g_opaque_type[10]; /* name for the opaque type */ *************** *** 333,339 **** break; case 'n': /* Dump data for this schema only */ ! selectSchemaName = strdup(optarg); break; case 'o': /* Dump oids */ --- 335,345 ---- break; case 'n': /* Dump data for this schema only */ ! if (schem_idx == schem_max) { ! schem_max += 32; ! selectSchemaNames = pg_realloc(selectSchemaNames, schem_max*sizeof(char *)); ! } ! selectSchemaNames[schem_idx++] = pg_strdup(optarg); break; case 'o': /* Dump oids */ *************** *** 359,369 **** case 'S': /* Username for superuser in plain text * output */ ! outputSuperuser = strdup(optarg); break; ! case 't': /* Dump data for this table only */ ! selectTableName = strdup(optarg); break; case 'u': --- 365,379 ---- case 'S': /* Username for superuser in plain text * output */ ! outputSuperuser = pg_strdup(optarg); break; ! case 't': /* Dump data for th(is|ese) table(s) only */ ! if (tab_idx == tab_max) { ! tab_max += 32; ! selectTableNames = pg_realloc(selectTableNames, tab_max*sizeof(char *)); ! } ! selectTableNames[tab_idx++] = pg_strdup(optarg); break; case 'u': *************** *** 450,456 **** exit(1); } ! if (selectTableName != NULL || selectSchemaName != NULL) outputBlobs = false; if (dumpInserts == true && oids == true) --- 460,466 ---- exit(1); } ! if (selectTableNames != NULL || selectSchemaNames != NULL) outputBlobs = false; if (dumpInserts == true && oids == true) *************** *** 526,532 **** /* Set the client encoding */ if (dumpencoding) { ! char *cmd = malloc(strlen(dumpencoding) + 32); sprintf(cmd,"SET client_encoding='%s'", dumpencoding); do_sql_command(g_conn, cmd); free(cmd); --- 536,542 ---- /* Set the client encoding */ if (dumpencoding) { ! char *cmd = pg_malloc(strlen(dumpencoding) + 32); sprintf(cmd,"SET client_encoding='%s'", dumpencoding); do_sql_command(g_conn, cmd); free(cmd); *************** *** 572,588 **** /* Add placeholders to allow correct sorting of blobs */ DumpableObject *blobobj; ! blobobj = (DumpableObject *) malloc(sizeof(DumpableObject)); blobobj->objType = DO_BLOBS; blobobj->catId = nilCatalogId; AssignDumpId(blobobj); ! blobobj->name = strdup("BLOBS"); ! blobobj = (DumpableObject *) malloc(sizeof(DumpableObject)); blobobj->objType = DO_BLOB_COMMENTS; blobobj->catId = nilCatalogId; AssignDumpId(blobobj); ! blobobj->name = strdup("BLOB COMMENTS"); } /* --- 582,598 ---- /* Add placeholders to allow correct sorting of blobs */ DumpableObject *blobobj; ! blobobj = (DumpableObject *) pg_malloc(sizeof(DumpableObject)); blobobj->objType = DO_BLOBS; blobobj->catId = nilCatalogId; AssignDumpId(blobobj); ! blobobj->name = pg_strdup("BLOBS"); ! blobobj = (DumpableObject *) pg_malloc(sizeof(DumpableObject)); blobobj->objType = DO_BLOB_COMMENTS; blobobj->catId = nilCatalogId; AssignDumpId(blobobj); ! blobobj->name = pg_strdup("BLOB COMMENTS"); } /* *************** *** 618,624 **** dumpEncoding(g_fout); /* The database item is always second, unless we don't want it at all */ ! if (!dataOnly && selectTableName == NULL && selectSchemaName == NULL) dumpDatabase(g_fout); /* Now the rearrangeable objects. */ --- 628,634 ---- dumpEncoding(g_fout); /* The database item is always second, unless we don't want it at all */ ! if (!dataOnly && selectTableNames == NULL && selectSchemaNames == NULL) dumpDatabase(g_fout); /* Now the rearrangeable objects. */ *************** *** 729,746 **** selectDumpableNamespace(NamespaceInfo *nsinfo) { /* ! * If a specific table is being dumped, do not dump any complete ! * namespaces. If a specific namespace is being dumped, dump just ! * that namespace. Otherwise, dump all non-system namespaces. */ ! if (selectTableName != NULL) nsinfo->dump = false; ! else if (selectSchemaName != NULL) { ! if (strcmp(nsinfo->dobj.name, selectSchemaName) == 0) ! nsinfo->dump = true; ! else ! nsinfo->dump = false; } else if (strncmp(nsinfo->dobj.name, "pg_", 3) == 0 || strcmp(nsinfo->dobj.name, "information_schema") == 0) --- 739,763 ---- selectDumpableNamespace(NamespaceInfo *nsinfo) { /* ! * If specific tables are being dumped, do not dump any complete ! * namespaces. If specific namespaces are being dumped, dump just ! * those namespaces. If both specific tables and specific ! * namespaces are being dumped, dump just the tables that match ! * the namespaces. Otherwise, dump all non-system namespaces. */ ! if (selectTableNames != NULL) nsinfo->dump = false; ! else if (selectSchemaNames != NULL) { ! int i; ! nsinfo->dump = false; ! for(i = 0; i < schem_idx; i++) { ! if (strcmp(nsinfo->dobj.name, selectSchemaNames[i]) == 0) ! { ! nsinfo->dump = true; ! break; ! } ! } } else if (strncmp(nsinfo->dobj.name, "pg_", 3) == 0 || strcmp(nsinfo->dobj.name, "information_schema") == 0) *************** *** 764,777 **** tbinfo->dump = false; if (tbinfo->dobj.namespace->dump) tbinfo->dump = true; ! else if (selectTableName != NULL && ! strcmp(tbinfo->dobj.name, selectTableName) == 0) { ! /* If both -s and -t specified, must match both to dump */ ! if (selectSchemaName == NULL) ! tbinfo->dump = true; ! else if (strcmp(tbinfo->dobj.namespace->dobj.name, selectSchemaName) == 0) ! tbinfo->dump = true; } } --- 781,802 ---- tbinfo->dump = false; if (tbinfo->dobj.namespace->dump) tbinfo->dump = true; ! else if (selectTableNames != NULL) { ! int i = 0; ! int j = 0; ! for(i = 0; i < tab_idx; i++) { ! if (strcmp(tbinfo->dobj.name, selectTableNames[i]) == 0) ! { ! /* If both -s and -t specified, must match both to dump */ ! for(j = 0; j < schem_idx; j++) { ! if (selectSchemaNames == NULL) ! tbinfo->dump = true; ! else if (strcmp(tbinfo->dobj.namespace->dobj.name, selectSchemaNames[j]) == 0) ! tbinfo->dump = true; ! } ! } ! } } } *************** *** 1136,1142 **** { TableDataInfo *tdinfo; ! tdinfo = (TableDataInfo *) malloc(sizeof(TableDataInfo)); tdinfo->dobj.objType = DO_TABLE_DATA; --- 1161,1167 ---- { TableDataInfo *tdinfo; ! tdinfo = (TableDataInfo *) pg_malloc(sizeof(TableDataInfo)); tdinfo->dobj.objType = DO_TABLE_DATA; *************** *** 1563,1577 **** */ if (g_fout->remoteVersion < 70300) { ! nsinfo = (NamespaceInfo *) malloc(2 * sizeof(NamespaceInfo)); nsinfo[0].dobj.objType = DO_NAMESPACE; nsinfo[0].dobj.catId.tableoid = 0; nsinfo[0].dobj.catId.oid = 0; AssignDumpId(&nsinfo[0].dobj); ! nsinfo[0].dobj.name = strdup("public"); ! nsinfo[0].rolname = strdup(""); ! nsinfo[0].nspacl = strdup(""); selectDumpableNamespace(&nsinfo[0]); --- 1588,1602 ---- */ if (g_fout->remoteVersion < 70300) { ! nsinfo = (NamespaceInfo *) pg_malloc(2 * sizeof(NamespaceInfo)); nsinfo[0].dobj.objType = DO_NAMESPACE; nsinfo[0].dobj.catId.tableoid = 0; nsinfo[0].dobj.catId.oid = 0; AssignDumpId(&nsinfo[0].dobj); ! nsinfo[0].dobj.name = pg_strdup("public"); ! nsinfo[0].rolname = pg_strdup(""); ! nsinfo[0].nspacl = pg_strdup(""); selectDumpableNamespace(&nsinfo[0]); *************** *** 1579,1587 **** nsinfo[1].dobj.catId.tableoid = 0; nsinfo[1].dobj.catId.oid = 1; AssignDumpId(&nsinfo[1].dobj); ! nsinfo[1].dobj.name = strdup("pg_catalog"); ! nsinfo[1].rolname = strdup(""); ! nsinfo[1].nspacl = strdup(""); selectDumpableNamespace(&nsinfo[1]); --- 1604,1612 ---- nsinfo[1].dobj.catId.tableoid = 0; nsinfo[1].dobj.catId.oid = 1; AssignDumpId(&nsinfo[1].dobj); ! nsinfo[1].dobj.name = pg_strdup("pg_catalog"); ! nsinfo[1].rolname = pg_strdup(""); ! nsinfo[1].nspacl = pg_strdup(""); selectDumpableNamespace(&nsinfo[1]); *************** *** 1610,1616 **** ntups = PQntuples(res); ! nsinfo = (NamespaceInfo *) malloc(ntups * sizeof(NamespaceInfo)); i_tableoid = PQfnumber(res, "tableoid"); i_oid = PQfnumber(res, "oid"); --- 1635,1641 ---- ntups = PQntuples(res); ! nsinfo = (NamespaceInfo *) pg_malloc(ntups * sizeof(NamespaceInfo)); i_tableoid = PQfnumber(res, "tableoid"); i_oid = PQfnumber(res, "oid"); *************** *** 1624,1632 **** nsinfo[i].dobj.catId.tableoid = atooid(PQgetvalue(res, i, i_tableoid)); nsinfo[i].dobj.catId.oid = atooid(PQgetvalue(res, i, i_oid)); AssignDumpId(&nsinfo[i].dobj); ! nsinfo[i].dobj.name = strdup(PQgetvalue(res, i, i_nspname)); ! nsinfo[i].rolname = strdup(PQgetvalue(res, i, i_rolname)); ! nsinfo[i].nspacl = strdup(PQgetvalue(res, i, i_nspacl)); /* Decide whether to dump this namespace */ selectDumpableNamespace(&nsinfo[i]); --- 1649,1657 ---- nsinfo[i].dobj.catId.tableoid = atooid(PQgetvalue(res, i, i_tableoid)); nsinfo[i].dobj.catId.oid = atooid(PQgetvalue(res, i, i_oid)); AssignDumpId(&nsinfo[i].dobj); ! nsinfo[i].dobj.name = pg_strdup(PQgetvalue(res, i, i_nspname)); ! nsinfo[i].rolname = pg_strdup(PQgetvalue(res, i, i_rolname)); ! nsinfo[i].nspacl = pg_strdup(PQgetvalue(res, i, i_nspacl)); /* Decide whether to dump this namespace */ selectDumpableNamespace(&nsinfo[i]); *************** *** 1640,1657 **** * If the user attempted to dump a specific namespace, check to ensure * that the specified namespace actually exists. */ ! if (selectSchemaName) { ! for (i = 0; i < ntups; i++) ! if (strcmp(nsinfo[i].dobj.name, selectSchemaName) == 0) ! break; /* Didn't find a match */ ! if (i == ntups) ! { ! write_msg(NULL, "specified schema \"%s\" does not exist\n", ! selectSchemaName); ! exit_nicely(); } } --- 1665,1688 ---- * If the user attempted to dump a specific namespace, check to ensure * that the specified namespace actually exists. */ ! if (selectSchemaNames) { ! int j = 0; ! for (i = 0; i < ntups; i++) { ! for (j = 0; j < schem_idx; j++) { ! if (strcmp(nsinfo[i].dobj.name, selectSchemaNames[j]) == 0) ! { ! goto schema_matches; ! } ! } /* Didn't find a match */ ! schema_matches:if (i == ntups) ! { ! write_msg(NULL, "specified schema \"%s\" does not exist\n", ! selectSchemaNames[j]); ! exit_nicely(); ! } } } *************** *** 1792,1798 **** ntups = PQntuples(res); ! tinfo = (TypeInfo *) malloc(ntups * sizeof(TypeInfo)); i_tableoid = PQfnumber(res, "tableoid"); i_oid = PQfnumber(res, "oid"); --- 1823,1829 ---- ntups = PQntuples(res); ! tinfo = (TypeInfo *) pg_malloc(ntups * sizeof(TypeInfo)); i_tableoid = PQfnumber(res, "tableoid"); i_oid = PQfnumber(res, "oid"); *************** *** 1816,1825 **** tinfo[i].dobj.catId.tableoid = atooid(PQgetvalue(res, i, i_tableoid)); tinfo[i].dobj.catId.oid = atooid(PQgetvalue(res, i, i_oid)); AssignDumpId(&tinfo[i].dobj); ! tinfo[i].dobj.name = strdup(PQgetvalue(res, i, i_typname)); tinfo[i].dobj.namespace = findNamespace(atooid(PQgetvalue(res, i, i_typnamespace)), tinfo[i].dobj.catId.oid); ! tinfo[i].rolname = strdup(PQgetvalue(res, i, i_rolname)); tinfo[i].typinput = atooid(PQgetvalue(res, i, i_typinput)); typoutput = atooid(PQgetvalue(res, i, i_typoutput)); tinfo[i].typelem = atooid(PQgetvalue(res, i, i_typelem)); --- 1847,1856 ---- tinfo[i].dobj.catId.tableoid = atooid(PQgetvalue(res, i, i_tableoid)); tinfo[i].dobj.catId.oid = atooid(PQgetvalue(res, i, i_oid)); AssignDumpId(&tinfo[i].dobj); ! tinfo[i].dobj.name = pg_strdup(PQgetvalue(res, i, i_typname)); tinfo[i].dobj.namespace = findNamespace(atooid(PQgetvalue(res, i, i_typnamespace)), tinfo[i].dobj.catId.oid); ! tinfo[i].rolname = pg_strdup(PQgetvalue(res, i, i_rolname)); tinfo[i].typinput = atooid(PQgetvalue(res, i, i_typinput)); typoutput = atooid(PQgetvalue(res, i, i_typoutput)); tinfo[i].typelem = atooid(PQgetvalue(res, i, i_typelem)); *************** *** 1953,1959 **** ntups = PQntuples(res); *numOprs = ntups; ! oprinfo = (OprInfo *) malloc(ntups * sizeof(OprInfo)); i_tableoid = PQfnumber(res, "tableoid"); i_oid = PQfnumber(res, "oid"); --- 1984,1990 ---- ntups = PQntuples(res); *numOprs = ntups; ! oprinfo = (OprInfo *) pg_malloc(ntups * sizeof(OprInfo)); i_tableoid = PQfnumber(res, "tableoid"); i_oid = PQfnumber(res, "oid"); *************** *** 1968,1977 **** oprinfo[i].dobj.catId.tableoid = atooid(PQgetvalue(res, i, i_tableoid)); oprinfo[i].dobj.catId.oid = atooid(PQgetvalue(res, i, i_oid)); AssignDumpId(&oprinfo[i].dobj); ! oprinfo[i].dobj.name = strdup(PQgetvalue(res, i, i_oprname)); oprinfo[i].dobj.namespace = findNamespace(atooid(PQgetvalue(res, i, i_oprnamespace)), oprinfo[i].dobj.catId.oid); ! oprinfo[i].rolname = strdup(PQgetvalue(res, i, i_rolname)); oprinfo[i].oprcode = atooid(PQgetvalue(res, i, i_oprcode)); if (strlen(oprinfo[i].rolname) == 0) --- 1999,2008 ---- oprinfo[i].dobj.catId.tableoid = atooid(PQgetvalue(res, i, i_tableoid)); oprinfo[i].dobj.catId.oid = atooid(PQgetvalue(res, i, i_oid)); AssignDumpId(&oprinfo[i].dobj); ! oprinfo[i].dobj.name = pg_strdup(PQgetvalue(res, i, i_oprname)); oprinfo[i].dobj.namespace = findNamespace(atooid(PQgetvalue(res, i, i_oprnamespace)), oprinfo[i].dobj.catId.oid); ! oprinfo[i].rolname = pg_strdup(PQgetvalue(res, i, i_rolname)); oprinfo[i].oprcode = atooid(PQgetvalue(res, i, i_oprcode)); if (strlen(oprinfo[i].rolname) == 0) *************** *** 2034,2040 **** ntups = PQntuples(res); *numConversions = ntups; ! convinfo = (ConvInfo *) malloc(ntups * sizeof(ConvInfo)); i_tableoid = PQfnumber(res, "tableoid"); i_oid = PQfnumber(res, "oid"); --- 2065,2071 ---- ntups = PQntuples(res); *numConversions = ntups; ! convinfo = (ConvInfo *) pg_malloc(ntups * sizeof(ConvInfo)); i_tableoid = PQfnumber(res, "tableoid"); i_oid = PQfnumber(res, "oid"); *************** *** 2048,2057 **** convinfo[i].dobj.catId.tableoid = atooid(PQgetvalue(res, i, i_tableoid)); convinfo[i].dobj.catId.oid = atooid(PQgetvalue(res, i, i_oid)); AssignDumpId(&convinfo[i].dobj); ! convinfo[i].dobj.name = strdup(PQgetvalue(res, i, i_conname)); convinfo[i].dobj.namespace = findNamespace(atooid(PQgetvalue(res, i, i_connamespace)), convinfo[i].dobj.catId.oid); ! convinfo[i].rolname = strdup(PQgetvalue(res, i, i_rolname)); } PQclear(res); --- 2079,2088 ---- convinfo[i].dobj.catId.tableoid = atooid(PQgetvalue(res, i, i_tableoid)); convinfo[i].dobj.catId.oid = atooid(PQgetvalue(res, i, i_oid)); AssignDumpId(&convinfo[i].dobj); ! convinfo[i].dobj.name = pg_strdup(PQgetvalue(res, i, i_conname)); convinfo[i].dobj.namespace = findNamespace(atooid(PQgetvalue(res, i, i_connamespace)), convinfo[i].dobj.catId.oid); ! convinfo[i].rolname = pg_strdup(PQgetvalue(res, i, i_rolname)); } PQclear(res); *************** *** 2121,2127 **** ntups = PQntuples(res); *numOpclasses = ntups; ! opcinfo = (OpclassInfo *) malloc(ntups * sizeof(OpclassInfo)); i_tableoid = PQfnumber(res, "tableoid"); i_oid = PQfnumber(res, "oid"); --- 2152,2158 ---- ntups = PQntuples(res); *numOpclasses = ntups; ! opcinfo = (OpclassInfo *) pg_malloc(ntups * sizeof(OpclassInfo)); i_tableoid = PQfnumber(res, "tableoid"); i_oid = PQfnumber(res, "oid"); *************** *** 2135,2144 **** opcinfo[i].dobj.catId.tableoid = atooid(PQgetvalue(res, i, i_tableoid)); opcinfo[i].dobj.catId.oid = atooid(PQgetvalue(res, i, i_oid)); AssignDumpId(&opcinfo[i].dobj); ! opcinfo[i].dobj.name = strdup(PQgetvalue(res, i, i_opcname)); opcinfo[i].dobj.namespace = findNamespace(atooid(PQgetvalue(res, i, i_opcnamespace)), opcinfo[i].dobj.catId.oid); ! opcinfo[i].rolname = strdup(PQgetvalue(res, i, i_rolname)); if (g_fout->remoteVersion >= 70300) { --- 2166,2175 ---- opcinfo[i].dobj.catId.tableoid = atooid(PQgetvalue(res, i, i_tableoid)); opcinfo[i].dobj.catId.oid = atooid(PQgetvalue(res, i, i_oid)); AssignDumpId(&opcinfo[i].dobj); ! opcinfo[i].dobj.name = pg_strdup(PQgetvalue(res, i, i_opcname)); opcinfo[i].dobj.namespace = findNamespace(atooid(PQgetvalue(res, i, i_opcnamespace)), opcinfo[i].dobj.catId.oid); ! opcinfo[i].rolname = pg_strdup(PQgetvalue(res, i, i_rolname)); if (g_fout->remoteVersion >= 70300) { *************** *** 2229,2235 **** ntups = PQntuples(res); *numAggs = ntups; ! agginfo = (AggInfo *) malloc(ntups * sizeof(AggInfo)); i_tableoid = PQfnumber(res, "tableoid"); i_oid = PQfnumber(res, "oid"); --- 2260,2266 ---- ntups = PQntuples(res); *numAggs = ntups; ! agginfo = (AggInfo *) pg_malloc(ntups * sizeof(AggInfo)); i_tableoid = PQfnumber(res, "tableoid"); i_oid = PQfnumber(res, "oid"); *************** *** 2245,2264 **** agginfo[i].aggfn.dobj.catId.tableoid = atooid(PQgetvalue(res, i, i_tableoid)); agginfo[i].aggfn.dobj.catId.oid = atooid(PQgetvalue(res, i, i_oid)); AssignDumpId(&agginfo[i].aggfn.dobj); ! agginfo[i].aggfn.dobj.name = strdup(PQgetvalue(res, i, i_aggname)); agginfo[i].aggfn.dobj.namespace = findNamespace(atooid(PQgetvalue(res, i, i_aggnamespace)), agginfo[i].aggfn.dobj.catId.oid); ! agginfo[i].aggfn.rolname = strdup(PQgetvalue(res, i, i_rolname)); if (strlen(agginfo[i].aggfn.rolname) == 0) write_msg(NULL, "WARNING: owner of aggregate function \"%s\" appears to be invalid\n", agginfo[i].aggfn.dobj.name); agginfo[i].aggfn.lang = InvalidOid; /* not currently * interesting */ agginfo[i].aggfn.nargs = 1; ! agginfo[i].aggfn.argtypes = (Oid *) malloc(sizeof(Oid)); agginfo[i].aggfn.argtypes[0] = atooid(PQgetvalue(res, i, i_aggbasetype)); agginfo[i].aggfn.prorettype = InvalidOid; /* not saved */ ! agginfo[i].aggfn.proacl = strdup(PQgetvalue(res, i, i_aggacl)); agginfo[i].anybasetype = false; /* computed when it's dumped */ agginfo[i].fmtbasetype = NULL; /* computed when it's dumped */ } --- 2276,2295 ---- agginfo[i].aggfn.dobj.catId.tableoid = atooid(PQgetvalue(res, i, i_tableoid)); agginfo[i].aggfn.dobj.catId.oid = atooid(PQgetvalue(res, i, i_oid)); AssignDumpId(&agginfo[i].aggfn.dobj); ! agginfo[i].aggfn.dobj.name = pg_strdup(PQgetvalue(res, i, i_aggname)); agginfo[i].aggfn.dobj.namespace = findNamespace(atooid(PQgetvalue(res, i, i_aggnamespace)), agginfo[i].aggfn.dobj.catId.oid); ! agginfo[i].aggfn.rolname = pg_strdup(PQgetvalue(res, i, i_rolname)); if (strlen(agginfo[i].aggfn.rolname) == 0) write_msg(NULL, "WARNING: owner of aggregate function \"%s\" appears to be invalid\n", agginfo[i].aggfn.dobj.name); agginfo[i].aggfn.lang = InvalidOid; /* not currently * interesting */ agginfo[i].aggfn.nargs = 1; ! agginfo[i].aggfn.argtypes = (Oid *) pg_malloc(sizeof(Oid)); agginfo[i].aggfn.argtypes[0] = atooid(PQgetvalue(res, i, i_aggbasetype)); agginfo[i].aggfn.prorettype = InvalidOid; /* not saved */ ! agginfo[i].aggfn.proacl = pg_strdup(PQgetvalue(res, i, i_aggacl)); agginfo[i].anybasetype = false; /* computed when it's dumped */ agginfo[i].fmtbasetype = NULL; /* computed when it's dumped */ } *************** *** 2352,2358 **** *numFuncs = ntups; ! finfo = (FuncInfo *) calloc(ntups, sizeof(FuncInfo)); i_tableoid = PQfnumber(res, "tableoid"); i_oid = PQfnumber(res, "oid"); --- 2383,2389 ---- *numFuncs = ntups; ! finfo = (FuncInfo *) pg_calloc(ntups, sizeof(FuncInfo)); i_tableoid = PQfnumber(res, "tableoid"); i_oid = PQfnumber(res, "oid"); *************** *** 2371,2390 **** finfo[i].dobj.catId.tableoid = atooid(PQgetvalue(res, i, i_tableoid)); finfo[i].dobj.catId.oid = atooid(PQgetvalue(res, i, i_oid)); AssignDumpId(&finfo[i].dobj); ! finfo[i].dobj.name = strdup(PQgetvalue(res, i, i_proname)); finfo[i].dobj.namespace = findNamespace(atooid(PQgetvalue(res, i, i_pronamespace)), finfo[i].dobj.catId.oid); ! finfo[i].rolname = strdup(PQgetvalue(res, i, i_rolname)); finfo[i].lang = atooid(PQgetvalue(res, i, i_prolang)); finfo[i].prorettype = atooid(PQgetvalue(res, i, i_prorettype)); ! finfo[i].proacl = strdup(PQgetvalue(res, i, i_proacl)); finfo[i].nargs = atoi(PQgetvalue(res, i, i_pronargs)); if (finfo[i].nargs == 0) finfo[i].argtypes = NULL; else { ! finfo[i].argtypes = (Oid *) malloc(finfo[i].nargs * sizeof(Oid)); parseOidArray(PQgetvalue(res, i, i_proargtypes), finfo[i].argtypes, finfo[i].nargs); } --- 2402,2421 ---- finfo[i].dobj.catId.tableoid = atooid(PQgetvalue(res, i, i_tableoid)); finfo[i].dobj.catId.oid = atooid(PQgetvalue(res, i, i_oid)); AssignDumpId(&finfo[i].dobj); ! finfo[i].dobj.name = pg_strdup(PQgetvalue(res, i, i_proname)); finfo[i].dobj.namespace = findNamespace(atooid(PQgetvalue(res, i, i_pronamespace)), finfo[i].dobj.catId.oid); ! finfo[i].rolname = pg_strdup(PQgetvalue(res, i, i_rolname)); finfo[i].lang = atooid(PQgetvalue(res, i, i_prolang)); finfo[i].prorettype = atooid(PQgetvalue(res, i, i_prorettype)); ! finfo[i].proacl = pg_strdup(PQgetvalue(res, i, i_proacl)); finfo[i].nargs = atoi(PQgetvalue(res, i, i_pronargs)); if (finfo[i].nargs == 0) finfo[i].argtypes = NULL; else { ! finfo[i].argtypes = (Oid *) pg_malloc(finfo[i].nargs * sizeof(Oid)); parseOidArray(PQgetvalue(res, i, i_proargtypes), finfo[i].argtypes, finfo[i].nargs); } *************** *** 2598,2604 **** * dumping only one, because we don't yet know which tables might be * inheritance ancestors of the target table. */ ! tblinfo = (TableInfo *) calloc(ntups, sizeof(TableInfo)); i_reltableoid = PQfnumber(res, "tableoid"); i_reloid = PQfnumber(res, "oid"); --- 2629,2635 ---- * dumping only one, because we don't yet know which tables might be * inheritance ancestors of the target table. */ ! tblinfo = (TableInfo *) pg_calloc(ntups, sizeof(TableInfo)); i_reltableoid = PQfnumber(res, "tableoid"); i_reloid = PQfnumber(res, "oid"); *************** *** 2622,2632 **** tblinfo[i].dobj.catId.tableoid = atooid(PQgetvalue(res, i, i_reltableoid)); tblinfo[i].dobj.catId.oid = atooid(PQgetvalue(res, i, i_reloid)); AssignDumpId(&tblinfo[i].dobj); ! tblinfo[i].dobj.name = strdup(PQgetvalue(res, i, i_relname)); tblinfo[i].dobj.namespace = findNamespace(atooid(PQgetvalue(res, i, i_relnamespace)), tblinfo[i].dobj.catId.oid); ! tblinfo[i].rolname = strdup(PQgetvalue(res, i, i_rolname)); ! tblinfo[i].relacl = strdup(PQgetvalue(res, i, i_relacl)); tblinfo[i].relkind = *(PQgetvalue(res, i, i_relkind)); tblinfo[i].hasindex = (strcmp(PQgetvalue(res, i, i_relhasindex), "t") == 0); tblinfo[i].hasrules = (strcmp(PQgetvalue(res, i, i_relhasrules), "t") == 0); --- 2653,2663 ---- tblinfo[i].dobj.catId.tableoid = atooid(PQgetvalue(res, i, i_reltableoid)); tblinfo[i].dobj.catId.oid = atooid(PQgetvalue(res, i, i_reloid)); AssignDumpId(&tblinfo[i].dobj); ! tblinfo[i].dobj.name = pg_strdup(PQgetvalue(res, i, i_relname)); tblinfo[i].dobj.namespace = findNamespace(atooid(PQgetvalue(res, i, i_relnamespace)), tblinfo[i].dobj.catId.oid); ! tblinfo[i].rolname = pg_strdup(PQgetvalue(res, i, i_rolname)); ! tblinfo[i].relacl = pg_strdup(PQgetvalue(res, i, i_relacl)); tblinfo[i].relkind = *(PQgetvalue(res, i, i_relkind)); tblinfo[i].hasindex = (strcmp(PQgetvalue(res, i, i_relhasindex), "t") == 0); tblinfo[i].hasrules = (strcmp(PQgetvalue(res, i, i_relhasrules), "t") == 0); *************** *** 2643,2649 **** tblinfo[i].owning_tab = atooid(PQgetvalue(res, i, i_owning_tab)); tblinfo[i].owning_col = atoi(PQgetvalue(res, i, i_owning_col)); } ! tblinfo[i].reltablespace = strdup(PQgetvalue(res, i, i_reltablespace)); /* other fields were zeroed above */ --- 2674,2680 ---- tblinfo[i].owning_tab = atooid(PQgetvalue(res, i, i_owning_tab)); tblinfo[i].owning_col = atoi(PQgetvalue(res, i, i_owning_col)); } ! tblinfo[i].reltablespace = pg_strdup(PQgetvalue(res, i, i_reltablespace)); /* other fields were zeroed above */ *************** *** 2693,2709 **** * simplistic since we don't fully check the combination of -n and -t * switches.) */ ! if (selectTableName) { ! for (i = 0; i < ntups; i++) ! if (strcmp(tblinfo[i].dobj.name, selectTableName) == 0) ! break; ! /* Didn't find a match */ ! if (i == ntups) { write_msg(NULL, "specified table \"%s\" does not exist\n", ! selectTableName); exit_nicely(); } } --- 2724,2744 ---- * simplistic since we don't fully check the combination of -n and -t * switches.) */ ! if (selectTableNames != NULL) { ! int i = 0; ! int j = 0; ! for (i = 0; i < ntups; i++) { ! for (j = 0; j < tab_idx; j++) { ! if (strcmp(tblinfo[i].dobj.name, selectTableNames[j]) == 0) ! goto check_match; ! } ! } /* Didn't find a match */ ! check_match: if (i == ntups) { write_msg(NULL, "specified table \"%s\" does not exist\n", ! selectTableNames[j]); exit_nicely(); } } *************** *** 2749,2755 **** *numInherits = ntups; ! inhinfo = (InhInfo *) malloc(ntups * sizeof(InhInfo)); i_inhrelid = PQfnumber(res, "inhrelid"); i_inhparent = PQfnumber(res, "inhparent"); --- 2784,2790 ---- *numInherits = ntups; ! inhinfo = (InhInfo *) pg_malloc(ntups * sizeof(InhInfo)); i_inhrelid = PQfnumber(res, "inhrelid"); i_inhparent = PQfnumber(res, "inhparent"); *************** *** 2934,2941 **** i_conoid = PQfnumber(res, "conoid"); i_tablespace = PQfnumber(res, "tablespace"); ! indxinfo = (IndxInfo *) malloc(ntups * sizeof(IndxInfo)); ! constrinfo = (ConstraintInfo *) malloc(ntups * sizeof(ConstraintInfo)); for (j = 0; j < ntups; j++) { --- 2969,2976 ---- i_conoid = PQfnumber(res, "conoid"); i_tablespace = PQfnumber(res, "tablespace"); ! indxinfo = (IndxInfo *) pg_malloc(ntups * sizeof(IndxInfo)); ! constrinfo = (ConstraintInfo *) pg_malloc(ntups * sizeof(ConstraintInfo)); for (j = 0; j < ntups; j++) { *************** *** 2945,2956 **** indxinfo[j].dobj.catId.tableoid = atooid(PQgetvalue(res, j, i_tableoid)); indxinfo[j].dobj.catId.oid = atooid(PQgetvalue(res, j, i_oid)); AssignDumpId(&indxinfo[j].dobj); ! indxinfo[j].dobj.name = strdup(PQgetvalue(res, j, i_indexname)); indxinfo[j].dobj.namespace = tbinfo->dobj.namespace; indxinfo[j].indextable = tbinfo; ! indxinfo[j].indexdef = strdup(PQgetvalue(res, j, i_indexdef)); indxinfo[j].indnkeys = atoi(PQgetvalue(res, j, i_indnkeys)); ! indxinfo[j].tablespace = strdup(PQgetvalue(res, j, i_tablespace)); /* * In pre-7.4 releases, indkeys may contain more entries than --- 2980,2991 ---- indxinfo[j].dobj.catId.tableoid = atooid(PQgetvalue(res, j, i_tableoid)); indxinfo[j].dobj.catId.oid = atooid(PQgetvalue(res, j, i_oid)); AssignDumpId(&indxinfo[j].dobj); ! indxinfo[j].dobj.name = pg_strdup(PQgetvalue(res, j, i_indexname)); indxinfo[j].dobj.namespace = tbinfo->dobj.namespace; indxinfo[j].indextable = tbinfo; ! indxinfo[j].indexdef = pg_strdup(PQgetvalue(res, j, i_indexdef)); indxinfo[j].indnkeys = atoi(PQgetvalue(res, j, i_indnkeys)); ! indxinfo[j].tablespace = pg_strdup(PQgetvalue(res, j, i_tablespace)); /* * In pre-7.4 releases, indkeys may contain more entries than *************** *** 2961,2967 **** * indexes. But we have to allocate enough space to keep * parseOidArray from complaining. */ ! indxinfo[j].indkeys = (Oid *) malloc(INDEX_MAX_KEYS * sizeof(Oid)); parseOidArray(PQgetvalue(res, j, i_indkey), indxinfo[j].indkeys, INDEX_MAX_KEYS); indxinfo[j].indisclustered = (PQgetvalue(res, j, i_indisclustered)[0] == 't'); --- 2996,3002 ---- * indexes. But we have to allocate enough space to keep * parseOidArray from complaining. */ ! indxinfo[j].indkeys = (Oid *) pg_malloc(INDEX_MAX_KEYS * sizeof(Oid)); parseOidArray(PQgetvalue(res, j, i_indkey), indxinfo[j].indkeys, INDEX_MAX_KEYS); indxinfo[j].indisclustered = (PQgetvalue(res, j, i_indisclustered)[0] == 't'); *************** *** 2980,2986 **** constrinfo[j].dobj.catId.tableoid = atooid(PQgetvalue(res, j, i_contableoid)); constrinfo[j].dobj.catId.oid = atooid(PQgetvalue(res, j, i_conoid)); AssignDumpId(&constrinfo[j].dobj); ! constrinfo[j].dobj.name = strdup(PQgetvalue(res, j, i_conname)); constrinfo[j].dobj.namespace = tbinfo->dobj.namespace; constrinfo[j].contable = tbinfo; constrinfo[j].condomain = NULL; --- 3015,3021 ---- constrinfo[j].dobj.catId.tableoid = atooid(PQgetvalue(res, j, i_contableoid)); constrinfo[j].dobj.catId.oid = atooid(PQgetvalue(res, j, i_conoid)); AssignDumpId(&constrinfo[j].dobj); ! constrinfo[j].dobj.name = pg_strdup(PQgetvalue(res, j, i_conname)); constrinfo[j].dobj.namespace = tbinfo->dobj.namespace; constrinfo[j].contable = tbinfo; constrinfo[j].condomain = NULL; *************** *** 3073,3079 **** i_conname = PQfnumber(res, "conname"); i_condef = PQfnumber(res, "condef"); ! constrinfo = (ConstraintInfo *) malloc(ntups * sizeof(ConstraintInfo)); for (j = 0; j < ntups; j++) { --- 3108,3114 ---- i_conname = PQfnumber(res, "conname"); i_condef = PQfnumber(res, "condef"); ! constrinfo = (ConstraintInfo *) pg_malloc(ntups * sizeof(ConstraintInfo)); for (j = 0; j < ntups; j++) { *************** *** 3081,3092 **** constrinfo[j].dobj.catId.tableoid = atooid(PQgetvalue(res, j, i_contableoid)); constrinfo[j].dobj.catId.oid = atooid(PQgetvalue(res, j, i_conoid)); AssignDumpId(&constrinfo[j].dobj); ! constrinfo[j].dobj.name = strdup(PQgetvalue(res, j, i_conname)); constrinfo[j].dobj.namespace = tbinfo->dobj.namespace; constrinfo[j].contable = tbinfo; constrinfo[j].condomain = NULL; constrinfo[j].contype = 'f'; ! constrinfo[j].condef = strdup(PQgetvalue(res, j, i_condef)); constrinfo[j].conindex = 0; constrinfo[j].coninherited = false; constrinfo[j].separate = true; --- 3116,3127 ---- constrinfo[j].dobj.catId.tableoid = atooid(PQgetvalue(res, j, i_contableoid)); constrinfo[j].dobj.catId.oid = atooid(PQgetvalue(res, j, i_conoid)); AssignDumpId(&constrinfo[j].dobj); ! constrinfo[j].dobj.name = pg_strdup(PQgetvalue(res, j, i_conname)); constrinfo[j].dobj.namespace = tbinfo->dobj.namespace; constrinfo[j].contable = tbinfo; constrinfo[j].condomain = NULL; constrinfo[j].contype = 'f'; ! constrinfo[j].condef = pg_strdup(PQgetvalue(res, j, i_condef)); constrinfo[j].conindex = 0; constrinfo[j].coninherited = false; constrinfo[j].separate = true; *************** *** 3153,3159 **** i_conname = PQfnumber(res, "conname"); i_consrc = PQfnumber(res, "consrc"); ! constrinfo = (ConstraintInfo *) malloc(ntups * sizeof(ConstraintInfo)); tinfo->nDomChecks = ntups; tinfo->domChecks = constrinfo; --- 3188,3194 ---- i_conname = PQfnumber(res, "conname"); i_consrc = PQfnumber(res, "consrc"); ! constrinfo = (ConstraintInfo *) pg_malloc(ntups * sizeof(ConstraintInfo)); tinfo->nDomChecks = ntups; tinfo->domChecks = constrinfo; *************** *** 3164,3175 **** constrinfo[i].dobj.catId.tableoid = atooid(PQgetvalue(res, i, i_tableoid)); constrinfo[i].dobj.catId.oid = atooid(PQgetvalue(res, i, i_oid)); AssignDumpId(&constrinfo[i].dobj); ! constrinfo[i].dobj.name = strdup(PQgetvalue(res, i, i_conname)); constrinfo[i].dobj.namespace = tinfo->dobj.namespace; constrinfo[i].contable = NULL; constrinfo[i].condomain = tinfo; constrinfo[i].contype = 'c'; ! constrinfo[i].condef = strdup(PQgetvalue(res, i, i_consrc)); constrinfo[i].conindex = 0; constrinfo[i].coninherited = false; constrinfo[i].separate = false; --- 3199,3210 ---- constrinfo[i].dobj.catId.tableoid = atooid(PQgetvalue(res, i, i_tableoid)); constrinfo[i].dobj.catId.oid = atooid(PQgetvalue(res, i, i_oid)); AssignDumpId(&constrinfo[i].dobj); ! constrinfo[i].dobj.name = pg_strdup(PQgetvalue(res, i, i_conname)); constrinfo[i].dobj.namespace = tinfo->dobj.namespace; constrinfo[i].contable = NULL; constrinfo[i].condomain = tinfo; constrinfo[i].contype = 'c'; ! constrinfo[i].condef = pg_strdup(PQgetvalue(res, i, i_consrc)); constrinfo[i].conindex = 0; constrinfo[i].coninherited = false; constrinfo[i].separate = false; *************** *** 3236,3242 **** *numRules = ntups; ! ruleinfo = (RuleInfo *) malloc(ntups * sizeof(RuleInfo)); i_tableoid = PQfnumber(res, "tableoid"); i_oid = PQfnumber(res, "oid"); --- 3271,3277 ---- *numRules = ntups; ! ruleinfo = (RuleInfo *) pg_malloc(ntups * sizeof(RuleInfo)); i_tableoid = PQfnumber(res, "tableoid"); i_oid = PQfnumber(res, "oid"); *************** *** 3253,3259 **** ruleinfo[i].dobj.catId.tableoid = atooid(PQgetvalue(res, i, i_tableoid)); ruleinfo[i].dobj.catId.oid = atooid(PQgetvalue(res, i, i_oid)); AssignDumpId(&ruleinfo[i].dobj); ! ruleinfo[i].dobj.name = strdup(PQgetvalue(res, i, i_rulename)); ruletableoid = atooid(PQgetvalue(res, i, i_ruletable)); ruleinfo[i].ruletable = findTableByOid(ruletableoid); if (ruleinfo[i].ruletable == NULL) --- 3288,3294 ---- ruleinfo[i].dobj.catId.tableoid = atooid(PQgetvalue(res, i, i_tableoid)); ruleinfo[i].dobj.catId.oid = atooid(PQgetvalue(res, i, i_oid)); AssignDumpId(&ruleinfo[i].dobj); ! ruleinfo[i].dobj.name = pg_strdup(PQgetvalue(res, i, i_rulename)); ruletableoid = atooid(PQgetvalue(res, i, i_ruletable)); ruleinfo[i].ruletable = findTableByOid(ruletableoid); if (ruleinfo[i].ruletable == NULL) *************** *** 3430,3436 **** i_tgdeferrable = PQfnumber(res, "tgdeferrable"); i_tginitdeferred = PQfnumber(res, "tginitdeferred"); ! tginfo = (TriggerInfo *) malloc(ntups * sizeof(TriggerInfo)); for (j = 0; j < ntups; j++) { --- 3465,3471 ---- i_tgdeferrable = PQfnumber(res, "tgdeferrable"); i_tginitdeferred = PQfnumber(res, "tginitdeferred"); ! tginfo = (TriggerInfo *) pg_malloc(ntups * sizeof(TriggerInfo)); for (j = 0; j < ntups; j++) { *************** *** 3438,3450 **** tginfo[j].dobj.catId.tableoid = atooid(PQgetvalue(res, j, i_tableoid)); tginfo[j].dobj.catId.oid = atooid(PQgetvalue(res, j, i_oid)); AssignDumpId(&tginfo[j].dobj); ! tginfo[j].dobj.name = strdup(PQgetvalue(res, j, i_tgname)); tginfo[j].dobj.namespace = tbinfo->dobj.namespace; tginfo[j].tgtable = tbinfo; ! tginfo[j].tgfname = strdup(PQgetvalue(res, j, i_tgfname)); tginfo[j].tgtype = atoi(PQgetvalue(res, j, i_tgtype)); tginfo[j].tgnargs = atoi(PQgetvalue(res, j, i_tgnargs)); ! tginfo[j].tgargs = strdup(PQgetvalue(res, j, i_tgargs)); tginfo[j].tgisconstraint = *(PQgetvalue(res, j, i_tgisconstraint)) == 't'; tginfo[j].tgenabled = *(PQgetvalue(res, j, i_tgenabled)) == 't'; tginfo[j].tgdeferrable = *(PQgetvalue(res, j, i_tgdeferrable)) == 't'; --- 3473,3485 ---- tginfo[j].dobj.catId.tableoid = atooid(PQgetvalue(res, j, i_tableoid)); tginfo[j].dobj.catId.oid = atooid(PQgetvalue(res, j, i_oid)); AssignDumpId(&tginfo[j].dobj); ! tginfo[j].dobj.name = pg_strdup(PQgetvalue(res, j, i_tgname)); tginfo[j].dobj.namespace = tbinfo->dobj.namespace; tginfo[j].tgtable = tbinfo; ! tginfo[j].tgfname = pg_strdup(PQgetvalue(res, j, i_tgfname)); tginfo[j].tgtype = atoi(PQgetvalue(res, j, i_tgtype)); tginfo[j].tgnargs = atoi(PQgetvalue(res, j, i_tgnargs)); ! tginfo[j].tgargs = pg_strdup(PQgetvalue(res, j, i_tgargs)); tginfo[j].tgisconstraint = *(PQgetvalue(res, j, i_tgisconstraint)) == 't'; tginfo[j].tgenabled = *(PQgetvalue(res, j, i_tgenabled)) == 't'; tginfo[j].tgdeferrable = *(PQgetvalue(res, j, i_tgdeferrable)) == 't'; *************** *** 3452,3458 **** if (tginfo[j].tgisconstraint) { ! tginfo[j].tgconstrname = strdup(PQgetvalue(res, j, i_tgconstrname)); tginfo[j].tgconstrrelid = atooid(PQgetvalue(res, j, i_tgconstrrelid)); if (OidIsValid(tginfo[j].tgconstrrelid)) { --- 3487,3493 ---- if (tginfo[j].tgisconstraint) { ! tginfo[j].tgconstrname = pg_strdup(PQgetvalue(res, j, i_tgconstrname)); tginfo[j].tgconstrrelid = atooid(PQgetvalue(res, j, i_tgconstrrelid)); if (OidIsValid(tginfo[j].tgconstrrelid)) { *************** *** 3463,3469 **** tginfo[j].tgconstrrelid); exit_nicely(); } ! tginfo[j].tgconstrrelname = strdup(PQgetvalue(res, j, i_tgconstrrelname)); } else tginfo[j].tgconstrrelname = NULL; --- 3498,3504 ---- tginfo[j].tgconstrrelid); exit_nicely(); } ! tginfo[j].tgconstrrelname = pg_strdup(PQgetvalue(res, j, i_tgconstrrelname)); } else tginfo[j].tgconstrrelname = NULL; *************** *** 3532,3538 **** *numProcLangs = ntups; ! planginfo = (ProcLangInfo *) malloc(ntups * sizeof(ProcLangInfo)); i_tableoid = PQfnumber(res, "tableoid"); i_oid = PQfnumber(res, "oid"); --- 3567,3573 ---- *numProcLangs = ntups; ! planginfo = (ProcLangInfo *) pg_malloc(ntups * sizeof(ProcLangInfo)); i_tableoid = PQfnumber(res, "tableoid"); i_oid = PQfnumber(res, "oid"); *************** *** 3552,3571 **** planginfo[i].dobj.catId.oid = atooid(PQgetvalue(res, i, i_oid)); AssignDumpId(&planginfo[i].dobj); ! planginfo[i].dobj.name = strdup(PQgetvalue(res, i, i_lanname)); planginfo[i].lanpltrusted = *(PQgetvalue(res, i, i_lanpltrusted)) == 't'; planginfo[i].lanplcallfoid = atooid(PQgetvalue(res, i, i_lanplcallfoid)); if (g_fout->remoteVersion >= 70300) { planginfo[i].lanvalidator = atooid(PQgetvalue(res, i, i_lanvalidator)); ! planginfo[i].lanacl = strdup(PQgetvalue(res, i, i_lanacl)); } else { FuncInfo *funcInfo; planginfo[i].lanvalidator = InvalidOid; ! planginfo[i].lanacl = strdup("{=U}"); /* * We need to make a dependency to ensure the function will be --- 3587,3606 ---- planginfo[i].dobj.catId.oid = atooid(PQgetvalue(res, i, i_oid)); AssignDumpId(&planginfo[i].dobj); ! planginfo[i].dobj.name = pg_strdup(PQgetvalue(res, i, i_lanname)); planginfo[i].lanpltrusted = *(PQgetvalue(res, i, i_lanpltrusted)) == 't'; planginfo[i].lanplcallfoid = atooid(PQgetvalue(res, i, i_lanplcallfoid)); if (g_fout->remoteVersion >= 70300) { planginfo[i].lanvalidator = atooid(PQgetvalue(res, i, i_lanvalidator)); ! planginfo[i].lanacl = pg_strdup(PQgetvalue(res, i, i_lanacl)); } else { FuncInfo *funcInfo; planginfo[i].lanvalidator = InvalidOid; ! planginfo[i].lanacl = pg_strdup("{=U}"); /* * We need to make a dependency to ensure the function will be *************** *** 3635,3641 **** *numCasts = ntups; ! castinfo = (CastInfo *) malloc(ntups * sizeof(CastInfo)); i_tableoid = PQfnumber(res, "tableoid"); i_oid = PQfnumber(res, "oid"); --- 3670,3676 ---- *numCasts = ntups; ! castinfo = (CastInfo *) pg_malloc(ntups * sizeof(CastInfo)); i_tableoid = PQfnumber(res, "tableoid"); i_oid = PQfnumber(res, "oid"); *************** *** 3825,3844 **** i_attislocal = PQfnumber(res, "attislocal"); tbinfo->numatts = ntups; ! tbinfo->attnames = (char **) malloc(ntups * sizeof(char *)); ! tbinfo->atttypnames = (char **) malloc(ntups * sizeof(char *)); ! tbinfo->atttypmod = (int *) malloc(ntups * sizeof(int)); ! tbinfo->attstattarget = (int *) malloc(ntups * sizeof(int)); ! tbinfo->attstorage = (char *) malloc(ntups * sizeof(char)); ! tbinfo->typstorage = (char *) malloc(ntups * sizeof(char)); ! tbinfo->attisdropped = (bool *) malloc(ntups * sizeof(bool)); ! tbinfo->attislocal = (bool *) malloc(ntups * sizeof(bool)); ! tbinfo->attisserial = (bool *) malloc(ntups * sizeof(bool)); ! tbinfo->notnull = (bool *) malloc(ntups * sizeof(bool)); ! tbinfo->attrdefs = (AttrDefInfo **) malloc(ntups * sizeof(AttrDefInfo *)); ! tbinfo->inhAttrs = (bool *) malloc(ntups * sizeof(bool)); ! tbinfo->inhAttrDef = (bool *) malloc(ntups * sizeof(bool)); ! tbinfo->inhNotNull = (bool *) malloc(ntups * sizeof(bool)); hasdefaults = false; for (j = 0; j < ntups; j++) --- 3860,3879 ---- i_attislocal = PQfnumber(res, "attislocal"); tbinfo->numatts = ntups; ! tbinfo->attnames = (char **) pg_malloc(ntups * sizeof(char *)); ! tbinfo->atttypnames = (char **) pg_malloc(ntups * sizeof(char *)); ! tbinfo->atttypmod = (int *) pg_malloc(ntups * sizeof(int)); ! tbinfo->attstattarget = (int *) pg_malloc(ntups * sizeof(int)); ! tbinfo->attstorage = (char *) pg_malloc(ntups * sizeof(char)); ! tbinfo->typstorage = (char *) pg_malloc(ntups * sizeof(char)); ! tbinfo->attisdropped = (bool *) pg_malloc(ntups * sizeof(bool)); ! tbinfo->attislocal = (bool *) pg_malloc(ntups * sizeof(bool)); ! tbinfo->attisserial = (bool *) pg_malloc(ntups * sizeof(bool)); ! tbinfo->notnull = (bool *) pg_malloc(ntups * sizeof(bool)); ! tbinfo->attrdefs = (AttrDefInfo **) pg_malloc(ntups * sizeof(AttrDefInfo *)); ! tbinfo->inhAttrs = (bool *) pg_malloc(ntups * sizeof(bool)); ! tbinfo->inhAttrDef = (bool *) pg_malloc(ntups * sizeof(bool)); ! tbinfo->inhNotNull = (bool *) pg_malloc(ntups * sizeof(bool)); hasdefaults = false; for (j = 0; j < ntups; j++) *************** *** 3849,3856 **** tbinfo->dobj.name); exit_nicely(); } ! tbinfo->attnames[j] = strdup(PQgetvalue(res, j, i_attname)); ! tbinfo->atttypnames[j] = strdup(PQgetvalue(res, j, i_atttypname)); tbinfo->atttypmod[j] = atoi(PQgetvalue(res, j, i_atttypmod)); tbinfo->attstattarget[j] = atoi(PQgetvalue(res, j, i_attstattarget)); tbinfo->attstorage[j] = *(PQgetvalue(res, j, i_attstorage)); --- 3884,3891 ---- tbinfo->dobj.name); exit_nicely(); } ! tbinfo->attnames[j] = pg_strdup(PQgetvalue(res, j, i_attname)); ! tbinfo->atttypnames[j] = pg_strdup(PQgetvalue(res, j, i_atttypname)); tbinfo->atttypmod[j] = atoi(PQgetvalue(res, j, i_atttypmod)); tbinfo->attstattarget[j] = atoi(PQgetvalue(res, j, i_attstattarget)); tbinfo->attstorage[j] = *(PQgetvalue(res, j, i_attstorage)); *************** *** 3922,3928 **** check_sql_result(res, g_conn, q->data, PGRES_TUPLES_OK); numDefaults = PQntuples(res); ! attrdefs = (AttrDefInfo *) malloc(numDefaults * sizeof(AttrDefInfo)); for (j = 0; j < numDefaults; j++) { --- 3957,3963 ---- check_sql_result(res, g_conn, q->data, PGRES_TUPLES_OK); numDefaults = PQntuples(res); ! attrdefs = (AttrDefInfo *) pg_malloc(numDefaults * sizeof(AttrDefInfo)); for (j = 0; j < numDefaults; j++) { *************** *** 3934,3942 **** AssignDumpId(&attrdefs[j].dobj); attrdefs[j].adtable = tbinfo; attrdefs[j].adnum = adnum = atoi(PQgetvalue(res, j, 2)); ! attrdefs[j].adef_expr = strdup(PQgetvalue(res, j, 3)); ! attrdefs[j].dobj.name = strdup(tbinfo->dobj.name); attrdefs[j].dobj.namespace = tbinfo->dobj.namespace; /* --- 3969,3977 ---- AssignDumpId(&attrdefs[j].dobj); attrdefs[j].adtable = tbinfo; attrdefs[j].adnum = adnum = atoi(PQgetvalue(res, j, 2)); ! attrdefs[j].adef_expr = pg_strdup(PQgetvalue(res, j, 3)); ! attrdefs[j].dobj.name = pg_strdup(tbinfo->dobj.name); attrdefs[j].dobj.namespace = tbinfo->dobj.namespace; /* *************** *** 4050,4056 **** exit_nicely(); } ! constrs = (ConstraintInfo *) malloc(numConstrs * sizeof(ConstraintInfo)); tbinfo->checkexprs = constrs; for (j = 0; j < numConstrs; j++) --- 4085,4091 ---- exit_nicely(); } ! constrs = (ConstraintInfo *) pg_malloc(numConstrs * sizeof(ConstraintInfo)); tbinfo->checkexprs = constrs; for (j = 0; j < numConstrs; j++) *************** *** 4059,4070 **** constrs[j].dobj.catId.tableoid = atooid(PQgetvalue(res, j, 0)); constrs[j].dobj.catId.oid = atooid(PQgetvalue(res, j, 1)); AssignDumpId(&constrs[j].dobj); ! constrs[j].dobj.name = strdup(PQgetvalue(res, j, 2)); constrs[j].dobj.namespace = tbinfo->dobj.namespace; constrs[j].contable = tbinfo; constrs[j].condomain = NULL; constrs[j].contype = 'c'; ! constrs[j].condef = strdup(PQgetvalue(res, j, 3)); constrs[j].conindex = 0; constrs[j].coninherited = false; constrs[j].separate = false; --- 4094,4105 ---- constrs[j].dobj.catId.tableoid = atooid(PQgetvalue(res, j, 0)); constrs[j].dobj.catId.oid = atooid(PQgetvalue(res, j, 1)); AssignDumpId(&constrs[j].dobj); ! constrs[j].dobj.name = pg_strdup(PQgetvalue(res, j, 2)); constrs[j].dobj.namespace = tbinfo->dobj.namespace; constrs[j].contable = tbinfo; constrs[j].condomain = NULL; constrs[j].contype = 'c'; ! constrs[j].condef = pg_strdup(PQgetvalue(res, j, 3)); constrs[j].conindex = 0; constrs[j].coninherited = false; constrs[j].separate = false; *************** *** 4431,4437 **** ntups = PQntuples(res); ! comments = (CommentItem *) malloc(ntups * sizeof(CommentItem)); for (i = 0; i < ntups; i++) { --- 4466,4472 ---- ntups = PQntuples(res); ! comments = (CommentItem *) pg_malloc(ntups * sizeof(CommentItem)); for (i = 0; i < ntups; i++) { *************** *** 4552,4558 **** q = createPQExpBuffer(); delq = createPQExpBuffer(); ! qnspname = strdup(fmtId(nspinfo->dobj.name)); appendPQExpBuffer(delq, "DROP SCHEMA %s;\n", qnspname); --- 4587,4593 ---- q = createPQExpBuffer(); delq = createPQExpBuffer(); ! qnspname = pg_strdup(fmtId(nspinfo->dobj.name)); appendPQExpBuffer(delq, "DROP SCHEMA %s;\n", qnspname); *************** *** 5089,5095 **** static bool shouldDumpProcLangs(void) { ! if (selectTableName != NULL || selectSchemaName != NULL) return false; /* And they're schema not data */ if (dataOnly) --- 5124,5130 ---- static bool shouldDumpProcLangs(void) { ! if (selectTableNames != NULL || selectSchemaNames != NULL) return false; /* And they're schema not data */ if (dataOnly) *************** *** 5149,5155 **** defqry = createPQExpBuffer(); delqry = createPQExpBuffer(); ! qlanname = strdup(fmtId(plang->dobj.name)); /* * If dumping a HANDLER clause, treat the language as being in the --- 5184,5190 ---- defqry = createPQExpBuffer(); delqry = createPQExpBuffer(); ! qlanname = pg_strdup(fmtId(plang->dobj.name)); /* * If dumping a HANDLER clause, treat the language as being in the *************** *** 6020,6026 **** char *paren; bool inquote; ! name = strdup(proc); /* find non-double-quoted left paren */ inquote = false; for (paren = name; *paren; paren++) --- 6055,6061 ---- char *paren; bool inquote; ! name = pg_strdup(proc); /* find non-double-quoted left paren */ inquote = false; for (paren = name; *paren; paren++) *************** *** 6064,6070 **** char *paren; bool inquote; ! name = strdup(opr); /* find non-double-quoted left paren */ inquote = false; for (paren = name; *paren; paren++) --- 6099,6105 ---- char *paren; bool inquote; ! name = pg_strdup(opr); /* find non-double-quoted left paren */ inquote = false; for (paren = name; *paren; paren++) *************** *** 6172,6178 **** opckeytype = PQgetvalue(res, 0, i_opckeytype); opcdefault = PQgetvalue(res, 0, i_opcdefault); /* amname will still be needed after we PQclear res */ ! amname = strdup(PQgetvalue(res, 0, i_amname)); /* * DROP must be fully qualified in case same name appears in --- 6207,6213 ---- opckeytype = PQgetvalue(res, 0, i_opckeytype); opcdefault = PQgetvalue(res, 0, i_opcdefault); /* amname will still be needed after we PQclear res */ ! amname = pg_strdup(PQgetvalue(res, 0, i_amname)); /* * DROP must be fully qualified in case same name appears in *************** *** 6586,6592 **** /* we save anybasetype for format_aggregate_signature */ agginfo->anybasetype = (PQgetvalue(res, 0, i_anybasetype)[0] == 't'); /* we save fmtbasetype for format_aggregate_signature */ ! agginfo->fmtbasetype = strdup(PQgetvalue(res, 0, i_fmtbasetype)); convertok = (PQgetvalue(res, 0, i_convertok)[0] == 't'); aggsig = format_aggregate_signature(agginfo, fout, true); --- 6621,6627 ---- /* we save anybasetype for format_aggregate_signature */ agginfo->anybasetype = (PQgetvalue(res, 0, i_anybasetype)[0] == 't'); /* we save fmtbasetype for format_aggregate_signature */ ! agginfo->fmtbasetype = pg_strdup(PQgetvalue(res, 0, i_fmtbasetype)); convertok = (PQgetvalue(res, 0, i_convertok)[0] == 't'); aggsig = format_aggregate_signature(agginfo, fout, true); *************** *** 6769,6775 **** dumpTableSchema(fout, tbinfo); /* Handle the ACL here */ ! namecopy = strdup(fmtId(tbinfo->dobj.name)); dumpACL(fout, tbinfo->dobj.catId, tbinfo->dobj.dumpId, "TABLE", namecopy, tbinfo->dobj.name, tbinfo->dobj.namespace->dobj.name, tbinfo->rolname, --- 6804,6810 ---- dumpTableSchema(fout, tbinfo); /* Handle the ACL here */ ! namecopy = pg_strdup(fmtId(tbinfo->dobj.name)); dumpACL(fout, tbinfo->dobj.catId, tbinfo->dobj.dumpId, "TABLE", namecopy, tbinfo->dobj.name, tbinfo->dobj.namespace->dobj.name, tbinfo->rolname, *************** *** 8146,8152 **** destroyPQExpBuffer(query); if (curSchemaName) free(curSchemaName); ! curSchemaName = strdup(schemaName); } /* --- 8181,8187 ---- destroyPQExpBuffer(query); if (curSchemaName) free(curSchemaName); ! curSchemaName = pg_strdup(schemaName); } /* *************** *** 8167,8179 **** if (oid == 0) { if ((opts & zeroAsOpaque) != 0) ! return strdup(g_opaque_type); else if ((opts & zeroAsAny) != 0) ! return strdup("'any'"); else if ((opts & zeroAsStar) != 0) ! return strdup("*"); else if ((opts & zeroAsNone) != 0) ! return strdup("NONE"); } query = createPQExpBuffer(); --- 8202,8214 ---- if (oid == 0) { if ((opts & zeroAsOpaque) != 0) ! return pg_strdup(g_opaque_type); else if ((opts & zeroAsAny) != 0) ! return pg_strdup("'any'"); else if ((opts & zeroAsStar) != 0) ! return pg_strdup("*"); else if ((opts & zeroAsNone) != 0) ! return pg_strdup("NONE"); } query = createPQExpBuffer(); *************** *** 8210,8221 **** if (g_fout->remoteVersion >= 70100) { /* already quoted */ ! result = strdup(PQgetvalue(res, 0, 0)); } else { /* may need to quote it */ ! result = strdup(fmtId(PQgetvalue(res, 0, 0))); } PQclear(res); --- 8245,8256 ---- if (g_fout->remoteVersion >= 70100) { /* already quoted */ ! result = pg_strdup(PQgetvalue(res, 0, 0)); } else { /* may need to quote it */ ! result = pg_strdup(fmtId(PQgetvalue(res, 0, 0))); } PQclear(res); *************** *** 8288,8294 **** if (isarray) appendPQExpBuffer(buf, "[]"); ! result = strdup(buf->data); destroyPQExpBuffer(buf); return result; --- 8323,8329 ---- if (isarray) appendPQExpBuffer(buf, "[]"); ! result = pg_strdup(buf->data); destroyPQExpBuffer(buf); return result; *************** *** 8398,8400 **** --- 8433,8488 ---- write_msg(NULL, "The command was: %s\n", query); exit_nicely(); } + + void * + pg_calloc(size_t nmemb, size_t size) + { + void * the_calloc; + the_calloc = calloc(nmemb, size); + if (the_calloc == NULL) + { + fprintf(stderr, _("out of memory\n")); + exit_nicely(); + } + return the_calloc; + } + + void * + pg_malloc(size_t size) + { + void * the_malloc; + the_malloc = malloc(size); + if (the_malloc == NULL) + { + fprintf(stderr, _("out of memory\n")); + exit_nicely(); + } + return the_malloc; + } + + + void * + pg_realloc(void *ptr, size_t size) + { + void * the_realloc; + the_realloc = realloc(ptr, size); + if (the_realloc == NULL) + { + fprintf(stderr, _("out of memory\n")); + exit_nicely(); + } + return the_realloc; + } + + char * + pg_strdup(const char *s) + { + char * the_string; + the_string = strdup(s); + if (the_string == NULL) + { + fprintf(stderr, _("out of memory\n")); + exit_nicely(); + } + return the_string; + } Index: src/bin/pg_dump/pg_dump.h =================================================================== RCS file: /projects/cvsroot/pgsql/src/bin/pg_dump/pg_dump.h,v retrieving revision 1.121 diff -c -r1.121 pg_dump.h *** src/bin/pg_dump/pg_dump.h 5 Sep 2005 23:50:49 -0000 1.121 --- src/bin/pg_dump/pg_dump.h 23 Sep 2005 07:13:02 -0000 *************** *** 387,390 **** --- 387,395 ---- extern CastInfo *getCasts(int *numCasts); extern void getTableAttrs(TableInfo *tbinfo, int numTables); + void *pg_calloc(size_t nmemb, size_t size); + void *pg_malloc(size_t size); + void *pg_realloc(void *ptr, size_t size); + char *pg_strdup(const char *s); + #endif /* PG_DUMP_H */