*
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/backend/access/heap/heapam.c,v 1.1.1.1 1996/07/09 06:21:11 scrappy Exp $
+ * $Header: /cvsroot/pgsql/src/backend/access/heap/heapam.c,v 1.1.1.1.2.1 1996/08/24 20:53:09 scrappy Exp $
*
*
* INTERFACE ROUTINES
tup->t_oid = newoid();
LastOidProcessed = tup->t_oid;
}
+ else
+ CheckMaxObjectId(tup->t_oid);
TransactionIdStore(GetCurrentTransactionId(), &(tup->t_xmin));
tup->t_cmin = GetCurrentCommandId();
*
* Copyright (c) 1994, Regents of the University of California
*
- * $Id: transam.h,v 1.1.1.1 1996/07/09 06:21:09 scrappy Exp $
+ * $Id: transam.h,v 1.1.1.1.2.1 1996/08/24 20:52:17 scrappy Exp $
*
* NOTES
* Transaction System Version 101 now support proper oid
typedef unsigned char XidStatus; /* (2 bits) */
+/* ----------
+ * note: we reserve the first 16384 object ids for internal use.
+ * oid's less than this appear in the .bki files. the choice of
+ * 16384 is completely arbitrary.
+ * ----------
+ */
+#define BootstrapObjectIdData 16384
+
/* ----------------
* BitIndexOf computes the index of the Nth xid on a given block
* ----------------
extern void UpdateLastCommittedXid(TransactionId xid);
extern void GetNewObjectIdBlock(Oid *oid_return, int oid_block_size);
extern void GetNewObjectId(Oid *oid_return);
+extern void CheckMaxObjectId(Oid assigned_oid);
/* ----------------
* global variable extern declarations
*
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/backend/access/transam/varsup.c,v 1.1.1.1 1996/07/09 06:21:13 scrappy Exp $
+ * $Header: /cvsroot/pgsql/src/backend/access/transam/varsup.c,v 1.1.1.1.2.1 1996/08/24 20:53:26 scrappy Exp $
*
*-------------------------------------------------------------------------
*/
#include "catalog/catname.h"
-/* ----------
- * note: we reserve the first 16384 object ids for internal use.
- * oid's less than this appear in the .bki files. the choice of
- * 16384 is completely arbitrary.
- * ----------
- */
-#define BootstrapObjectIdData 16384
-
/* ---------------------
* spin lock for oid generation
* ---------------------
next_prefetched_oid++;
prefetched_oid_count--;
}
+
+void
+CheckMaxObjectId(Oid assigned_oid)
+{
+Oid pass_oid;
+
+
+ if (prefetched_oid_count == 0) /* make sure next/max is set, or reload */
+ GetNewObjectId(&pass_oid);
+
+ /* ----------------
+ * If we are below prefetched limits, do nothing
+ * ----------------
+ */
+
+ if (assigned_oid < next_prefetched_oid)
+ return;
+
+ /* ----------------
+ * If we are here, we are coming from a 'copy from' with oid's
+ *
+ * If we are in the prefetched oid range, just bump it up
+ *
+ * ----------------
+ */
+
+ if (assigned_oid <= next_prefetched_oid + prefetched_oid_count - 1)
+ {
+ prefetched_oid_count -= assigned_oid - next_prefetched_oid + 1;
+ next_prefetched_oid = assigned_oid + 1;
+ return;
+ }
+
+ /* ----------------
+ * We have exceeded the prefetch oid range
+ *
+ * We should lock the database and kill all other backends
+ * but we are loading oid's that we can not guarantee are unique
+ * anyway, so we must rely on the user
+ *
+ *
+ * We now:
+ * set the variable relation with the new max oid
+ * force the backend to reload its oid cache
+ *
+ * We use the oid cache so we don't have to update the variable
+ * relation every time
+ *
+ * ----------------
+ */
+
+ pass_oid = assigned_oid;
+ VariableRelationPutNextOid(&pass_oid); /* not modified */
+ prefetched_oid_count = 0; /* force reload */
+ pass_oid = assigned_oid;
+ GetNewObjectId(&pass_oid); /* throw away returned oid */
+
+}
+
*
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/backend/commands/copy.c,v 1.2 1996/07/23 02:23:15 scrappy Exp $
+ * $Header: /cvsroot/pgsql/src/backend/commands/copy.c,v 1.2.2.1 1996/08/24 20:53:39 scrappy Exp $
*
*-------------------------------------------------------------------------
*/
#include "catalog/pg_index.h"
#include "catalog/index.h"
+#include "storage/bufmgr.h"
#include "access/heapam.h"
#include "access/htup.h"
#include "access/itup.h"
#include "access/relscan.h"
#include "access/funcindex.h"
+#include "access/transam.h"
#include "access/tupdesc.h"
#include "nodes/execnodes.h"
#include "nodes/plannodes.h"
static bool reading_from_input = false;
/* non-export function prototypes */
-static void CopyTo(Relation rel, bool binary, FILE *fp, char *delim);
-static void CopyFrom(Relation rel, bool binary, FILE *fp, char *delim);
+static void CopyTo(Relation rel, bool binary, bool oids, FILE *fp, char *delim);
+static void CopyFrom(Relation rel, bool binary, bool oids, FILE *fp, char *delim);
static Oid GetOutputFunction(Oid type);
static Oid GetTypeElement(Oid type);
static Oid GetInputFunction(Oid type);
static void GetIndexRelations(Oid main_relation_oid,
int *n_indices,
Relation **index_rels);
-static char *CopyReadAttribute(int attno, FILE *fp, bool *isnull, char *delim);
+static char *CopyReadAttribute(FILE *fp, bool *isnull, char *delim);
static void CopyAttributeOut(FILE *fp, char *string, char *delim);
static int CountTuples(Relation relation);
extern FILE *Pfout, *Pfin;
void
-DoCopy(char *relname, bool binary, bool from, bool pipe, char *filename,
+DoCopy(char *relname, bool binary, bool oids, bool from, bool pipe, char *filename,
char *delim)
{
FILE *fp;
if (fp == NULL) {
elog(WARN, "COPY: file %s could not be open for reading", filename);
}
- CopyFrom(rel, binary, fp, delim);
+ CopyFrom(rel, binary, oids, fp, delim);
}else {
mode_t oumask = umask((mode_t) 0);
if (fp == NULL) {
elog(WARN, "COPY: file %s could not be open for writing", filename);
}
- CopyTo(rel, binary, fp, delim);
+ CopyTo(rel, binary, oids, fp, delim);
}
if (!pipe) {
fclose(fp);
}
static void
-CopyTo(Relation rel, bool binary, FILE *fp, char *delim)
+CopyTo(Relation rel, bool binary, bool oids, FILE *fp, char *delim)
{
HeapTuple tuple;
HeapScanDesc scandesc;
for (tuple = heap_getnext(scandesc, 0, NULL);
tuple != NULL;
tuple = heap_getnext(scandesc, 0, NULL)) {
+
+ if (oids && !binary) {
+ fputs(oidout(tuple->t_oid),fp);
+ fputc(delim[0], fp);
+ }
for (i = 0; i < attr_count; i++) {
value = (Datum)
length = tuple->t_len - tuple->t_hoff;
fwrite(&length, sizeof(int32), 1, fp);
+ if (oids)
+ fwrite((char *) &tuple->t_oid, sizeof(int32), 1, fp);
+
fwrite(&null_ct, sizeof(int32), 1, fp);
if (null_ct > 0) {
for (i = 0; i < attr_count; i++) {
}
static void
-CopyFrom(Relation rel, bool binary, FILE *fp, char *delim)
+CopyFrom(Relation rel, bool binary, bool oids, FILE *fp, char *delim)
{
HeapTuple tuple;
IndexTuple ituple;
int n_indices;
InsertIndexResult indexRes;
TupleDesc tupDesc;
-
+ Oid loaded_oid;
+
tupDesc = RelationGetTupleDescriptor(rel);
attr = tupDesc->attrs;
attr_count = tupDesc->natts;
while (!done) {
if (!binary) {
+ if (oids) {
+ string = CopyReadAttribute(fp, &isnull, delim);
+ if (string == NULL)
+ done = 1;
+ else {
+ loaded_oid = oidin(string);
+ if (loaded_oid < BootstrapObjectIdData)
+ elog(WARN, "COPY TEXT: Invalid Oid");
+ }
+ }
for (i = 0; i < attr_count && !done; i++) {
- string = CopyReadAttribute(i, fp, &isnull, delim);
+ string = CopyReadAttribute(fp, &isnull, delim);
if (isnull) {
values[i] = PointerGetDatum(NULL);
nulls[i] = 'n';
if (feof(fp)) {
done = 1;
}else {
+ if (oids) {
+ fread(&loaded_oid, sizeof(int32), 1, fp);
+ if (loaded_oid < BootstrapObjectIdData)
+ elog(WARN, "COPY BINARY: Invalid Oid");
+ }
fread(&null_ct, sizeof(int32), 1, fp);
if (null_ct > 0) {
for (i = 0; i < null_ct; i++) {
tupDesc = CreateTupleDesc(attr_count, attr);
tuple = heap_formtuple(tupDesc, values, nulls);
+ if (oids)
+ tuple->t_oid = loaded_oid;
heap_insert(rel, tuple);
if (has_index) {
*/
static char *
-CopyReadAttribute(int attno, FILE *fp, bool *isnull, char *delim)
+CopyReadAttribute(FILE *fp, bool *isnull, char *delim)
{
static char attribute[EXT_ATTLEN];
char c;
*
* Copyright (c) 1994, Regents of the University of California
*
- * $Id: copy.h,v 1.1.1.1 1996/07/09 06:21:19 scrappy Exp $
+ * $Id: copy.h,v 1.1.1.1.2.1 1996/08/24 20:53:43 scrappy Exp $
*
*-------------------------------------------------------------------------
*/
#include "postgres.h"
-void DoCopy(char *relname, bool binary, bool from, bool pipe, char *filename,
+void DoCopy(char *relname, bool binary, bool oids, bool from, bool pipe, char *filename,
char *delim);
#endif /* COPY_H */
*
* Copyright (c) 1994, Regents of the University of California
*
- * $Id: parsenodes.h,v 1.1.1.1 1996/07/09 06:21:33 scrappy Exp $
+ * $Id: parsenodes.h,v 1.1.1.1.2.1 1996/08/24 20:53:55 scrappy Exp $
*
*-------------------------------------------------------------------------
*/
NodeTag type;
bool binary; /* is a binary copy? */
char *relname; /* the relation to copy */
+ bool oids; /* copy oid's? */
int direction; /* TO or FROM */
char *filename; /* if NULL, use stdin/stdout */
char *delimiter; /* delimiter character, \t by default*/
*
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/backend/parser/gram.y,v 1.2 1996/07/23 02:23:33 scrappy Exp $
+ * $Header: /cvsroot/pgsql/src/backend/parser/gram.y,v 1.2.2.1 1996/08/24 20:54:06 scrappy Exp $
*
* HISTORY
* AUTHOR DATE MAJOR EVENT
%type <list> queryblock, relation_name_list, OptTableElementList,
tableElementList, OptInherit, definition,
- opt_with, def_args, def_name_list, func_argtypes, oper_argtypes,
+ opt_with_func, def_args, def_name_list, func_argtypes, oper_argtypes,
OptStmtList, OptStmtBlock, opt_column_list, columnList,
exprList, sort_clause, sortby_list, index_params,
name_list, from_clause, from_list, opt_array_bounds, nest_array_bounds,
expr_list, attrs, res_target_list, res_target_list2, def_list,
opt_indirection, group_clause, groupby_list, explain_options
-%type <boolean> opt_inh_star, opt_binary, opt_instead
+%type <boolean> opt_inh_star, opt_binary, opt_instead, opt_with_copy
%type <ival> copy_dirn, archive_type, OptArchiveType, OptArchiveLocation,
def_type, opt_direction, remove_type, opt_column, event
HAVING, HEAVY, IN, INDEX, INHERITS, INSERT, INSTEAD, INTO,
ISNULL, LANGUAGE, LIGHT, LISTEN, LOAD, MERGE, MOVE, NEW,
NONE, NOT, NOTHING, NOTIFY, NOTNULL,
- ON, OPERATOR, OPTION, OR, ORDER,
+ OIDS, ON, OPERATOR, OPTION, OR, ORDER,
PNULL, PRIVILEGES, PUBLIC, PURGE, P_TYPE,
RENAME, REPLACE, RETRIEVE, RETURNS, REVOKE, ROLLBACK, RULE,
SELECT, SET, SETOF, STDIN, STDOUT, STORE,
*
*****************************************************************************/
-CopyStmt: COPY opt_binary relation_name copy_dirn copy_file_name copy_delimiter
+CopyStmt: COPY opt_binary relation_name opt_with_copy copy_dirn copy_file_name copy_delimiter
{
CopyStmt *n = makeNode(CopyStmt);
n->binary = $2;
n->relname = $3;
- n->direction = $4;
- n->filename = $5;
- n->delimiter = $6;
+ n->oids = $4;
+ n->direction = $5;
+ n->filename = $6;
+ n->delimiter = $7;
$$ = (Node *)n;
}
;
| /*EMPTY*/ { $$ = FALSE; }
;
+opt_with_copy: WITH OIDS { $$ = TRUE; }
+ | /* EMPTY */ { $$ = FALSE; }
+ ;
+
/*
* the default copy delimiter is tab but the user can configure it
*/
*****************************************************************************/
ProcedureStmt: CREATE FUNCTION def_name def_args
- RETURNS def_arg opt_with AS Sconst LANGUAGE Sconst
+ RETURNS def_arg opt_with_func AS Sconst LANGUAGE Sconst
{
ProcedureStmt *n = makeNode(ProcedureStmt);
n->funcname = $3;
$$ = (Node *)n;
};
-opt_with: WITH definition { $$ = $2; }
+opt_with_func: WITH definition { $$ = $2; }
| /* EMPTY */ { $$ = NIL; }
;
*
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/backend/parser/keywords.c,v 1.1.1.1 1996/07/09 06:21:40 scrappy Exp $
+ * $Header: /cvsroot/pgsql/src/backend/parser/keywords.c,v 1.1.1.1.2.1 1996/08/24 20:54:11 scrappy Exp $
*
*-------------------------------------------------------------------------
*/
{ "notify", NOTIFY },
{ "notnull", NOTNULL },
{ "null", PNULL },
+ { "oids", OIDS },
{ "on", ON },
{ "operator", OPERATOR },
{ "option", OPTION },
*
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/backend/tcop/utility.c,v 1.1.1.1 1996/07/09 06:22:00 scrappy Exp $
+ * $Header: /cvsroot/pgsql/src/backend/tcop/utility.c,v 1.1.1.1.2.1 1996/08/24 20:54:23 scrappy Exp $
*
*-------------------------------------------------------------------------
*/
char *filename;
char *delim;
bool isBinary;
+ bool isOids;
bool isFrom;
bool pipe = false;
relname = stmt->relname;
isBinary = stmt->binary;
+ isOids = stmt->oids;
isFrom = (bool)(stmt->direction == FROM);
filename = stmt->filename;
if (pipe && IsUnderPostmaster) dest = CopyEnd;
- DoCopy(relname, isBinary, isFrom, pipe, filename, delim);
+ DoCopy(relname, isBinary, isOids, isFrom, pipe, filename, delim);
}
break;
*
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/bin/pg_dump/common.c,v 1.3 1996/07/22 08:36:59 scrappy Exp $
+ * $Header: /cvsroot/pgsql/src/bin/pg_dump/common.c,v 1.3.2.1 1996/08/24 20:54:38 scrappy Exp $
*
* Modifications - 6/12/96 - dave@bensoft.com - version 1.13.dhb.2
*
int numFuncs;
int numTables;
int numInherits;
- int numIndices;
int numAggregates;
int numOperators;
TypeInfo *tinfo;
AggInfo *agginfo;
TableInfo *tblinfo;
InhInfo *inhinfo;
- IndInfo *indinfo;
OprInfo *oprinfo;
if (g_verbose) fprintf(stderr,"%s reading user-defined types %s\n",
g_comment_start, g_comment_end);
flagInhAttrs(tblinfo, numTables, inhinfo, numInherits);
-if (g_verbose) fprintf(stderr,"%s reading indices information %s\n",
- g_comment_start, g_comment_end);
- indinfo = getIndices(&numIndices);
-
if (!tablename && fout) {
if (g_verbose) fprintf(stderr,"%s dumping out user-defined types %s\n",
g_comment_start, g_comment_end);
dumpOprs(fout, oprinfo, numOperators, tinfo, numTypes);
}
-if (fout) {
- if (g_verbose) fprintf(stderr,"%s dumping out indices %s\n",
- g_comment_start, g_comment_end);
- dumpIndices(fout, indinfo, numIndices, tblinfo, numTables, tablename);
-}
*numTablesPtr = numTables;
return tblinfo;
}
+/*
+ * dumpSchemaIdx:
+ * dump indexes at the end for performance
+ *
+ */
+
+extern void
+dumpSchemaIdx(FILE *fout, int *numTablesPtr, char *tablename,
+ TableInfo* tblinfo, int numTables)
+{
+ int numIndices;
+ IndInfo *indinfo;
+
+ if (g_verbose) fprintf(stderr,"%s reading indices information %s\n",
+ g_comment_start, g_comment_end);
+ indinfo = getIndices(&numIndices);
+
+ if (fout) {
+ if (g_verbose) fprintf(stderr,"%s dumping out indices %s\n",
+ g_comment_start, g_comment_end);
+ dumpIndices(fout, indinfo, numIndices, tblinfo, numTables, tablename);
+ }
+}
+
/* flagInhAttrs -
* for each table in tblinfo, flag its inherited attributes
* so when we dump the table out, we don't dump out the inherited attributes
*
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/bin/pg_dump/pg_dump.c,v 1.5 1996/07/31 06:09:46 scrappy Exp $
+ * $Header: /cvsroot/pgsql/src/bin/pg_dump/pg_dump.c,v 1.5.2.1 1996/08/24 20:54:40 scrappy Exp $
*
* Modifications - 6/10/96 - dave@bensoft.com - version 1.13.dhb
*
fprintf(stderr, "%s - version 1.13.dhb.2\n\n",progname);
fprintf(stderr, "usage: %s [options] [dbname]\n",progname);
fprintf(stderr, "\t -f filename \t\t script output filename\n");
- fprintf(stderr, "\t -d[a] \t\t dump data as proper insert strings\n");
- fprintf(stderr, "\t \t\t (if 'a' then attribute names also)\n");
fprintf(stderr, "\t -H hostname \t\t server host name\n");
fprintf(stderr, "\t -p port \t\t server port number\n");
fprintf(stderr, "\t -v \t\t verbose\n");
+ fprintf(stderr, "\t -d[a] \t\t dump data as proper insert strings\n");
+ fprintf(stderr, "\t \t\t (if 'a' then attribute names also)\n");
fprintf(stderr, "\t -S \t\t dump out only the schema, no data\n");
fprintf(stderr, "\t -a \t\t dump out only the data, no schema\n");
fprintf(stderr, "\t -t table \t\t dump for this table only\n");
+ fprintf(stderr, "\t -o \t\t dump object id's (oids)\n");
fprintf(stderr, "\n if dbname is not supplied, then the DATABASE environment name is used\n");
fprintf(stderr, "\n");
char *pghost = NULL;
char *pgport = NULL;
char *tablename;
-
+ int oids;
TableInfo *tblinfo;
int numTables;
filename = NULL;
tablename = NULL;
g_verbose = 0;
-
+ oids = 0;
+
strcpy(g_comment_start,"-- ");
g_comment_end[0] = '\0';
strcpy(g_opaque_type, "opaque");
progname = *argv;
- while ((c = getopt(argc, argv,"f:H:p:t:vSDd:a")) != EOF) {
+ while ((c = getopt(argc, argv,"f:H:p:t:vSDd:ao")) != EOF) {
switch(c) {
case 'f': /* output file name */
filename = optarg;
case 'a': /* Dump data only */
dataOnly = 1;
break;
+ case 'o': /* Dump oids */
+ oids = 1;
+ break;
default:
usage(progname);
break;
g_last_builtin_oid = findLastBuiltinOid();
+ if (oids)
+ setMaxOid(g_fout);
if (!dataOnly) {
-
-if (g_verbose)
- fprintf(stderr, "%s last builtin oid is %d %s\n",
- g_comment_start, g_last_builtin_oid, g_comment_end);
-
- tblinfo = dumpSchema(g_fout, &numTables, tablename);
-
+ if (g_verbose)
+ fprintf(stderr, "%s last builtin oid is %d %s\n",
+ g_comment_start, g_last_builtin_oid, g_comment_end);
+ tblinfo = dumpSchema(g_fout, &numTables, tablename);
}
- else {
+ else
tblinfo = dumpSchema(NULL, &numTables, tablename);
- }
if (!schemaOnly) {
-
-if (g_verbose) fprintf(stderr,"%s dumping out the contents of each table %s\n",
+ if (g_verbose)
+ fprintf(stderr,"%s dumping out the contents of each table %s\n",
g_comment_start, g_comment_end);
-
- dumpClasses(tblinfo, numTables, g_fout, tablename);
+ dumpClasses(tblinfo, numTables, g_fout, tablename, oids);
}
+ if (!dataOnly) /* dump indexes at the end for performance */
+ dumpSchemaIdx(g_fout, &numTables, tablename, tblinfo, numTables);
+
fflush(g_fout);
fclose(g_fout);
/* we must read the attribute names in attribute number order! */
/* because we will use the attnum to index into the attnames array
later */
-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);
+ 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,"SELECT a.attnum, a.attname, t.typname, a.attlen from pg_attribute a, pg_type t where a.attrelid = '%s'::oid and a.atttypid = t.oid and a.attnum > 0 order by attnum",tblinfo[i].oid);
res = PQexec(g_conn, q);
* dump the contents of all the classes.
*/
void
-dumpClasses(TableInfo *tblinfo, int numTables, FILE *fout, char *onlytable)
+dumpClasses(TableInfo *tblinfo, int numTables, FILE *fout, char *onlytable, int oids)
{
char query[255];
#define COPYBUFSIZ 8192
int field;
int tuple;
int copydone;
-
+
for(i = 0; i < numTables; i++) {
char *classname = tblinfo[i].relname;
continue;
if(!dumpData) {
- fprintf(fout, "COPY %s from stdin;\n", classname);
- sprintf(query, "COPY %s to stdout;\n", classname);
+ if (oids) {
+ fprintf(fout, "COPY %s WITH OIDS FROM stdin;\n", classname);
+ sprintf(query, "COPY %s WITH OIDS TO stdout;\n", classname);
+ }
+ else {
+ fprintf(fout, "COPY %s FROM stdin;\n", classname);
+ sprintf(query, "COPY %s TO stdout;\n", classname);
+ }
res = PQexec(g_conn, query);
if (!res ||
PQresultStatus(res) != PGRES_COPY_OUT) {
}
}
+/*
+ * setMaxOid -
+ * find the maximum oid and generate a COPY statement to set it
+*/
+void
+setMaxOid(FILE *fout)
+{
+ char query[255];
+ PGresult *res;
+ Oid max_oid;
+
+ res = PQexec(g_conn, "CREATE TABLE pgdump_oid (dummy int4)");
+ if (!res ||
+ PQresultStatus(res) != PGRES_COMMAND_OK) {
+ fprintf(stderr,"Can not create pgdump_oid table\n");
+ exit_nicely(g_conn);
+ }
+ PQclear(res);
+ res = PQexec(g_conn, "INSERT INTO pgdump_oid VALUES (0)");
+ if (!res ||
+ PQresultStatus(res) != PGRES_COMMAND_OK) {
+ fprintf(stderr,"Can not insert into pgdump_oid table\n");
+ exit_nicely(g_conn);
+ }
+ max_oid = atol(PQoidStatus(res));
+ if (max_oid == 0) {
+ fprintf(stderr,"Invalid max id in setMaxOid\n");
+ exit_nicely(g_conn);
+ }
+ PQclear(res);
+ res = PQexec(g_conn, "DROP TABLE pgdump_oid;");
+ if (!res ||
+ PQresultStatus(res) != PGRES_COMMAND_OK) {
+ fprintf(stderr,"Can not drop pgdump_oid table\n");
+ exit_nicely(g_conn);
+ }
+ PQclear(res);
+ if (g_verbose)
+ fprintf(stderr, "%s maximum system oid is %d %s\n",
+ g_comment_start, max_oid, g_comment_end);
+ fprintf(fout, "CREATE TABLE pgdump_oid (dummy int4);\n");
+ fprintf(fout, "COPY pgdump_oid WITH OIDS FROM stdin;\n");
+ fprintf(fout, "%-ld\t0\n", max_oid);
+ fprintf(fout, "\\.\n");
+ fprintf(fout, "DROP TABLE pgdump_oid;\n");
+}
/*
* findLastBuiltInOid -
*
* Copyright (c) 1994, Regents of the University of California
*
- * $Id: pg_dump.h,v 1.3 1996/07/22 08:37:00 scrappy Exp $
+ * $Id: pg_dump.h,v 1.3.2.1 1996/08/24 20:54:43 scrappy Exp $
*
* Modifications - 6/12/96 - dave@bensoft.com - version 1.13.dhb.2
*
*/
extern TableInfo* dumpSchema(FILE* fout, int *numTablesPtr, char *tablename);
+extern void dumpSchemaIdx(FILE* fout, int *numTablesPtr, char *tablename,
+ TableInfo* tblinfo, int numTables);
extern char* findTypeByOid(TypeInfo* tinfo, int numTypes, char* oid);
extern char* findOprByOid(OprInfo *oprinfo, int numOprs, char *oid);
*
* Copyright (c) 1994, Regents of the University of California
*
- * $Id: psqlHelp.h,v 1.2 1996/07/28 07:08:14 scrappy Exp $
+ * $Id: psqlHelp.h,v 1.2.2.1 1996/08/24 20:54:52 scrappy Exp $
*
*-------------------------------------------------------------------------
*/
"commit [work]"},
{ "copy",
"copy data to and from a table",
- "copy [binary] [nonulls] <relname>\n\t{to|from} {<filename>|stdin|stdout} [using delimiters <delim>];"},
+ "copy [binary] <relname> [with oids]\n\t{to|from} {<filename>|stdin|stdout} [using delimiters <delim>];"},
{ "create",
"Please more be specific:",
"\tcreate aggregate\n\tcreate database\n\tcreate function\n\tcreate index\n\tcreate operator\n\tcreate rule\n\tcreate table\n\tcreate type\n\tcreate view"},
"create function <function_name> ([<type1>,...<typeN>]) returns <return_type>\n\tas '<object_filename>'|'<sql-queries>'\n\tlanguage 'c'|'sql'|'internal';"},
{ "create index",
"construct an index",
- "create index <indexname> on <relname> using <access_method> (<attr1>|<funcname>(<attr1>,...) <type_class1>);"},
+ "create index <indexname> on <relname> [using <access_method>] (<attr1>|<funcname>(<attr1>,...) [<type_class1>]);"},
{ "create operator",
"create a user-defined operator",
"create operator <operator_name> (\n\t[leftarg = <type1>][,rightarg = <type2>]\n\t,procedure = <func_name>,\n\t[,commutator = <com_op>][,negator = <neg_op>]\n\t[,restrict = <res_proc>][,hashes]\n\t[,join = <join_proc>][,sort = <sort_op1>...<sort_opN>]);"},