*
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/bin/pg_dump/common.c,v 1.36 1999/12/27 15:42:43 momjian Exp $
+ * $Header: /cvsroot/pgsql/src/bin/pg_dump/common.c,v 1.37 2000/01/16 03:54:58 tgl Exp $
*
* Modifications - 6/12/96 - dave@bensoft.com - version 1.13.dhb.2
*
}
/*
- * parseArgTypes
- * parse a string of eight numbers delimited by spaces
- * into a character array
+ * parseNumericArray
+ * parse a string of numbers delimited by spaces into a character array
*/
void
-parseArgTypes(char **argtypes, const char *str)
+parseNumericArray(const char *str, char **array, int arraysize)
{
int j,
argNum;
argNum = 0;
j = 0;
- while ((s = *str) != '\0')
+ for (;;)
{
- if (s == ' ')
+ s = *str++;
+ if (s == ' ' || s == '\0')
{
- temp[j] = '\0';
- argtypes[argNum] = strdup(temp);
- argNum++;
- j = 0;
+ if (j > 0)
+ {
+ if (argNum >= arraysize)
+ {
+ fprintf(stderr, "parseNumericArray: too many numbers\n");
+ exit(2);
+ }
+ temp[j] = '\0';
+ array[argNum++] = strdup(temp);
+ j = 0;
+ }
+ if (s == '\0')
+ break;
}
else
{
- temp[j] = s;
- j++;
+ if (!isdigit(s) || j >= sizeof(temp)-1)
+ {
+ fprintf(stderr, "parseNumericArray: bogus number\n");
+ exit(2);
+ }
+ temp[j++] = s;
}
- str++;
}
- if (j != 0)
- {
- temp[j] = '\0';
- argtypes[argNum] = strdup(temp);
- }
-
+ while (argNum < arraysize)
+ array[argNum++] = strdup("0");
}
*
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/bin/pg_dump/pg_dump.c,v 1.131 2000/01/10 17:14:40 momjian Exp $
+ * $Header: /cvsroot/pgsql/src/bin/pg_dump/pg_dump.c,v 1.132 2000/01/16 03:54:58 tgl Exp $
*
* Modifications - 6/10/96 - dave@bensoft.com - version 1.13.dhb
*
finfo = (FuncInfo *) malloc(ntups * sizeof(FuncInfo));
+ memset((char *) finfo, 0, ntups * sizeof(FuncInfo));
+
i_oid = PQfnumber(res, "oid");
i_proname = PQfnumber(res, "proname");
i_prolang = PQfnumber(res, "prolang");
finfo[i].retset = (strcmp(PQgetvalue(res, i, i_proretset), "t") == 0);
finfo[i].nargs = atoi(PQgetvalue(res, i, i_pronargs));
finfo[i].lang = atoi(PQgetvalue(res, i, i_prolang));
-
finfo[i].usename = strdup(PQgetvalue(res, i, i_usename));
-
- parseArgTypes(finfo[i].argtypes, PQgetvalue(res, i, i_proargtypes));
-
+ if (finfo[i].nargs < 0 || finfo[i].nargs > FUNC_MAX_ARGS)
+ {
+ fprintf(stderr, "failed sanity check: %s has %d args\n",
+ finfo[i].proname, finfo[i].nargs);
+ exit(2);
+ }
+ parseNumericArray(PQgetvalue(res, i, i_proargtypes),
+ finfo[i].argtypes,
+ finfo[i].nargs);
finfo[i].dumped = 0;
}
indinfo = (IndInfo *) malloc(ntups * sizeof(IndInfo));
+ memset((char *) indinfo, 0, ntups * sizeof(IndInfo));
+
i_indexrelname = PQfnumber(res, "indexrelname");
i_indrelname = PQfnumber(res, "indrelname");
i_indamname = PQfnumber(res, "indamname");
indinfo[i].indrelname = strdup(PQgetvalue(res, i, i_indrelname));
indinfo[i].indamname = strdup(PQgetvalue(res, i, i_indamname));
indinfo[i].indproc = strdup(PQgetvalue(res, i, i_indproc));
- parseArgTypes((char **) indinfo[i].indkey,
- (const char *) PQgetvalue(res, i, i_indkey));
- parseArgTypes((char **) indinfo[i].indclass,
- (const char *) PQgetvalue(res, i, i_indclass));
+ parseNumericArray(PQgetvalue(res, i, i_indkey),
+ indinfo[i].indkey,
+ INDEX_MAX_KEYS);
+ parseNumericArray(PQgetvalue(res, i, i_indclass),
+ indinfo[i].indclass,
+ INDEX_MAX_KEYS);
indinfo[i].indisunique = strdup(PQgetvalue(res, i, i_indisunique));
}
PQclear(res);
*
* Copyright (c) 1994, Regents of the University of California
*
- * $Id: pg_dump.h,v 1.44 2000/01/10 17:14:40 momjian Exp $
+ * $Id: pg_dump.h,v 1.45 2000/01/16 03:54:58 tgl Exp $
*
* Modifications - 6/12/96 - dave@bensoft.com - version 1.13.dhb.2
*
#include "pqexpbuffer.h"
#include "catalog/pg_index.h"
-/*
- * Very temporary hack --- remove this when all pg_dump's uses of it are gone!
- */
-#define MAX_QUERY_SIZE (BLCKSZ*2)
-
-
-/* The *Info data structures run-time C structures used to store
- system catalog information */
+/* The data structures used to store system catalog information */
typedef struct _typeInfo
{
char *proowner;
int lang;
int nargs;
- char *argtypes[FUNC_MAX_ARGS]; /* should be derived from obj/fmgr.h
- * instead of hardwired */
+ char *argtypes[FUNC_MAX_ARGS];
char *prorettype;
- int retset; /* 1 if the function returns a set, 0
- * otherwise */
+ int retset; /* 1 if the function returns a set, else 0 */
char *prosrc;
char *probin;
char *usename;
extern int findTableByName(TableInfo *tbinfo, int numTables, const char *relname);
extern void check_conn_and_db(void);
-extern void parseArgTypes(char **argtypes, const char *str);
+extern void parseNumericArray(const char *str, char **array, int arraysize);
/*
* version specific routines