summaryrefslogtreecommitdiff
path: root/src/bin
diff options
context:
space:
mode:
Diffstat (limited to 'src/bin')
-rw-r--r--src/bin/pg_dump/common.c82
-rw-r--r--src/bin/pg_dump/pg_dump.c682
-rw-r--r--src/bin/pg_dump/pg_dump.h227
-rw-r--r--src/bin/pg_id/pg_id.c16
-rw-r--r--src/bin/pg_passwd/pg_passwd.c106
-rw-r--r--src/bin/pg_version/pg_version.c6
-rw-r--r--src/bin/pgtclsh/pgtclAppInit.c4
-rw-r--r--src/bin/pgtclsh/pgtkAppInit.c4
-rw-r--r--src/bin/psql/psql.c1149
-rw-r--r--src/bin/psql/psqlHelp.h8
-rw-r--r--src/bin/psql/stringutils.c22
-rw-r--r--src/bin/psql/stringutils.h6
12 files changed, 1153 insertions, 1159 deletions
diff --git a/src/bin/pg_dump/common.c b/src/bin/pg_dump/common.c
index c8d3c755b6..61d0879e31 100644
--- a/src/bin/pg_dump/common.c
+++ b/src/bin/pg_dump/common.c
@@ -7,7 +7,7 @@
*
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/bin/pg_dump/common.c,v 1.14 1997/09/07 04:54:28 momjian Exp $
+ * $Header: /cvsroot/pgsql/src/bin/pg_dump/common.c,v 1.15 1997/09/08 02:32:37 momjian Exp $
*
* Modifications - 6/12/96 - dave@bensoft.com - version 1.13.dhb.2
*
@@ -35,16 +35,16 @@
#include "pg_dump.h"
-static char **
+static char **
findParentsByOid(TableInfo * tbinfo, int numTables,
InhInfo * inhinfo, int numInherits,
const char *oid,
int *numParents);
-static int findTableByOid(TableInfo * tbinfo, int numTables, const char *oid);
+static int findTableByOid(TableInfo * tbinfo, int numTables, const char *oid);
static void
flagInhAttrs(TableInfo * tbinfo, int numTables,
InhInfo * inhinfo, int numInherits);
-static int strInArray(const char *pattern, char **arr, int arr_size);
+static int strInArray(const char *pattern, char **arr, int arr_size);
/*
* findTypeByOid
@@ -55,10 +55,10 @@ static int strInArray(const char *pattern, char **arr, int arr_size);
* NOTE: should hash this, but just do linear search for now
*/
-char *
+char *
findTypeByOid(TypeInfo * tinfo, int numTypes, const char *oid)
{
- int i;
+ int i;
if (strcmp(oid, "0") == 0)
return g_opaque_type;
@@ -83,10 +83,10 @@ findTypeByOid(TypeInfo * tinfo, int numTypes, const char *oid)
* NOTE: should hash this, but just do linear search for now
*
*/
-char *
+char *
findOprByOid(OprInfo * oprinfo, int numOprs, const char *oid)
{
- int i;
+ int i;
for (i = 0; i < numOprs; i++)
{
@@ -110,16 +110,16 @@ findOprByOid(OprInfo * oprinfo, int numOprs, const char *oid)
* returns NULL if none
*/
-static char **
+static char **
findParentsByOid(TableInfo * tblinfo, int numTables,
InhInfo * inhinfo, int numInherits, const char *oid,
int *numParentsPtr)
{
- int i,
- j;
- int parentInd;
- char **result;
- int numParents;
+ int i,
+ j;
+ int parentInd;
+ char **result;
+ int numParents;
numParents = 0;
for (i = 0; i < numInherits; i++)
@@ -160,10 +160,10 @@ findParentsByOid(TableInfo * tblinfo, int numTables,
void
parseArgTypes(char **argtypes, const char *str)
{
- int j,
- argNum;
- char temp[100];
- char s;
+ int j,
+ argNum;
+ char temp[100];
+ char s;
argNum = 0;
j = 0;
@@ -203,7 +203,7 @@ parseArgTypes(char **argtypes, const char *str)
static int
strInArray(const char *pattern, char **arr, int arr_size)
{
- int i;
+ int i;
for (i = 0; i < arr_size; i++)
{
@@ -220,24 +220,24 @@ strInArray(const char *pattern, char **arr, int arr_size)
*
*/
-TableInfo *
+TableInfo *
dumpSchema(FILE * fout,
int *numTablesPtr,
const char *tablename,
const bool acls)
{
- int numTypes;
- int numFuncs;
- int numTables;
- int numInherits;
- int numAggregates;
- int numOperators;
- TypeInfo *tinfo = NULL;
- FuncInfo *finfo = NULL;
- AggInfo *agginfo = NULL;
- TableInfo *tblinfo = NULL;
- InhInfo *inhinfo = NULL;
- OprInfo *oprinfo = NULL;
+ int numTypes;
+ int numFuncs;
+ int numTables;
+ int numInherits;
+ int numAggregates;
+ int numOperators;
+ TypeInfo *tinfo = NULL;
+ FuncInfo *finfo = NULL;
+ AggInfo *agginfo = NULL;
+ TableInfo *tblinfo = NULL;
+ InhInfo *inhinfo = NULL;
+ OprInfo *oprinfo = NULL;
if (g_verbose)
fprintf(stderr, "%s reading user-defined types %s\n",
@@ -339,8 +339,8 @@ extern void
dumpSchemaIdx(FILE * fout, int *numTablesPtr, const char *tablename,
TableInfo * tblinfo, int numTables)
{
- int numIndices;
- IndInfo *indinfo;
+ int numIndices;
+ IndInfo *indinfo;
if (g_verbose)
fprintf(stderr, "%s reading indices information %s\n",
@@ -370,10 +370,10 @@ static void
flagInhAttrs(TableInfo * tblinfo, int numTables,
InhInfo * inhinfo, int numInherits)
{
- int i,
- j,
- k;
- int parentInd;
+ int i,
+ j,
+ k;
+ int parentInd;
/*
* we go backwards because the tables in tblinfo are in OID order,
@@ -415,7 +415,7 @@ flagInhAttrs(TableInfo * tblinfo, int numTables,
int
findTableByName(TableInfo * tblinfo, int numTables, const char *relname)
{
- int i;
+ int i;
for (i = 0; i < numTables; i++)
{
@@ -436,7 +436,7 @@ findTableByName(TableInfo * tblinfo, int numTables, const char *relname)
static int
findTableByOid(TableInfo * tblinfo, int numTables, const char *oid)
{
- int i;
+ int i;
for (i = 0; i < numTables; i++)
{
@@ -458,7 +458,7 @@ findTableByOid(TableInfo * tblinfo, int numTables, const char *oid)
int
findFuncByName(FuncInfo * finfo, int numFuncs, const char *name)
{
- int i;
+ int i;
for (i = 0; i < numFuncs; i++)
{
diff --git a/src/bin/pg_dump/pg_dump.c b/src/bin/pg_dump/pg_dump.c
index 8192d5c30b..7409b62873 100644
--- a/src/bin/pg_dump/pg_dump.c
+++ b/src/bin/pg_dump/pg_dump.c
@@ -21,7 +21,7 @@
*
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/bin/pg_dump/pg_dump.c,v 1.41 1997/09/07 04:54:38 momjian Exp $
+ * $Header: /cvsroot/pgsql/src/bin/pg_dump/pg_dump.c,v 1.42 1997/09/08 02:32:45 momjian Exp $
*
* Modifications - 6/10/96 - dave@bensoft.com - version 1.13.dhb
*
@@ -67,36 +67,36 @@
#include "pg_dump.h"
-static void dumpSequence(FILE * fout, TableInfo tbinfo);
-static char *checkForQuote(const char *s);
-static void clearTableInfo(TableInfo *, int);
+static void dumpSequence(FILE * fout, TableInfo tbinfo);
+static char *checkForQuote(const char *s);
+static void clearTableInfo(TableInfo *, int);
static void
dumpOneFunc(FILE * fout, FuncInfo * finfo, int i,
TypeInfo * tinfo, int numTypes);
-static int findLastBuiltinOid(void);
-static bool isViewRule(char *relname);
-static void setMaxOid(FILE * fout);
+static int findLastBuiltinOid(void);
+static bool isViewRule(char *relname);
+static void setMaxOid(FILE * fout);
-extern char *optarg;
-extern int optind,
- opterr;
+extern char *optarg;
+extern int optind,
+ opterr;
/* global decls */
-bool g_verbose; /* User wants verbose narration of our
+bool g_verbose; /* User wants verbose narration of our
* activities. */
-int g_last_builtin_oid; /* value of the last builtin oid */
-FILE *g_fout; /* the script file */
-PGconn *g_conn; /* the database connection */
-int dumpData; /* dump data using proper insert strings */
-int attrNames; /* put attr names into insert strings */
-int schemaOnly;
-int dataOnly;
+int g_last_builtin_oid; /* value of the last builtin oid */
+FILE *g_fout; /* the script file */
+PGconn *g_conn; /* the database connection */
+int dumpData; /* dump data using proper insert strings */
+int attrNames; /* put attr names into insert strings */
+int schemaOnly;
+int dataOnly;
-char g_opaque_type[10]; /* name for the opaque type */
+char g_opaque_type[10]; /* name for the opaque type */
/* placeholders for the delimiters for comments */
-char g_comment_start[10];
-char g_comment_end[10];
+char g_comment_start[10];
+char g_comment_end[10];
static void
@@ -149,12 +149,12 @@ exit_nicely(PGconn * conn)
* Determine if the relation is a VIEW
*
*/
-static bool
+static bool
isViewRule(char *relname)
{
- PGresult *res;
- int ntups;
- char query[MAXQUERYLEN];
+ PGresult *res;
+ int ntups;
+ char query[MAXQUERYLEN];
res = PQexec(g_conn, "begin");
if (!res ||
@@ -192,11 +192,11 @@ static void
dumpClasses_nodumpData(FILE * fout, const char *classname, const bool oids)
{
- PGresult *res;
- char query[255];
- int ret;
- bool copydone;
- char copybuf[COPYBUFSIZ];
+ PGresult *res;
+ char query[255];
+ int ret;
+ bool copydone;
+ char copybuf[COPYBUFSIZ];
if (oids)
{
@@ -248,14 +248,14 @@ dumpClasses_nodumpData(FILE * fout, const char *classname, const bool oids)
fputs(copybuf, fout);
switch (ret)
{
- case EOF:
- copydone = true;
- /* FALLTHROUGH */
- case 0:
- fputc('\n', fout);
- break;
- case 1:
- break;
+ case EOF:
+ copydone = true;
+ /* FALLTHROUGH */
+ case 0:
+ fputc('\n', fout);
+ break;
+ case 1:
+ break;
}
}
}
@@ -286,13 +286,13 @@ dumpClasses_dumpData(FILE * fout, const char *classname,
const TableInfo tblinfo, bool oids)
{
- PGresult *res;
- char query[255];
- int actual_atts;/* number of attrs in this a table */
- char expandbuf[COPYBUFSIZ];
- char q[MAXQUERYLEN];
- int tuple;
- int field;
+ PGresult *res;
+ char query[255];
+ int actual_atts; /* number of attrs in this a table */
+ char expandbuf[COPYBUFSIZ];
+ char q[MAXQUERYLEN];
+ int tuple;
+ int field;
sprintf(query, "select * from %s", classname);
res = PQexec(g_conn, query);
@@ -308,7 +308,7 @@ dumpClasses_dumpData(FILE * fout, const char *classname,
fprintf(fout, "insert into %s ", classname);
if (attrNames)
{
- int j;
+ int j;
actual_atts = 0;
sprintf(q, "(");
@@ -338,38 +338,38 @@ dumpClasses_dumpData(FILE * fout, const char *classname,
{
switch (PQftype(res, field))
{
- case INT2OID:
- case INT4OID:
- case OIDOID: /* int types */
- case FLOAT4OID:
- case FLOAT8OID:/* float types */
- fprintf(fout, "%s",
- PQgetvalue(res, tuple, field));
- break;
- default:
- {
- char *expsrc,
+ case INT2OID:
+ case INT4OID:
+ case OIDOID: /* int types */
+ case FLOAT4OID:
+ case FLOAT8OID: /* float types */
+ fprintf(fout, "%s",
+ PQgetvalue(res, tuple, field));
+ break;
+ default:
+ {
+ char *expsrc,
*expdest;
- /*
- * Before outputting string value, expand all
- * single quotes to twin single quotes - dhb -
- * 6/11/96
- */
- expsrc = PQgetvalue(res, tuple, field);
- expdest = expandbuf;
- while (*expsrc)
- {
- *expdest++ = *expsrc;
- if (*expsrc == (char) 0x27) /* single quote */
+ /*
+ * Before outputting string value, expand all
+ * single quotes to twin single quotes - dhb -
+ * 6/11/96
+ */
+ expsrc = PQgetvalue(res, tuple, field);
+ expdest = expandbuf;
+ while (*expsrc)
+ {
*expdest++ = *expsrc;
- expsrc++;
- }
- *expdest = *expsrc; /* null term. */
+ if (*expsrc == (char) 0x27) /* single quote */
+ *expdest++ = *expsrc;
+ expsrc++;
+ }
+ *expdest = *expsrc; /* null term. */
- fprintf(fout, "'%s'", expandbuf);
- }
- break;
+ fprintf(fout, "'%s'", expandbuf);
+ }
+ break;
}
}
field++;
@@ -393,8 +393,8 @@ dumpClasses(const TableInfo tblinfo[], const int numTables, FILE * fout,
const char *onlytable, const bool oids)
{
- int i;
- char *all_only;
+ int i;
+ char *all_only;
if (onlytable == NULL)
all_only = "all";
@@ -407,7 +407,7 @@ dumpClasses(const TableInfo tblinfo[], const int numTables, FILE * fout,
for (i = 0; i < numTables; i++)
{
- const char *classname = tblinfo[i].relname;
+ const char *classname = tblinfo[i].relname;
/* Skip VIEW relations */
if (isViewRule(tblinfo[i].relname))
@@ -451,17 +451,17 @@ dumpClasses(const TableInfo tblinfo[], const int numTables, FILE * fout,
int
main(int argc, char **argv)
{
- int c;
- const char *progname;
- const char *filename = NULL;
- const char *dbname = NULL;
- const char *pghost = NULL;
- const char *pgport = NULL;
- const char *tablename = NULL;
- int oids = 0,
- acls = 0;
- TableInfo *tblinfo;
- int numTables;
+ int c;
+ const char *progname;
+ const char *filename = NULL;
+ const char *dbname = NULL;
+ const char *pghost = NULL;
+ const char *pgport = NULL;
+ const char *tablename = NULL;
+ int oids = 0,
+ acls = 0;
+ TableInfo *tblinfo;
+ int numTables;
g_verbose = false;
@@ -477,44 +477,44 @@ main(int argc, char **argv)
{
switch (c)
{
- case 'f': /* output file name */
- filename = optarg;
- break;
- case 'H': /* server host */
- pghost = optarg;
- break;
- case 'p': /* server port */
- pgport = optarg;
- break;
- case 'v': /* verbose */
- g_verbose = true;
- break;
- case 'S': /* dump schema only */
- schemaOnly = 1;
- break;
- case 'd': /* dump data as proper insert strings */
- dumpData = 1;
- break;
- case 'D': /* dump data as proper insert strings with
+ case 'f': /* output file name */
+ filename = optarg;
+ break;
+ case 'H': /* server host */
+ pghost = optarg;
+ break;
+ case 'p': /* server port */
+ pgport = optarg;
+ break;
+ case 'v': /* verbose */
+ g_verbose = true;
+ break;
+ case 'S': /* dump schema only */
+ schemaOnly = 1;
+ break;
+ case 'd': /* dump data as proper insert strings */
+ dumpData = 1;
+ break;
+ case 'D': /* dump data as proper insert strings with
* attr names */
- dumpData = 1;
- attrNames = 1;
- break;
- case 't': /* Dump data for this table only */
- tablename = optarg;
- break;
- case 'a': /* Dump data only */
- dataOnly = 1;
- break;
- case 'o': /* Dump oids */
- oids = 1;
- break;
- case 'z': /* Dump oids */
- acls = 1;
- break;
- default:
- usage(progname);
- break;
+ dumpData = 1;
+ attrNames = 1;
+ break;
+ case 't': /* Dump data for this table only */
+ tablename = optarg;
+ break;
+ case 'a': /* Dump data only */
+ dataOnly = 1;
+ break;
+ case 'o': /* Dump oids */
+ oids = 1;
+ break;
+ case 'z': /* Dump oids */
+ acls = 1;
+ break;
+ default:
+ usage(progname);
+ break;
}
}
@@ -589,30 +589,30 @@ main(int argc, char **argv)
* numTypes is set to the number of types read in
*
*/
-TypeInfo *
+TypeInfo *
getTypes(int *numTypes)
{
- PGresult *res;
- int ntups;
- int i;
- char query[MAXQUERYLEN];
- TypeInfo *tinfo;
-
- int i_oid;
- int i_typowner;
- int i_typname;
- int i_typlen;
- int i_typprtlen;
- int i_typinput;
- int i_typoutput;
- int i_typreceive;
- int i_typsend;
- int i_typelem;
- int i_typdelim;
- int i_typdefault;
- int i_typrelid;
- int i_typbyval;
- int i_usename;
+ PGresult *res;
+ int ntups;
+ int i;
+ char query[MAXQUERYLEN];
+ TypeInfo *tinfo;
+
+ int i_oid;
+ int i_typowner;
+ int i_typname;
+ int i_typlen;
+ int i_typprtlen;
+ int i_typinput;
+ int i_typoutput;
+ int i_typreceive;
+ int i_typsend;
+ int i_typelem;
+ int i_typdelim;
+ int i_typdefault;
+ int i_typrelid;
+ int i_typbyval;
+ int i_usename;
res = PQexec(g_conn, "begin");
if (!res ||
@@ -718,30 +718,30 @@ getTypes(int *numTypes)
*
*
*/
-OprInfo *
+OprInfo *
getOperators(int *numOprs)
{
- PGresult *res;
- int ntups;
- int i;
- char query[MAXQUERYLEN];
-
- OprInfo *oprinfo;
-
- int i_oid;
- int i_oprname;
- int i_oprkind;
- int i_oprcode;
- int i_oprleft;
- int i_oprright;
- int i_oprcom;
- int i_oprnegate;
- int i_oprrest;
- int i_oprjoin;
- int i_oprcanhash;
- int i_oprlsortop;
- int i_oprrsortop;
- int i_usename;
+ PGresult *res;
+ int ntups;
+ int i;
+ char query[MAXQUERYLEN];
+
+ OprInfo *oprinfo;
+
+ int i_oid;
+ int i_oprname;
+ int i_oprkind;
+ int i_oprcode;
+ int i_oprleft;
+ int i_oprright;
+ int i_oprcom;
+ int i_oprnegate;
+ int i_oprrest;
+ int i_oprjoin;
+ int i_oprcanhash;
+ int i_oprlsortop;
+ int i_oprrsortop;
+ int i_usename;
/*
* find all operators, including builtin operators, filter out
@@ -818,7 +818,7 @@ getOperators(int *numOprs)
void
clearTypeInfo(TypeInfo * tp, int numTypes)
{
- int i;
+ int i;
for (i = 0; i < numTypes; ++i)
{
@@ -857,8 +857,8 @@ clearTypeInfo(TypeInfo * tp, int numTypes)
void
clearFuncInfo(FuncInfo * fun, int numFuncs)
{
- int i,
- a;
+ int i,
+ a;
if (!fun)
return;
@@ -886,8 +886,8 @@ clearFuncInfo(FuncInfo * fun, int numFuncs)
static void
clearTableInfo(TableInfo * tblinfo, int numTables)
{
- int i,
- j;
+ int i,
+ j;
for (i = 0; i < numTables; ++i)
{
@@ -940,7 +940,7 @@ clearTableInfo(TableInfo * tblinfo, int numTables)
void
clearInhInfo(InhInfo * inh, int numInherits)
{
- int i;
+ int i;
if (!inh)
return;
@@ -957,7 +957,7 @@ clearInhInfo(InhInfo * inh, int numInherits)
void
clearOprInfo(OprInfo * opr, int numOprs)
{
- int i;
+ int i;
if (!opr)
return;
@@ -998,8 +998,8 @@ clearOprInfo(OprInfo * opr, int numOprs)
void
clearIndInfo(IndInfo * ind, int numIndices)
{
- int i,
- a;
+ int i,
+ a;
if (!ind)
return;
@@ -1029,7 +1029,7 @@ clearIndInfo(IndInfo * ind, int numIndices)
void
clearAggInfo(AggInfo * agginfo, int numArgs)
{
- int i;
+ int i;
if (!agginfo)
return;
@@ -1070,26 +1070,26 @@ clearAggInfo(AggInfo * agginfo, int numArgs)
*
*
*/
-AggInfo *
+AggInfo *
getAggregates(int *numAggs)
{
- PGresult *res;
- int ntups;
- int i;
- char query[MAXQUERYLEN];
- AggInfo *agginfo;
-
- int i_oid;
- int i_aggname;
- int i_aggtransfn1;
- int i_aggtransfn2;
- int i_aggfinalfn;
- int i_aggtranstype1;
- int i_aggbasetype;
- int i_aggtranstype2;
- int i_agginitval1;
- int i_agginitval2;
- int i_usename;
+ PGresult *res;
+ int ntups;
+ int i;
+ char query[MAXQUERYLEN];
+ AggInfo *agginfo;
+
+ int i_oid;
+ int i_aggname;
+ int i_aggtransfn1;
+ int i_aggtransfn2;
+ int i_aggfinalfn;
+ int i_aggtranstype1;
+ int i_aggbasetype;
+ int i_aggtranstype2;
+ int i_agginitval1;
+ int i_agginitval2;
+ int i_usename;
/* find all user-defined aggregates */
@@ -1164,25 +1164,25 @@ getAggregates(int *numAggs)
*
*
*/
-FuncInfo *
+FuncInfo *
getFuncs(int *numFuncs)
{
- PGresult *res;
- int ntups;
- int i;
- char query[MAXQUERYLEN];
- FuncInfo *finfo;
-
- int i_oid;
- int i_proname;
- int i_prolang;
- int i_pronargs;
- int i_proargtypes;
- int i_prorettype;
- int i_proretset;
- int i_prosrc;
- int i_probin;
- int i_usename;
+ PGresult *res;
+ int ntups;
+ int i;
+ char query[MAXQUERYLEN];
+ FuncInfo *finfo;
+
+ int i_oid;
+ int i_proname;
+ int i_prolang;
+ int i_pronargs;
+ int i_proargtypes;
+ int i_prorettype;
+ int i_proretset;
+ int i_prosrc;
+ int i_probin;
+ int i_usename;
/* find all user-defined funcs */
@@ -1264,21 +1264,21 @@ getFuncs(int *numFuncs)
*
*
*/
-TableInfo *
+TableInfo *
getTables(int *numTables)
{
- PGresult *res;
- int ntups;
- int i;
- char query[MAXQUERYLEN];
- TableInfo *tblinfo;
-
- int i_oid;
- int i_relname;
- int i_relarch;
- int i_relkind;
- int i_relacl;
- int i_usename;
+ PGresult *res;
+ int ntups;
+ int i;
+ char query[MAXQUERYLEN];
+ TableInfo *tblinfo;
+
+ int i_oid;
+ int i_relname;
+ int i_relarch;
+ int i_relkind;
+ int i_relacl;
+ int i_usename;
/*
* find all the user-defined tables (no indices and no catalogs),
@@ -1352,17 +1352,17 @@ getTables(int *numTables)
*
*
*/
-InhInfo *
+InhInfo *
getInherits(int *numInherits)
{
- PGresult *res;
- int ntups;
- int i;
- char query[MAXQUERYLEN];
- InhInfo *inhinfo;
+ PGresult *res;
+ int ntups;
+ int i;
+ char query[MAXQUERYLEN];
+ InhInfo *inhinfo;
- int i_inhrel;
- int i_inhparent;
+ int i_inhrel;
+ int i_inhparent;
/* find all the inheritance information */
res = PQexec(g_conn, "begin");
@@ -1418,15 +1418,15 @@ getInherits(int *numInherits)
void
getTableAttrs(TableInfo * tblinfo, int numTables)
{
- int i,
- j;
- char q[MAXQUERYLEN];
- int i_attname;
- int i_typname;
- int i_attlen;
- int i_attnotnull;
- PGresult *res;
- int ntups;
+ int i,
+ j;
+ char q[MAXQUERYLEN];
+ int i_attname;
+ int i_typname;
+ int i_attlen;
+ int i_attnotnull;
+ PGresult *res;
+ int ntups;
for (i = 0; i < numTables; i++)
{
@@ -1504,22 +1504,22 @@ getTableAttrs(TableInfo * tblinfo, int numTables)
*
*
*/
-IndInfo *
+IndInfo *
getIndices(int *numIndices)
{
- int i;
- char query[MAXQUERYLEN];
- PGresult *res;
- int ntups;
- IndInfo *indinfo;
-
- int i_indexrelname;
- int i_indrelname;
- int i_indamname;
- int i_indproc;
- int i_indkey;
- int i_indclass;
- int i_indisunique;
+ int i;
+ char query[MAXQUERYLEN];
+ PGresult *res;
+ int ntups;
+ IndInfo *indinfo;
+
+ int i_indexrelname;
+ int i_indrelname;
+ int i_indamname;
+ int i_indproc;
+ int i_indkey;
+ int i_indclass;
+ int i_indisunique;
/*
* find all the user-defined indices. We do not handle partial
@@ -1599,9 +1599,9 @@ void
dumpTypes(FILE * fout, FuncInfo * finfo, int numFuncs,
TypeInfo * tinfo, int numTypes)
{
- int i;
- char q[MAXQUERYLEN];
- int funcInd;
+ int i;
+ char q[MAXQUERYLEN];
+ int funcInd;
for (i = 0; i < numTypes; i++)
{
@@ -1648,7 +1648,7 @@ dumpTypes(FILE * fout, FuncInfo * finfo, int numFuncs,
if (tinfo[i].isArray)
{
- char *elemType;
+ char *elemType;
elemType = findTypeByOid(tinfo, numTypes, tinfo[i].typelem);
@@ -1673,7 +1673,7 @@ void
dumpFuncs(FILE * fout, FuncInfo * finfo, int numFuncs,
TypeInfo * tinfo, int numTypes)
{
- int i;
+ int i;
for (i = 0; i < numFuncs; i++)
{
@@ -1692,8 +1692,8 @@ static void
dumpOneFunc(FILE * fout, FuncInfo * finfo, int i,
TypeInfo * tinfo, int numTypes)
{
- char q[MAXQUERYLEN];
- int j;
+ char q[MAXQUERYLEN];
+ int j;
if (finfo[i].dumped)
return;
@@ -1705,7 +1705,7 @@ dumpOneFunc(FILE * fout, FuncInfo * finfo, int i,
sprintf(q, "CREATE FUNCTION %s (", finfo[i].proname);
for (j = 0; j < finfo[i].nargs; j++)
{
- char *typname;
+ char *typname;
typname = findTypeByOid(tinfo, numTypes, finfo[i].argtypes[j]);
sprintf(q, "%s%s%s",
@@ -1733,15 +1733,15 @@ void
dumpOprs(FILE * fout, OprInfo * oprinfo, int numOperators,
TypeInfo * tinfo, int numTypes)
{
- int i;
- char q[MAXQUERYLEN];
- char leftarg[MAXQUERYLEN];
- char rightarg[MAXQUERYLEN];
- char commutator[MAXQUERYLEN];
- char negator[MAXQUERYLEN];
- char restrict[MAXQUERYLEN];
- char join[MAXQUERYLEN];
- char sortop[MAXQUERYLEN];
+ int i;
+ char q[MAXQUERYLEN];
+ char leftarg[MAXQUERYLEN];
+ char rightarg[MAXQUERYLEN];
+ char commutator[MAXQUERYLEN];
+ char negator[MAXQUERYLEN];
+ char restrict[MAXQUERYLEN];
+ char join[MAXQUERYLEN];
+ char sortop[MAXQUERYLEN];
for (i = 0; i < numOperators; i++)
{
@@ -1840,13 +1840,13 @@ void
dumpAggs(FILE * fout, AggInfo * agginfo, int numAggs,
TypeInfo * tinfo, int numTypes)
{
- int i;
- char q[MAXQUERYLEN];
- char sfunc1[MAXQUERYLEN];
- char sfunc2[MAXQUERYLEN];
- char finalfunc[MAXQUERYLEN];
- char comma1[2],
- comma2[2];
+ int i;
+ char q[MAXQUERYLEN];
+ char sfunc1[MAXQUERYLEN];
+ char sfunc2[MAXQUERYLEN];
+ char finalfunc[MAXQUERYLEN];
+ char comma1[2],
+ comma2[2];
for (i = 0; i < numAggs; i++)
{
@@ -1929,14 +1929,14 @@ dumpTables(FILE * fout, TableInfo * tblinfo, int numTables,
TypeInfo * tinfo, int numTypes, const char *tablename,
const bool acls)
{
- int i,
- j,
- k;
- char q[MAXQUERYLEN];
- char **parentRels; /* list of names of parent relations */
- int numParents;
- int actual_atts;/* number of attrs in this CREATE statment */
- const char *archiveMode;
+ int i,
+ j,
+ k;
+ char q[MAXQUERYLEN];
+ char **parentRels; /* list of names of parent relations */
+ int numParents;
+ int actual_atts; /* number of attrs in this CREATE statment */
+ const char *archiveMode;
for (i = 0; i < numTables; i++)
{
@@ -2031,19 +2031,19 @@ dumpTables(FILE * fout, TableInfo * tblinfo, int numTables,
switch (tblinfo[i].relarch[0])
{
- case 'n':
- archiveMode = "none";
- break;
- case 'h':
- archiveMode = "heavy";
- break;
- case 'l':
- archiveMode = "light";
- break;
- default:
- fprintf(stderr, "unknown archive mode\n");
- archiveMode = "none";
- break;
+ case 'n':
+ archiveMode = "none";
+ break;
+ case 'h':
+ archiveMode = "heavy";
+ break;
+ case 'l':
+ archiveMode = "light";
+ break;
+ default:
+ fprintf(stderr, "unknown archive mode\n");
+ archiveMode = "none";
+ break;
}
sprintf(q, "%s archive = %s;\n",
@@ -2067,19 +2067,19 @@ void
dumpIndices(FILE * fout, IndInfo * indinfo, int numIndices,
TableInfo * tblinfo, int numTables, const char *tablename)
{
- int i,
- k;
- int tableInd;
- char attlist[1000];
- char *classname[INDEX_MAX_KEYS];
- char *funcname; /* the name of the function to comput the
+ int i,
+ k;
+ int tableInd;
+ char attlist[1000];
+ char *classname[INDEX_MAX_KEYS];
+ char *funcname; /* the name of the function to comput the
* index key from */
- int indkey,
- indclass;
- int nclass;
+ int indkey,
+ indclass;
+ int nclass;
- char q[MAXQUERYLEN];
- PGresult *res;
+ char q[MAXQUERYLEN];
+ PGresult *res;
for (i = 0; i < numIndices; i++)
{
@@ -2145,7 +2145,7 @@ dumpIndices(FILE * fout, IndInfo * indinfo, int numIndices,
/* convert attribute numbers into attribute list */
for (k = 0, attlist[0] = 0; k < INDEX_MAX_KEYS; k++)
{
- char *attname;
+ char *attname;
indkey = atoi(indinfo[i].indkey[k]);
if (indkey == 0)
@@ -2214,11 +2214,11 @@ dumpIndices(FILE * fout, IndInfo * indinfo, int numIndices,
void
dumpTuples(PGresult * res, FILE * fout, int *attrmap)
{
- int j,
- k;
- int m,
- n;
- char **outVals = NULL; /* values to copy out */
+ int j,
+ k;
+ int m,
+ n;
+ char **outVals = NULL; /* values to copy out */
n = PQntuples(res);
m = PQnfields(res);
@@ -2240,7 +2240,7 @@ dumpTuples(PGresult * res, FILE * fout, int *attrmap)
}
for (k = 0; k < m; k++)
{
- char *pval = outVals[k];
+ char *pval = outVals[k];
if (k != 0)
fputc('\t', fout); /* delimiter for attribute */
@@ -2273,8 +2273,8 @@ dumpTuples(PGresult * res, FILE * fout, int *attrmap)
static void
setMaxOid(FILE * fout)
{
- PGresult *res;
- Oid max_oid;
+ PGresult *res;
+ Oid max_oid;
res = PQexec(g_conn, "CREATE TABLE pgdump_oid (dummy int4)");
if (!res ||
@@ -2326,9 +2326,9 @@ setMaxOid(FILE * fout)
static int
findLastBuiltinOid(void)
{
- PGresult *res;
- int ntups;
- int last_oid;
+ PGresult *res;
+ int ntups;
+ int last_oid;
res = PQexec(g_conn,
"SELECT oid from pg_database where datname = 'template1'");
@@ -2355,14 +2355,14 @@ findLastBuiltinOid(void)
* checkForQuote:
* checks a string for quote characters and quotes them
*/
-static char *
+static char *
checkForQuote(const char *s)
{
- char *r;
- char c;
- char *result;
+ char *r;
+ char c;
+ char *result;
- int j = 0;
+ int j = 0;
r = malloc(strlen(s) * 3 + 1); /* definitely long enough */
@@ -2389,16 +2389,16 @@ checkForQuote(const char *s)
static void
dumpSequence(FILE * fout, TableInfo tbinfo)
{
- PGresult *res;
- int4 last,
- incby,
- maxv,
- minv,
- cache;
- char cycled,
- called,
- *t;
- char query[MAXQUERYLEN];
+ PGresult *res;
+ int4 last,
+ incby,
+ maxv,
+ minv,
+ cache;
+ char cycled,
+ called,
+ *t;
+ char query[MAXQUERYLEN];
sprintf(query,
"SELECT sequence_name, last_value, increment_by, max_value, "
diff --git a/src/bin/pg_dump/pg_dump.h b/src/bin/pg_dump/pg_dump.h
index b59e4d8299..cf50bee06e 100644
--- a/src/bin/pg_dump/pg_dump.h
+++ b/src/bin/pg_dump/pg_dump.h
@@ -5,7 +5,7 @@
*
* Copyright (c) 1994, Regents of the University of California
*
- * $Id: pg_dump.h,v 1.20 1997/09/07 04:54:42 momjian Exp $
+ * $Id: pg_dump.h,v 1.21 1997/09/08 02:32:50 momjian Exp $
*
* Modifications - 6/12/96 - dave@bensoft.com - version 1.13.dhb.2
*
@@ -26,142 +26,139 @@
typedef struct _typeInfo
{
- char *oid;
- char *typowner;
- char *typname;
- char *typlen;
- char *typprtlen;
- char *typinput;
- char *typoutput;
- char *typreceive;
- char *typsend;
- char *typelem;
- char *typdelim;
- char *typdefault;
- char *typrelid;
- char *usename;
- int passedbyvalue;
- int isArray;
-} TypeInfo;
+ char *oid;
+ char *typowner;
+ char *typname;
+ char *typlen;
+ char *typprtlen;
+ char *typinput;
+ char *typoutput;
+ char *typreceive;
+ char *typsend;
+ char *typelem;
+ char *typdelim;
+ char *typdefault;
+ char *typrelid;
+ char *usename;
+ int passedbyvalue;
+ int isArray;
+} TypeInfo;
typedef struct _funcInfo
{
- char *oid;
- char *proname;
- char *proowner;
- int lang; /* 1 if C, else SQL */
- int nargs;
- char *argtypes[8];/* should be derived from obj/fmgr.h
+ char *oid;
+ char *proname;
+ char *proowner;
+ int lang; /* 1 if C, else SQL */
+ int nargs;
+ char *argtypes[8]; /* should be derived from obj/fmgr.h
* instead of hardwired */
- char *prorettype;
- int retset; /* 1 if the function returns a set, 0
+ char *prorettype;
+ int retset; /* 1 if the function returns a set, 0
* otherwise */
- char *prosrc;
- char *probin;
- char *usename;
- int dumped; /* 1 if already dumped */
-} FuncInfo;
+ char *prosrc;
+ char *probin;
+ char *usename;
+ int dumped; /* 1 if already dumped */
+} FuncInfo;
typedef struct _tableInfo
{
- char *oid;
- char *relname;
- char *relarch;
- char *relacl;
- bool sequence;
- int numatts; /* number of attributes */
- int *inhAttrs; /* an array of flags, one for each
+ char *oid;
+ char *relname;
+ char *relarch;
+ char *relacl;
+ bool sequence;
+ int numatts; /* number of attributes */
+ int *inhAttrs; /* an array of flags, one for each
* attribute if the value is 1, then this
* attribute is an inherited attribute */
- char **attnames; /* the attribute names */
- char **typnames; /* fill out attributes */
- bool *notnull; /* Not null constraints of an attribute */
- int numParents; /* number of (immediate) parent
+ char **attnames; /* the attribute names */
+ char **typnames; /* fill out attributes */
+ bool *notnull; /* Not null constraints of an attribute */
+ int numParents; /* number of (immediate) parent
* supertables */
- char **parentRels; /* names of parent relations, NULL if
+ char **parentRels; /* names of parent relations, NULL if
* numParents == 0 */
- char **out_attnames; /* the attribute names, in the
- * order they would be in, when
- * the table is created in the
- * target query language. this is
- * needed because the SQL tables
- * will not have the same order of
- * attributes as the POSTQUEL
- * tables */
- int *attlen; /* attribute lengths */
- char *usename;
-
-} TableInfo;
+ char **out_attnames; /* the attribute names, in the order they
+ * would be in, when the table is created
+ * in the target query language. this is
+ * needed because the SQL tables will not
+ * have the same order of attributes as
+ * the POSTQUEL tables */
+ int *attlen; /* attribute lengths */
+ char *usename;
+
+} TableInfo;
typedef struct _inhInfo
{
- char *inhrel;
- char *inhparent;
-} InhInfo;
+ char *inhrel;
+ char *inhparent;
+} InhInfo;
typedef struct _indInfo
{
- char *indexrelname; /* name of the secondary index
- * class */
- char *indrelname; /* name of the indexed heap class */
- char *indamname; /* name of the access method (e.g. btree,
+ char *indexrelname; /* name of the secondary index class */
+ char *indrelname; /* name of the indexed heap class */
+ char *indamname; /* name of the access method (e.g. btree,
* rtree, etc.) */
- char *indproc; /* oid of the function to compute the
+ char *indproc; /* oid of the function to compute the
* index, 0 if none */
- char *indkey[INDEX_MAX_KEYS]; /* attribute numbers of
- * the key attributes */
- char *indclass[INDEX_MAX_KEYS]; /* opclass of the keys */
- char *indisunique;/* is this index unique? */
-} IndInfo;
+ char *indkey[INDEX_MAX_KEYS]; /* attribute numbers of the key
+ * attributes */
+ char *indclass[INDEX_MAX_KEYS]; /* opclass of the keys */
+ char *indisunique; /* is this index unique? */
+} IndInfo;
typedef struct _aggInfo
{
- char *oid;
- char *aggname;
- char *aggtransfn1;
- char *aggtransfn2;
- char *aggfinalfn;
- char *aggtranstype1;
- char *aggbasetype;
- char *aggtranstype2;
- char *agginitval1;
- char *agginitval2;
- char *usename;
-} AggInfo;
+ char *oid;
+ char *aggname;
+ char *aggtransfn1;
+ char *aggtransfn2;
+ char *aggfinalfn;
+ char *aggtranstype1;
+ char *aggbasetype;
+ char *aggtranstype2;
+ char *agginitval1;
+ char *agginitval2;
+ char *usename;
+} AggInfo;
typedef struct _oprInfo
{
- char *oid;
- char *oprname;
- char *oprkind; /* "b" = binary, "l" = left unary, "r" =
+ char *oid;
+ char *oprname;
+ char *oprkind; /* "b" = binary, "l" = left unary, "r" =
* right unary */
- char *oprcode; /* operator function name */
- char *oprleft; /* left operand type */
- char *oprright; /* right operand type */
- char *oprcom; /* oid of the commutator operator */
- char *oprnegate; /* oid of the negator operator */
- char *oprrest; /* name of the function to calculate
+ char *oprcode; /* operator function name */
+ char *oprleft; /* left operand type */
+ char *oprright; /* right operand type */
+ char *oprcom; /* oid of the commutator operator */
+ char *oprnegate; /* oid of the negator operator */
+ char *oprrest; /* name of the function to calculate
* operator restriction selectivity */
- char *oprjoin; /* name of the function to calculate
+ char *oprjoin; /* name of the function to calculate
* operator join selectivity */
- char *oprcanhash; /* can we use hash join strategy ? */
- char *oprlsortop; /* oid's of the left and right sort
+ char *oprcanhash; /* can we use hash join strategy ? */
+ char *oprlsortop; /* oid's of the left and right sort
* operators */
- char *oprrsortop;
- char *usename;
-} OprInfo;
+ char *oprrsortop;
+ char *usename;
+} OprInfo;
/* global decls */
-extern bool g_verbose; /* verbose flag */
-extern int g_last_builtin_oid; /* value of the last builtin oid */
-extern FILE *g_fout; /* the script file */
+extern bool g_verbose; /* verbose flag */
+extern int g_last_builtin_oid; /* value of the last builtin oid */
+extern FILE *g_fout; /* the script file */
/* placeholders for comment starting and ending delimiters */
-extern char g_comment_start[10];
-extern char g_comment_end[10];
+extern char g_comment_start[10];
+extern char g_comment_end[10];
-extern char g_opaque_type[10]; /* name for the opaque type */
+extern char g_opaque_type[10]; /* name for the opaque type */
/* pg_dump is really two programs in one
one version works with postgres v4r2
@@ -184,14 +181,14 @@ dumpSchemaIdx(FILE * fout,
TableInfo * tblinfo,
int numTables);
-extern char *findTypeByOid(TypeInfo * tinfo, int numTypes, const char *oid);
-extern char *findOprByOid(OprInfo * oprinfo, int numOprs, const char *oid);
-extern int findFuncByName(FuncInfo * finfo, int numFuncs, const char *name);
-extern int findTableByName(TableInfo * tbinfo, int numTables, const char *relname);
+extern char *findTypeByOid(TypeInfo * tinfo, int numTypes, const char *oid);
+extern char *findOprByOid(OprInfo * oprinfo, int numOprs, const char *oid);
+extern int findFuncByName(FuncInfo * finfo, int numFuncs, const char *name);
+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 int isArchiveName(const char *);
+extern void check_conn_and_db(void);
+extern void parseArgTypes(char **argtypes, const char *str);
+extern int isArchiveName(const char *);
/*
* version specific routines
@@ -200,17 +197,17 @@ extern TypeInfo *getTypes(int *numTypes);
extern FuncInfo *getFuncs(int *numFuncs);
extern AggInfo *getAggregates(int *numAggregates);
-extern void clearAggInfo(AggInfo *, int);
-extern void clearFuncInfo(FuncInfo *, int);
-extern void clearInhInfo(InhInfo *, int);
-extern void clearIndInfo(IndInfo *, int);
-extern void clearOprInfo(OprInfo *, int);
-extern void clearTypeInfo(TypeInfo *, int);
+extern void clearAggInfo(AggInfo *, int);
+extern void clearFuncInfo(FuncInfo *, int);
+extern void clearInhInfo(InhInfo *, int);
+extern void clearIndInfo(IndInfo *, int);
+extern void clearOprInfo(OprInfo *, int);
+extern void clearTypeInfo(TypeInfo *, int);
extern OprInfo *getOperators(int *numOperators);
extern TableInfo *getTables(int *numTables);
extern InhInfo *getInherits(int *numInherits);
-extern void getTableAttrs(TableInfo * tbinfo, int numTables);
+extern void getTableAttrs(TableInfo * tbinfo, int numTables);
extern IndInfo *getIndices(int *numIndices);
extern void
dumpTypes(FILE * fout, FuncInfo * finfo, int numFuncs,
diff --git a/src/bin/pg_id/pg_id.c b/src/bin/pg_id/pg_id.c
index b782b091a3..b246131b84 100644
--- a/src/bin/pg_id/pg_id.c
+++ b/src/bin/pg_id/pg_id.c
@@ -9,7 +9,7 @@
*
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/bin/pg_id/Attic/pg_id.c,v 1.4 1997/09/07 04:54:46 momjian Exp $
+ * $Header: /cvsroot/pgsql/src/bin/pg_id/Attic/pg_id.c,v 1.5 1997/09/08 02:32:52 momjian Exp $
*
*-------------------------------------------------------------------------
*/
@@ -23,17 +23,17 @@
int
main(int argc, char **argv)
{
- struct passwd *pw;
- int ch;
- extern int optind;
+ struct passwd *pw;
+ int ch;
+ extern int optind;
while ((ch = getopt(argc, argv, "")) != EOF)
switch (ch)
{
- case '?':
- default:
- fprintf(stderr, "usage: pg_id [login]\n");
- exit(1);
+ case '?':
+ default:
+ fprintf(stderr, "usage: pg_id [login]\n");
+ exit(1);
}
argc -= optind;
argv += optind;
diff --git a/src/bin/pg_passwd/pg_passwd.c b/src/bin/pg_passwd/pg_passwd.c
index 9a99b45b69..4394f83e7c 100644
--- a/src/bin/pg_passwd/pg_passwd.c
+++ b/src/bin/pg_passwd/pg_passwd.c
@@ -19,18 +19,18 @@
#ifdef HAVE_CRYPT_H
#include <crypt.h>
#else
-extern char *crypt(const char *, const char *);
+extern char *crypt(const char *, const char *);
#endif
-char *comname;
-void usage(FILE * stream);
-void read_pwd_file(char *filename);
-void write_pwd_file(char *filename, char *bkname);
-void encrypt_pwd(char key[9], char salt[3], char passwd[14]);
-int check_pwd(char key[9], char passwd[14]);
-void prompt_for_username(char *username);
-void prompt_for_password(char *prompt, char *password);
+char *comname;
+void usage(FILE * stream);
+void read_pwd_file(char *filename);
+void write_pwd_file(char *filename, char *bkname);
+void encrypt_pwd(char key[9], char salt[3], char passwd[14]);
+int check_pwd(char key[9], char passwd[14]);
+void prompt_for_username(char *username);
+void prompt_for_password(char *prompt, char *password);
void
usage(FILE * stream)
@@ -40,24 +40,24 @@ usage(FILE * stream)
typedef struct
{
- char *uname;
- char *pwd;
- char *rest;
-} pg_pwd;
+ char *uname;
+ char *pwd;
+ char *rest;
+} pg_pwd;
#define MAXPWDS 1024
-pg_pwd pwds[MAXPWDS];
-int npwds = 0;
+pg_pwd pwds[MAXPWDS];
+int npwds = 0;
void
read_pwd_file(char *filename)
{
- FILE *fp;
- static char line[512];
- static char ans[128];
- int i;
+ FILE *fp;
+ static char line[512];
+ static char ans[128];
+ int i;
try_again:
fp = fopen(filename, "r");
@@ -70,19 +70,19 @@ try_again:
fgets(ans, 128, stdin);
switch (ans[0])
{
- case 'y':
- case 'Y':
- fp = fopen(filename, "w");
- if (fp == NULL)
- {
- perror(filename);
+ case 'y':
+ case 'Y':
+ fp = fopen(filename, "w");
+ if (fp == NULL)
+ {
+ perror(filename);
+ exit(1);
+ }
+ fclose(fp);
+ goto try_again;
+ default:
+ /* cannot continue */
exit(1);
- }
- fclose(fp);
- goto try_again;
- default:
- /* cannot continue */
- exit(1);
}
}
else
@@ -95,9 +95,9 @@ try_again:
/* read all the entries */
for (npwds = 0; npwds < MAXPWDS && fgets(line, 512, fp) != NULL; ++npwds)
{
- int l;
- char *p,
- *q;
+ int l;
+ char *p,
+ *q;
l = strlen(line);
if (line[l - 1] == '\n')
@@ -168,8 +168,8 @@ try_again:
void
write_pwd_file(char *filename, char *bkname)
{
- FILE *fp;
- int i;
+ FILE *fp;
+ int i;
/* make the backup file */
link_again:
@@ -210,12 +210,12 @@ link_again:
void
encrypt_pwd(char key[9], char salt[3], char passwd[14])
{
- int n;
+ int n;
/* get encrypted password */
if (salt[0] == '\0')
{
- struct timeval tm;
+ struct timeval tm;
gettimeofday(&tm, NULL);
srand(tm.tv_sec ? tm.tv_sec : 1);
@@ -244,8 +244,8 @@ encrypt_pwd(char key[9], char salt[3], char passwd[14])
int
check_pwd(char key[9], char passwd[14])
{
- char shouldbe[14];
- char salt[3];
+ char shouldbe[14];
+ char salt[3];
salt[0] = passwd[0];
salt[1] = passwd[1];
@@ -258,7 +258,7 @@ check_pwd(char key[9], char passwd[14])
void
prompt_for_username(char *username)
{
- int length;
+ int length;
printf("Username: ");
fgets(username, 9, stdin);
@@ -267,7 +267,7 @@ prompt_for_username(char *username)
/* skip rest of the line */
if (length > 0 && username[length - 1] != '\n')
{
- static char buf[512];
+ static char buf[512];
do
{
@@ -281,11 +281,11 @@ prompt_for_username(char *username)
void
prompt_for_password(char *prompt, char *password)
{
- int length;
+ int length;
#ifdef HAVE_TERMIOS_H
- struct termios t_orig,
- t;
+ struct termios t_orig,
+ t;
#endif
@@ -305,7 +305,7 @@ prompt_for_password(char *prompt, char *password)
/* skip rest of the line */
if (length > 0 && password[length - 1] != '\n')
{
- static char buf[512];
+ static char buf[512];
do
{
@@ -321,13 +321,13 @@ prompt_for_password(char *prompt, char *password)
int
main(int argc, char *argv[])
{
- static char bkname[512];
- char username[9];
- char salt[3];
- char key[9],
- key2[9];
- char e_passwd[14];
- int i;
+ static char bkname[512];
+ char username[9];
+ char salt[3];
+ char key[9],
+ key2[9];
+ char e_passwd[14];
+ int i;
comname = argv[0];
if (argc != 2)
diff --git a/src/bin/pg_version/pg_version.c b/src/bin/pg_version/pg_version.c
index 314ddddeb2..3c7de9387f 100644
--- a/src/bin/pg_version/pg_version.c
+++ b/src/bin/pg_version/pg_version.c
@@ -7,7 +7,7 @@
*
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/bin/pg_version/Attic/pg_version.c,v 1.7 1997/09/07 04:54:56 momjian Exp $
+ * $Header: /cvsroot/pgsql/src/bin/pg_version/Attic/pg_version.c,v 1.8 1997/09/08 02:33:10 momjian Exp $
*
*-------------------------------------------------------------------------
*/
@@ -21,8 +21,8 @@
int
main(int argc, char **argv)
{
- int retcode; /* our eventual return code */
- char *reason; /* Reason that SetPgVersion failed, NULL
+ int retcode; /* our eventual return code */
+ char *reason; /* Reason that SetPgVersion failed, NULL
* if it didn't. */
if (argc < 2)
diff --git a/src/bin/pgtclsh/pgtclAppInit.c b/src/bin/pgtclsh/pgtclAppInit.c
index 1c9040fbd5..f344dd403e 100644
--- a/src/bin/pgtclsh/pgtclAppInit.c
+++ b/src/bin/pgtclsh/pgtclAppInit.c
@@ -21,8 +21,8 @@
*/
#ifdef NEED_MATHERR
-extern int matherr();
-int *tclDummyMathPtr = (int *) matherr;
+extern int matherr();
+int *tclDummyMathPtr = (int *) matherr;
#endif
diff --git a/src/bin/pgtclsh/pgtkAppInit.c b/src/bin/pgtclsh/pgtkAppInit.c
index fbca4cca2e..bdb569cb3c 100644
--- a/src/bin/pgtclsh/pgtkAppInit.c
+++ b/src/bin/pgtclsh/pgtkAppInit.c
@@ -20,8 +20,8 @@
*/
#ifdef NEED_MATHERR
-extern int matherr();
-int *tclDummyMathPtr = (int *) matherr;
+extern int matherr();
+int *tclDummyMathPtr = (int *) matherr;
#endif
diff --git a/src/bin/psql/psql.c b/src/bin/psql/psql.c
index 3a58f8ad32..fa6bd9608e 100644
--- a/src/bin/psql/psql.c
+++ b/src/bin/psql/psql.c
@@ -7,7 +7,7 @@
*
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/bin/psql/Attic/psql.c,v 1.91 1997/09/07 04:55:20 momjian Exp $
+ * $Header: /cvsroot/pgsql/src/bin/psql/Attic/psql.c,v 1.92 1997/09/08 02:33:36 momjian Exp $
*
*-------------------------------------------------------------------------
*/
@@ -80,41 +80,41 @@
typedef struct _psqlSettings
{
- PGconn *db; /* connection to backend */
- FILE *queryFout; /* where to send the query results */
- PQprintOpt opt; /* options to be passed to PQprint */
- char *prompt; /* prompt to display */
- char *gfname; /* one-shot file output argument for \g */
- bool notty; /* input or output is not a tty */
- bool pipe; /* queryFout is from a popen() */
- bool echoQuery; /* echo the query before sending it */
- bool quiet; /* run quietly, no messages, no promt */
- bool singleStep; /* prompt before for each query */
- bool singleLineMode; /* query terminated by newline */
- bool useReadline;/* use libreadline routines */
- bool getPassword;/* prompt the user for a username and
+ PGconn *db; /* connection to backend */
+ FILE *queryFout; /* where to send the query results */
+ PQprintOpt opt; /* options to be passed to PQprint */
+ char *prompt; /* prompt to display */
+ char *gfname; /* one-shot file output argument for \g */
+ bool notty; /* input or output is not a tty */
+ bool pipe; /* queryFout is from a popen() */
+ bool echoQuery; /* echo the query before sending it */
+ bool quiet; /* run quietly, no messages, no promt */
+ bool singleStep; /* prompt before for each query */
+ bool singleLineMode; /* query terminated by newline */
+ bool useReadline; /* use libreadline routines */
+ bool getPassword; /* prompt the user for a username and
* password */
-} PsqlSettings;
+} PsqlSettings;
/* declarations for functions in this file */
-static void usage(char *progname);
-static void slashUsage();
-static void handleCopyOut(PGresult * res, bool quiet, FILE * copystream);
+static void usage(char *progname);
+static void slashUsage();
+static void handleCopyOut(PGresult * res, bool quiet, FILE * copystream);
static void
handleCopyIn(PGresult * res, const bool mustprompt,
FILE * copystream);
-static int tableList(PsqlSettings * ps, bool deep_tablelist, char info_type);
-static int tableDesc(PsqlSettings * ps, char *table);
-static int rightsList(PsqlSettings * ps);
-static void prompt_for_password(char *username, char *password);
-static char *
+static int tableList(PsqlSettings * ps, bool deep_tablelist, char info_type);
+static int tableDesc(PsqlSettings * ps, char *table);
+static int rightsList(PsqlSettings * ps);
+static void prompt_for_password(char *username, char *password);
+static char *
make_connect_string(char *host, char *port, char *dbname,
char *username, char *password);
-static char *gets_noreadline(char *prompt, FILE * source);
-static char *gets_readline(char *prompt, FILE * source);
-static char *gets_fromFile(char *prompt, FILE * source);
-static int listAllDbs(PsqlSettings * settings);
+static char *gets_noreadline(char *prompt, FILE * source);
+static char *gets_readline(char *prompt, FILE * source);
+static char *gets_fromFile(char *prompt, FILE * source);
+static int listAllDbs(PsqlSettings * settings);
static void
SendQuery(bool * success_p, PsqlSettings * settings, const char *query,
const bool copy_in, const bool copy_out, FILE * copystream);
@@ -122,7 +122,7 @@ static int
HandleSlashCmds(PsqlSettings * settings,
char *line,
char *query);
-static int MainLoop(PsqlSettings * settings, FILE * source);
+static int MainLoop(PsqlSettings * settings, FILE * source);
/* probably should move this into libpq */
void
@@ -131,7 +131,7 @@ PQprint(FILE * fp,
PQprintOpt * po
);
-static FILE *setFout(PsqlSettings * ps, char *fname);
+static FILE *setFout(PsqlSettings * ps, char *fname);
/*
* usage print out usage for command line arguments
@@ -168,7 +168,7 @@ usage(char *progname)
* slashUsage print out usage for the backslash commands
*/
-static char *
+static char *
on(bool f)
{
return f ? "on" : "off";
@@ -177,9 +177,9 @@ on(bool f)
static void
slashUsage(PsqlSettings * ps)
{
- int usePipe = 0;
- char *pagerenv;
- FILE *fout;
+ int usePipe = 0;
+ char *pagerenv;
+ FILE *fout;
if (ps->notty == 0 &&
(pagerenv = getenv("PAGER")) &&
@@ -230,7 +230,7 @@ slashUsage(PsqlSettings * ps)
static PGresult *
PSQLexec(PsqlSettings * ps, char *query)
{
- PGresult *res;
+ PGresult *res;
res = PQexec(ps->db, query);
if (!res)
@@ -258,8 +258,8 @@ PSQLexec(PsqlSettings * ps, char *query)
static int
listAllDbs(PsqlSettings * ps)
{
- PGresult *results;
- char *query = "select * from pg_database;";
+ PGresult *results;
+ char *query = "select * from pg_database;";
if (!(results = PSQLexec(ps, query)))
return 1;
@@ -280,32 +280,32 @@ listAllDbs(PsqlSettings * ps)
int
tableList(PsqlSettings * ps, bool deep_tablelist, char info_type)
{
- char listbuf[256];
- int nColumns;
- int i;
- char *rk;
- char *rr;
+ char listbuf[256];
+ int nColumns;
+ int i;
+ char *rk;
+ char *rr;
- PGresult *res;
+ PGresult *res;
listbuf[0] = '\0';
strcat(listbuf, "SELECT usename, relname, relkind, relhasrules");
strcat(listbuf, " FROM pg_class, pg_user ");
switch (info_type)
{
- case 't':
- strcat(listbuf, "WHERE ( relkind = 'r') ");
- break;
- case 'i':
- strcat(listbuf, "WHERE ( relkind = 'i') ");
- break;
- case 'S':
- strcat(listbuf, "WHERE ( relkind = 'S') ");
- break;
- case 'b':
- default:
- strcat(listbuf, "WHERE ( relkind = 'r' OR relkind = 'i' OR relkind = 'S') ");
- break;
+ case 't':
+ strcat(listbuf, "WHERE ( relkind = 'r') ");
+ break;
+ case 'i':
+ strcat(listbuf, "WHERE ( relkind = 'i') ");
+ break;
+ case 'S':
+ strcat(listbuf, "WHERE ( relkind = 'S') ");
+ break;
+ case 'b':
+ default:
+ strcat(listbuf, "WHERE ( relkind = 'r' OR relkind = 'i' OR relkind = 'S') ");
+ break;
}
strcat(listbuf, " and relname !~ '^pg_'");
strcat(listbuf, " and relname !~ '^xin[vx][0-9]+'");
@@ -325,7 +325,7 @@ tableList(PsqlSettings * ps, bool deep_tablelist, char info_type)
if (deep_tablelist)
{
/* describe everything here */
- char **table;
+ char **table;
table = (char **) malloc(nColumns * sizeof(char *));
if (table == NULL)
@@ -382,19 +382,19 @@ tableList(PsqlSettings * ps, bool deep_tablelist, char info_type)
PQclear(res); /* PURIFY */
switch (info_type)
{
- case 't':
- fprintf(stderr, "Couldn't find any tables!\n");
- break;
- case 'i':
- fprintf(stderr, "Couldn't find any indices!\n");
- break;
- case 'S':
- fprintf(stderr, "Couldn't find any sequences!\n");
- break;
- case 'b':
- default:
- fprintf(stderr, "Couldn't find any tables, sequences or indices!\n");
- break;
+ case 't':
+ fprintf(stderr, "Couldn't find any tables!\n");
+ break;
+ case 'i':
+ fprintf(stderr, "Couldn't find any indices!\n");
+ break;
+ case 'S':
+ fprintf(stderr, "Couldn't find any sequences!\n");
+ break;
+ case 'b':
+ default:
+ fprintf(stderr, "Couldn't find any tables, sequences or indices!\n");
+ break;
}
return (-1);
}
@@ -407,11 +407,11 @@ tableList(PsqlSettings * ps, bool deep_tablelist, char info_type)
int
rightsList(PsqlSettings * ps)
{
- char listbuf[256];
- int nColumns;
- int i;
+ char listbuf[256];
+ int nColumns;
+ int i;
- PGresult *res;
+ PGresult *res;
listbuf[0] = '\0';
strcat(listbuf, "SELECT relname, relacl");
@@ -462,13 +462,13 @@ rightsList(PsqlSettings * ps)
int
tableDesc(PsqlSettings * ps, char *table)
{
- char descbuf[256];
- int nColumns;
- char *rtype;
- int i;
- int rsize;
+ char descbuf[256];
+ int nColumns;
+ char *rtype;
+ int i;
+ int rsize;
- PGresult *res;
+ PGresult *res;
/* Build the query */
@@ -530,7 +530,7 @@ tableDesc(PsqlSettings * ps, char *table)
printf("%-32.32s |", rtype);
else
{
- char *newname;
+ char *newname;
newname = malloc(strlen(rtype) + 2);
strcpy(newname, rtype + 1);
@@ -558,13 +558,13 @@ tableDesc(PsqlSettings * ps, char *table)
}
}
-typedef char *(*READ_ROUTINE) (char *prompt, FILE * source);
+typedef char *(*READ_ROUTINE) (char *prompt, FILE * source);
/*
* gets_noreadline prompt source gets a line of input without calling
* readline, the source is ignored
*/
-static char *
+static char *
gets_noreadline(char *prompt, FILE * source)
{
fputs(prompt, stdout);
@@ -576,15 +576,15 @@ gets_noreadline(char *prompt, FILE * source)
* gets_readline prompt source the routine to get input from GNU readline(),
* the source is ignored the prompt argument is used as the prompting string
*/
-static char *
+static char *
gets_readline(char *prompt, FILE * source)
{
- char *s;
+ char *s;
#ifdef HAVE_LIBREADLINE
s = readline(prompt);
#else
- char buf[500];
+ char buf[500];
printf("%s", prompt);
s = fgets(buf, 500, stdin);
@@ -600,11 +600,11 @@ gets_readline(char *prompt, FILE * source)
* the routine to read from a file, the prompt argument is ignored the source
* argument is a FILE *
*/
-static char *
+static char *
gets_fromFile(char *prompt, FILE * source)
{
- char *line;
- int len;
+ char *line;
+ int len;
line = malloc(MAX_QUERY_BUFFER + 1);
@@ -634,8 +634,8 @@ SendQuery(bool * success_p, PsqlSettings * settings, const char *query,
const bool copy_in, const bool copy_out, FILE * copystream)
{
- PGresult *results;
- PGnotify *notify;
+ PGresult *results;
+ PGnotify *notify;
if (settings->singleStep)
fprintf(stdout, "\n**************************************"
@@ -664,76 +664,76 @@ SendQuery(bool * success_p, PsqlSettings * settings, const char *query,
{
switch (PQresultStatus(results))
{
- case PGRES_TUPLES_OK:
- if (settings->gfname)
- {
- PsqlSettings ps = *settings;
- FILE *fp;
-
- ps.queryFout = stdout;
- fp = setFout(&ps, settings->gfname);
- if (!fp || fp == stdout)
+ case PGRES_TUPLES_OK:
+ if (settings->gfname)
{
- *success_p = false;
+ PsqlSettings ps = *settings;
+ FILE *fp;
+
+ ps.queryFout = stdout;
+ fp = setFout(&ps, settings->gfname);
+ if (!fp || fp == stdout)
+ {
+ *success_p = false;
+ break;
+ }
+ else
+ *success_p = true;
+ PQprint(fp,
+ results,
+ &(settings->opt));
+ if (ps.pipe)
+ pclose(fp);
+ else
+ fclose(fp);
+ free(settings->gfname);
+ settings->gfname = NULL;
break;
}
else
+ {
*success_p = true;
- PQprint(fp,
- results,
- &(settings->opt));
- if (ps.pipe)
- pclose(fp);
- else
- fclose(fp);
- free(settings->gfname);
- settings->gfname = NULL;
+ PQprint(settings->queryFout,
+ results,
+ &(settings->opt));
+ fflush(settings->queryFout);
+ }
break;
- }
- else
- {
+ case PGRES_EMPTY_QUERY:
+ *success_p = true;
+ break;
+ case PGRES_COMMAND_OK:
*success_p = true;
- PQprint(settings->queryFout,
- results,
- &(settings->opt));
- fflush(settings->queryFout);
- }
- break;
- case PGRES_EMPTY_QUERY:
- *success_p = true;
- break;
- case PGRES_COMMAND_OK:
- *success_p = true;
- if (!settings->quiet)
- printf("%s\n", PQcmdStatus(results));
- break;
- case PGRES_COPY_OUT:
- *success_p = true;
- if (copy_out)
- {
- handleCopyOut(results, settings->quiet, copystream);
- }
- else
- {
if (!settings->quiet)
- printf("Copy command returns...\n");
+ printf("%s\n", PQcmdStatus(results));
+ break;
+ case PGRES_COPY_OUT:
+ *success_p = true;
+ if (copy_out)
+ {
+ handleCopyOut(results, settings->quiet, copystream);
+ }
+ else
+ {
+ if (!settings->quiet)
+ printf("Copy command returns...\n");
- handleCopyOut(results, settings->quiet, stdout);
- }
- break;
- case PGRES_COPY_IN:
- *success_p = true;
- if (copy_in)
- handleCopyIn(results, false, copystream);
- else
- handleCopyIn(results, !settings->quiet, stdin);
- break;
- case PGRES_NONFATAL_ERROR:
- case PGRES_FATAL_ERROR:
- case PGRES_BAD_RESPONSE:
- *success_p = false;
- fprintf(stderr, "%s", PQerrorMessage(settings->db));
- break;
+ handleCopyOut(results, settings->quiet, stdout);
+ }
+ break;
+ case PGRES_COPY_IN:
+ *success_p = true;
+ if (copy_in)
+ handleCopyIn(results, false, copystream);
+ else
+ handleCopyIn(results, !settings->quiet, stdin);
+ break;
+ case PGRES_NONFATAL_ERROR:
+ case PGRES_FATAL_ERROR:
+ case PGRES_BAD_RESPONSE:
+ *success_p = false;
+ fprintf(stderr, "%s", PQerrorMessage(settings->db));
+ break;
}
if (PQstatus(settings->db) == CONNECTION_BAD)
@@ -763,8 +763,8 @@ SendQuery(bool * success_p, PsqlSettings * settings, const char *query,
static void
editFile(char *fname)
{
- char *editorName;
- char *sys;
+ char *editorName;
+ char *sys;
editorName = getenv("EDITOR");
if (!editorName)
@@ -780,7 +780,7 @@ editFile(char *fname)
free(sys);
}
-static bool
+static bool
toggle(PsqlSettings * settings, bool * sw, char *msg)
{
*sw = !*sw;
@@ -798,36 +798,36 @@ unescape(char *dest, const char *source)
Return as the string <dest> the value of string <source> with escape
sequences turned into the bytes they represent.
-----------------------------------------------------------------------------*/
- char *p;
- bool esc; /* Last character we saw was the escape
+ char *p;
+ bool esc; /* Last character we saw was the escape
* character (/) */
esc = false; /* Haven't seen escape character yet */
for (p = (char *) source; *p; p++)
{
- char c; /* Our output character */
+ char c; /* Our output character */
if (esc)
{
switch (*p)
{
- case 'n':
- c = '\n';
- break;
- case 'r':
- c = '\r';
- break;
- case 't':
- c = '\t';
- break;
- case 'f':
- c = '\f';
- break;
- case '\\':
- c = '\\';
- break;
- default:
- c = *p;
+ case 'n':
+ c = '\n';
+ break;
+ case 'r':
+ c = '\r';
+ break;
+ case 't':
+ c = '\t';
+ break;
+ case 'f':
+ c = '\f';
+ break;
+ case '\\':
+ c = '\\';
+ break;
+ default:
+ c = *p;
}
esc = false;
}
@@ -856,14 +856,14 @@ parse_slash_copy(const char *args, char *table, const int table_len,
bool * from_p, bool * error_p)
{
- char work_args[200];
+ char work_args[200];
/*
* A copy of the \copy command arguments, except that we modify it as
* we parse to suit our parsing needs.
*/
- char *table_tok,
- *fromto_tok;
+ char *table_tok,
+ *fromto_tok;
strncpy(work_args, args, sizeof(work_args));
work_args[sizeof(work_args) - 1] = '\0';
@@ -903,7 +903,7 @@ parse_slash_copy(const char *args, char *table, const int table_len,
}
if (!*error_p)
{
- char *file_tok;
+ char *file_tok;
file_tok = strtok(NULL, " ");
if (file_tok == NULL)
@@ -942,22 +942,22 @@ do_copy(const char *args, PsqlSettings * settings)
should do all the things a backend copy can do.
----------------------------------------------------------------------------*/
- char query[200];
+ char query[200];
/* The COPY command we send to the back end */
- bool from;
+ bool from;
/* The direction of the copy is from a file to a table. */
- char file[MAXPATHLEN + 1];
+ char file[MAXPATHLEN + 1];
/* The pathname of the file from/to which we copy */
- char table[NAMEDATALEN];
+ char table[NAMEDATALEN];
/* The name of the table from/to which we copy */
- bool syntax_error;
+ bool syntax_error;
/* The \c command has invalid syntax */
- FILE *copystream;
+ FILE *copystream;
parse_slash_copy(args, table, sizeof(table), file, sizeof(file),
&from, &syntax_error);
@@ -986,8 +986,7 @@ do_copy(const char *args, PsqlSettings * settings)
from ? "from" : "to", strerror(errno), errno);
else
{
- bool success; /* The query succeeded at the
- * backend */
+ bool success;/* The query succeeded at the backend */
SendQuery(&success, settings, query, from, !from, copystream);
fclose(copystream);
@@ -1012,10 +1011,10 @@ do_connect(const char *new_dbname,
fprintf(stderr, "\\connect must be followed by a database name\n");
else
{
- PGconn *olddb = settings->db;
- static char *userenv = NULL;
- char *old_userenv = NULL;
- const char *dbparam;
+ PGconn *olddb = settings->db;
+ static char *userenv = NULL;
+ char *old_userenv = NULL;
+ const char *dbparam;
if (new_user != NULL)
{
@@ -1074,12 +1073,12 @@ static void
do_edit(const char *filename_arg, char *query, int *status_p)
{
- int fd;
- char tmp[64];
- char *fname;
- int cc;
- const int ql = strlen(query);
- bool error;
+ int fd;
+ char tmp[64];
+ char *fname;
+ int cc;
+ const int ql = strlen(query);
+ bool error;
if (filename_arg)
{
@@ -1161,9 +1160,8 @@ do_help(PsqlSettings * ps, const char *topic)
if (!topic)
{
- char left_center_right; /* Which column we're
- * displaying */
- int i; /* Index into QL_HELP[] */
+ char left_center_right; /* Which column we're displaying */
+ int i; /* Index into QL_HELP[] */
printf("type \\h <cmd> where <cmd> is one of the following:\n");
@@ -1173,18 +1171,18 @@ do_help(PsqlSettings * ps, const char *topic)
{
switch (left_center_right)
{
- case 'L':
- printf(" %-25s", QL_HELP[i].cmd);
- left_center_right = 'C';
- break;
- case 'C':
- printf("%-25s", QL_HELP[i].cmd);
- left_center_right = 'R';
- break;
- case 'R':
- printf("%-25s\n", QL_HELP[i].cmd);
- left_center_right = 'L';
- break;
+ case 'L':
+ printf(" %-25s", QL_HELP[i].cmd);
+ left_center_right = 'C';
+ break;
+ case 'C':
+ printf("%-25s", QL_HELP[i].cmd);
+ left_center_right = 'R';
+ break;
+ case 'R':
+ printf("%-25s\n", QL_HELP[i].cmd);
+ left_center_right = 'L';
+ break;
};
i++;
}
@@ -1194,12 +1192,12 @@ do_help(PsqlSettings * ps, const char *topic)
}
else
{
- int i; /* Index into QL_HELP[] */
- bool help_found; /* We found the help he asked for */
+ int i; /* Index into QL_HELP[] */
+ bool help_found; /* We found the help he asked for */
- int usePipe = 0;
- char *pagerenv;
- FILE *fout;
+ int usePipe = 0;
+ char *pagerenv;
+ FILE *fout;
if (strcmp(topic, "*") == 0 &&
(ps->notty == 0) &&
@@ -1248,8 +1246,8 @@ do_shell(const char *command)
if (!command)
{
- char *sys;
- char *shellName;
+ char *sys;
+ char *shellName;
shellName = getenv("SHELL");
if (shellName == NULL)
@@ -1288,28 +1286,28 @@ HandleSlashCmds(PsqlSettings * settings,
char *line,
char *query)
{
- int status = CMD_SKIP_LINE;
- char *optarg;
+ int status = CMD_SKIP_LINE;
+ char *optarg;
/*
* Pointer inside the <cmd> string to the argument of the slash
* command, assuming it is a one-character slash command. If it's not
* a one-character command, this is meaningless.
*/
- char *optarg2;
+ char *optarg2;
/*
* Pointer inside the <cmd> string to the argument of the slash
* command assuming it's not a one-character command. If it's a
* one-character command, this is meaningless.
*/
- char *cmd;
+ char *cmd;
/*
* String: value of the slash command, less the slash and with escape
* sequences decoded.
*/
- int blank_loc;
+ int blank_loc;
/* Offset within <cmd> of first blank */
@@ -1342,271 +1340,271 @@ HandleSlashCmds(PsqlSettings * settings,
switch (cmd[0])
{
- case 'a': /* toggles to align fields on output */
- toggle(settings, &settings->opt.align, "field alignment");
- break;
- case 'C': /* define new caption */
- if (settings->opt.caption)
- {
- free(settings->opt.caption);
- settings->opt.caption = NULL;
- }
- if (optarg && !(settings->opt.caption = strdup(optarg)))
- {
- perror("malloc");
- exit(CMD_TERMINATE);
- }
- break;
- case 'c':
- {
- if (strncmp(cmd, "copy ", strlen("copy ")) == 0)
- do_copy(optarg2, settings);
- else if (strncmp(cmd, "connect ", strlen("connect ")) == 0 ||
- strcmp(cmd, "connect") == 0 /* issue error message */ )
+ case 'a': /* toggles to align fields on output */
+ toggle(settings, &settings->opt.align, "field alignment");
+ break;
+ case 'C': /* define new caption */
+ if (settings->opt.caption)
+ {
+ free(settings->opt.caption);
+ settings->opt.caption = NULL;
+ }
+ if (optarg && !(settings->opt.caption = strdup(optarg)))
+ {
+ perror("malloc");
+ exit(CMD_TERMINATE);
+ }
+ break;
+ case 'c':
{
- char *optarg3 = NULL;
- int blank_loc2;
+ if (strncmp(cmd, "copy ", strlen("copy ")) == 0)
+ do_copy(optarg2, settings);
+ else if (strncmp(cmd, "connect ", strlen("connect ")) == 0 ||
+ strcmp(cmd, "connect") == 0 /* issue error message */ )
+ {
+ char *optarg3 = NULL;
+ int blank_loc2;
- if (optarg2)
+ if (optarg2)
+ {
+ blank_loc2 = strcspn(optarg2, " \t");
+ if (blank_loc2 == 0 || *(optarg2 + blank_loc2) == '\0')
+ optarg3 = NULL;
+ else
+ {
+ optarg3 = optarg2 + blank_loc2 +
+ strspn(optarg2 + blank_loc2, " \t");
+ *(optarg2 + blank_loc2) = '\0';
+ }
+ }
+ do_connect(optarg2, optarg3, settings);
+ }
+ else
{
- blank_loc2 = strcspn(optarg2, " \t");
- if (blank_loc2 == 0 || *(optarg2 + blank_loc2) == '\0')
- optarg3 = NULL;
- else
+ char *optarg3 = NULL;
+ int blank_loc2;
+
+ if (optarg)
{
- optarg3 = optarg2 + blank_loc2 +
- strspn(optarg2 + blank_loc2, " \t");
- *(optarg2 + blank_loc2) = '\0';
+ blank_loc2 = strcspn(optarg, " \t");
+ if (blank_loc2 == 0 || *(optarg + blank_loc2) == '\0')
+ optarg3 = NULL;
+ else
+ {
+ optarg3 = optarg + blank_loc2 +
+ strspn(optarg + blank_loc2, " \t");
+ *(optarg + blank_loc2) = '\0';
+ }
}
+ do_connect(optarg, optarg3, settings);
}
- do_connect(optarg2, optarg3, settings);
+ }
+ break;
+ case 'd': /* \d describe tables or columns in a
+ * table */
+ if (strncmp(cmd, "dt", 2) == 0)
+ { /* only tables */
+ tableList(settings, 0, 't');
+ }
+ else if (strncmp(cmd, "di", 2) == 0)
+ { /* only indices */
+ tableList(settings, 0, 'i');
+ }
+ else if (strncmp(cmd, "ds", 2) == 0)
+ { /* only sequences */
+ tableList(settings, 0, 'S');
+ }
+ else if (!optarg)
+ { /* show tables, sequences and indices */
+ tableList(settings, 0, 'b');
+ }
+ else if (strcmp(optarg, "*") == 0)
+ { /* show everything */
+ if (tableList(settings, 0, 'b') == 0)
+ tableList(settings, 1, 'b');
}
else
+ { /* describe the specified table */
+ tableDesc(settings, optarg);
+ }
+ break;
+ case 'e': /* edit */
+ {
+ do_edit(optarg, query, &status);
+ break;
+ }
+ case 'E':
{
- char *optarg3 = NULL;
- int blank_loc2;
+ FILE *fd;
+ static char *lastfile;
+ struct stat st,
+ st2;
if (optarg)
{
- blank_loc2 = strcspn(optarg, " \t");
- if (blank_loc2 == 0 || *(optarg + blank_loc2) == '\0')
- optarg3 = NULL;
- else
+ if (lastfile)
+ free(lastfile);
+ lastfile = malloc(strlen(optarg + 1));
+ if (!lastfile)
{
- optarg3 = optarg + blank_loc2 +
- strspn(optarg + blank_loc2, " \t");
- *(optarg + blank_loc2) = '\0';
+ perror("malloc");
+ exit(CMD_TERMINATE);
}
+ strcpy(lastfile, optarg);
}
- do_connect(optarg, optarg3, settings);
+ else if (!lastfile)
+ {
+ fprintf(stderr, "\\r must be followed by a file name initially\n");
+ break;
+ }
+ stat(lastfile, &st);
+ editFile(lastfile);
+ if ((stat(lastfile, &st2) == -1) || ((fd = fopen(lastfile, "r")) == NULL))
+ {
+ perror(lastfile);
+ break;
+ }
+ if (st2.st_mtime == st.st_mtime)
+ {
+ if (!settings->quiet)
+ fprintf(stderr, "warning: %s not modified. query not executed\n", lastfile);
+ fclose(fd);
+ break;
+ }
+ MainLoop(settings, fd);
+ fclose(fd);
+ break;
}
- }
- break;
- case 'd': /* \d describe tables or columns in a
- * table */
- if (strncmp(cmd, "dt", 2) == 0)
- { /* only tables */
- tableList(settings, 0, 't');
- }
- else if (strncmp(cmd, "di", 2) == 0)
- { /* only indices */
- tableList(settings, 0, 'i');
- }
- else if (strncmp(cmd, "ds", 2) == 0)
- { /* only sequences */
- tableList(settings, 0, 'S');
- }
- else if (!optarg)
- { /* show tables, sequences and indices */
- tableList(settings, 0, 'b');
- }
- else if (strcmp(optarg, "*") == 0)
- { /* show everything */
- if (tableList(settings, 0, 'b') == 0)
- tableList(settings, 1, 'b');
- }
- else
- { /* describe the specified table */
- tableDesc(settings, optarg);
- }
- break;
- case 'e': /* edit */
- {
- do_edit(optarg, query, &status);
- break;
- }
- case 'E':
- {
- FILE *fd;
- static char *lastfile;
- struct stat st,
- st2;
-
- if (optarg)
+ case 'f':
{
- if (lastfile)
- free(lastfile);
- lastfile = malloc(strlen(optarg + 1));
- if (!lastfile)
+ char *fs = DEFAULT_FIELD_SEP;
+
+ if (optarg)
+ fs = optarg;
+ if (settings->opt.fieldSep)
+ free(settings->opt.fieldSep);
+ if (!(settings->opt.fieldSep = strdup(fs)))
{
perror("malloc");
exit(CMD_TERMINATE);
}
- strcpy(lastfile, optarg);
+ if (!settings->quiet)
+ printf("field separator changed to '%s'\n", settings->opt.fieldSep);
+ break;
}
- else if (!lastfile)
+ case 'g': /* \g means send query */
+ if (!optarg)
+ settings->gfname = NULL;
+ else if (!(settings->gfname = strdup(optarg)))
{
- fprintf(stderr, "\\r must be followed by a file name initially\n");
- break;
+ perror("malloc");
+ exit(CMD_TERMINATE);
}
- stat(lastfile, &st);
- editFile(lastfile);
- if ((stat(lastfile, &st2) == -1) || ((fd = fopen(lastfile, "r")) == NULL))
+ status = CMD_SEND;
+ break;
+ case 'h': /* help */
{
- perror(lastfile);
+ do_help(settings, optarg);
break;
}
- if (st2.st_mtime == st.st_mtime)
+ case 'i': /* \i is include file */
{
- if (!settings->quiet)
- fprintf(stderr, "warning: %s not modified. query not executed\n", lastfile);
+ FILE *fd;
+
+ if (!optarg)
+ {
+ fprintf(stderr, "\\i must be followed by a file name\n");
+ break;
+ }
+ if ((fd = fopen(optarg, "r")) == NULL)
+ {
+ fprintf(stderr, "file named %s could not be opened\n", optarg);
+ break;
+ }
+ MainLoop(settings, fd);
fclose(fd);
break;
}
- MainLoop(settings, fd);
- fclose(fd);
+ case 'l': /* \l is list database */
+ listAllDbs(settings);
break;
- }
- case 'f':
- {
- char *fs = DEFAULT_FIELD_SEP;
-
- if (optarg)
- fs = optarg;
- if (settings->opt.fieldSep)
- free(settings->opt.fieldSep);
- if (!(settings->opt.fieldSep = strdup(fs)))
+ case 'H':
+ if (toggle(settings, &settings->opt.html3, "HTML3.0 tabular output"))
+ settings->opt.standard = 0;
+ break;
+ case 'o':
+ setFout(settings, optarg);
+ break;
+ case 'p':
+ if (query)
{
- perror("malloc");
- exit(CMD_TERMINATE);
+ fputs(query, stdout);
+ fputc('\n', stdout);
}
- if (!settings->quiet)
- printf("field separator changed to '%s'\n", settings->opt.fieldSep);
break;
- }
- case 'g': /* \g means send query */
- if (!optarg)
- settings->gfname = NULL;
- else if (!(settings->gfname = strdup(optarg)))
- {
- perror("malloc");
- exit(CMD_TERMINATE);
- }
- status = CMD_SEND;
- break;
- case 'h': /* help */
- {
- do_help(settings, optarg);
+ case 'q': /* \q is quit */
+ status = CMD_TERMINATE;
break;
- }
- case 'i': /* \i is include file */
- {
- FILE *fd;
-
+ case 'r': /* reset(clear) the buffer */
+ query[0] = '\0';
+ if (!settings->quiet)
+ printf("buffer reset(cleared)\n");
+ break;
+ case 's': /* \s is save history to a file */
if (!optarg)
+ optarg = "/dev/tty";
+#ifdef HAVE_HISTORY
+ if (write_history(optarg) != 0)
+ fprintf(stderr, "cannot write history to %s\n", optarg);
+#endif
+ break;
+ case 'm': /* monitor like type-setting */
+ if (toggle(settings, &settings->opt.standard, "standard SQL separaters and padding"))
{
- fprintf(stderr, "\\i must be followed by a file name\n");
- break;
+ settings->opt.html3 = settings->opt.expanded = 0;
+ settings->opt.align = settings->opt.header = 1;
+ if (settings->opt.fieldSep)
+ free(settings->opt.fieldSep);
+ settings->opt.fieldSep = strdup("|");
+ if (!settings->quiet)
+ printf("field separator changed to '%s'\n", settings->opt.fieldSep);
}
- if ((fd = fopen(optarg, "r")) == NULL)
+ else
{
- fprintf(stderr, "file named %s could not be opened\n", optarg);
- break;
+ if (settings->opt.fieldSep)
+ free(settings->opt.fieldSep);
+ settings->opt.fieldSep = strdup(DEFAULT_FIELD_SEP);
+ if (!settings->quiet)
+ printf("field separator changed to '%s'\n", settings->opt.fieldSep);
}
- MainLoop(settings, fd);
- fclose(fd);
break;
- }
- case 'l': /* \l is list database */
- listAllDbs(settings);
- break;
- case 'H':
- if (toggle(settings, &settings->opt.html3, "HTML3.0 tabular output"))
- settings->opt.standard = 0;
- break;
- case 'o':
- setFout(settings, optarg);
- break;
- case 'p':
- if (query)
- {
- fputs(query, stdout);
- fputc('\n', stdout);
- }
- break;
- case 'q': /* \q is quit */
- status = CMD_TERMINATE;
- break;
- case 'r': /* reset(clear) the buffer */
- query[0] = '\0';
- if (!settings->quiet)
- printf("buffer reset(cleared)\n");
- break;
- case 's': /* \s is save history to a file */
- if (!optarg)
- optarg = "/dev/tty";
-#ifdef HAVE_HISTORY
- if (write_history(optarg) != 0)
- fprintf(stderr, "cannot write history to %s\n", optarg);
-#endif
- break;
- case 'm': /* monitor like type-setting */
- if (toggle(settings, &settings->opt.standard, "standard SQL separaters and padding"))
- {
- settings->opt.html3 = settings->opt.expanded = 0;
- settings->opt.align = settings->opt.header = 1;
- if (settings->opt.fieldSep)
- free(settings->opt.fieldSep);
- settings->opt.fieldSep = strdup("|");
- if (!settings->quiet)
- printf("field separator changed to '%s'\n", settings->opt.fieldSep);
- }
- else
- {
- if (settings->opt.fieldSep)
- free(settings->opt.fieldSep);
- settings->opt.fieldSep = strdup(DEFAULT_FIELD_SEP);
- if (!settings->quiet)
- printf("field separator changed to '%s'\n", settings->opt.fieldSep);
- }
- break;
- case 'z': /* list table rights (grant/revoke) */
- rightsList(settings);
- break;
- case 't': /* toggle headers */
- toggle(settings, &settings->opt.header, "output headings and row count");
- break;
- case 'T': /* define html <table ...> option */
- if (settings->opt.tableOpt)
- free(settings->opt.tableOpt);
- if (!optarg)
- settings->opt.tableOpt = NULL;
- else if (!(settings->opt.tableOpt = strdup(optarg)))
- {
- perror("malloc");
- exit(CMD_TERMINATE);
- }
- break;
- case 'x':
- toggle(settings, &settings->opt.expanded, "expanded table representation");
- break;
- case '!':
- do_shell(optarg);
- break;
- default:
- case '?': /* \? is help */
- slashUsage(settings);
- break;
+ case 'z': /* list table rights (grant/revoke) */
+ rightsList(settings);
+ break;
+ case 't': /* toggle headers */
+ toggle(settings, &settings->opt.header, "output headings and row count");
+ break;
+ case 'T': /* define html <table ...> option */
+ if (settings->opt.tableOpt)
+ free(settings->opt.tableOpt);
+ if (!optarg)
+ settings->opt.tableOpt = NULL;
+ else if (!(settings->opt.tableOpt = strdup(optarg)))
+ {
+ perror("malloc");
+ exit(CMD_TERMINATE);
+ }
+ break;
+ case 'x':
+ toggle(settings, &settings->opt.expanded, "expanded table representation");
+ break;
+ case '!':
+ do_shell(optarg);
+ break;
+ default:
+ case '?': /* \? is help */
+ slashUsage(settings);
+ break;
}
free(cmd);
return status;
@@ -1624,13 +1622,13 @@ HandleSlashCmds(PsqlSettings * settings,
static int
MainLoop(PsqlSettings * settings, FILE * source)
{
- char *line; /* line of input */
- char *xcomment; /* start of extended comment */
- int len; /* length of the line */
- char query[MAX_QUERY_BUFFER]; /* multi-line query
+ char *line; /* line of input */
+ char *xcomment; /* start of extended comment */
+ int len; /* length of the line */
+ char query[MAX_QUERY_BUFFER]; /* multi-line query
* storage */
- int successResult = 1;
- int slashCmdStatus = CMD_SEND;
+ int successResult = 1;
+ int slashCmdStatus = CMD_SEND;
/*
* slashCmdStatus can be: CMD_UNKNOWN - send currently constructed
@@ -1641,16 +1639,16 @@ MainLoop(PsqlSettings * settings, FILE * source)
* entirely CMD_NEWEDIT - new query supplied by edit
*/
- bool querySent = false;
- bool interactive;
- READ_ROUTINE GetNextLine;
- bool eof = 0;
+ bool querySent = false;
+ bool interactive;
+ READ_ROUTINE GetNextLine;
+ bool eof = 0;
/* We've reached the end of our command input. */
- bool success;
- bool in_quote;
- int paren_level;
- char *query_start;
+ bool success;
+ bool in_quote;
+ int paren_level;
+ char *query_start;
interactive = ((source == stdin) && !settings->notty);
if (interactive)
@@ -1772,7 +1770,7 @@ MainLoop(PsqlSettings * settings, FILE * source)
}
else
{
- int i;
+ int i;
for (i = 0; i < len; i++)
{
@@ -1802,7 +1800,7 @@ MainLoop(PsqlSettings * settings, FILE * source)
}
else if (line[i] == '\\')
{
- char hold_char = line[i];
+ char hold_char = line[i];
line[i] = '\0';
if (query_start[0] != '\0')
@@ -1849,7 +1847,7 @@ MainLoop(PsqlSettings * settings, FILE * source)
}
else if (!paren_level && line[i] == ';')
{
- char hold_char = line[i + 1];
+ char hold_char = line[i + 1];
line[i + 1] = '\0';
if (query_start[0] != '\0')
@@ -1955,23 +1953,23 @@ MainLoop(PsqlSettings * settings, FILE * source)
int
main(int argc, char **argv)
{
- extern char *optarg;
- extern int optind;
+ extern char *optarg;
+ extern int optind;
- char *dbname = NULL;
- char *host = NULL;
- char *port = NULL;
- char *qfilename = NULL;
- char errbuf[ERROR_MSG_LENGTH];
+ char *dbname = NULL;
+ char *host = NULL;
+ char *port = NULL;
+ char *qfilename = NULL;
+ char errbuf[ERROR_MSG_LENGTH];
- PsqlSettings settings;
+ PsqlSettings settings;
- char *singleQuery = NULL;
+ char *singleQuery = NULL;
- bool listDatabases = 0;
- int successResult = 1;
- bool singleSlashCmd = 0;
- int c;
+ bool listDatabases = 0;
+ int successResult = 1;
+ bool singleSlashCmd = 0;
+ int c;
memset(&settings, 0, sizeof settings);
settings.opt.align = 1;
@@ -1995,73 +1993,73 @@ main(int argc, char **argv)
{
switch (c)
{
- case 'A':
- settings.opt.align = 0;
- break;
- case 'a':
- fe_setauthsvc(optarg, errbuf);
- break;
- case 'c':
- singleQuery = strdup(optarg);
- if (singleQuery[0] == '\\')
- {
- singleSlashCmd = 1;
- }
- break;
- case 'd':
- dbname = optarg;
- break;
- case 'e':
- settings.echoQuery = 1;
- break;
- case 'f':
- qfilename = optarg;
- break;
- case 'F':
- settings.opt.fieldSep = strdup(optarg);
- break;
- case 'l':
- listDatabases = 1;
- break;
- case 'h':
- host = optarg;
- break;
- case 'H':
- settings.opt.html3 = 1;
- break;
- case 'n':
- settings.useReadline = 0;
- break;
- case 'o':
- setFout(&settings, optarg);
- break;
- case 'p':
- port = optarg;
- break;
- case 'q':
- settings.quiet = 1;
- break;
- case 's':
- settings.singleStep = 1;
- break;
- case 'S':
- settings.singleLineMode = 1;
- break;
- case 't':
- settings.opt.header = 0;
- break;
- case 'T':
- settings.opt.tableOpt = strdup(optarg);
- break;
- case 'u':
- settings.getPassword = 1;
- break;
- case 'x':
- settings.opt.expanded = 1;
- break;
- default:
- usage(argv[0]);
- break;
+ case 'A':
+ settings.opt.align = 0;
+ break;
+ case 'a':
+ fe_setauthsvc(optarg, errbuf);
+ break;
+ case 'c':
+ singleQuery = strdup(optarg);
+ if (singleQuery[0] == '\\')
+ {
+ singleSlashCmd = 1;
+ }
+ break;
+ case 'd':
+ dbname = optarg;
+ break;
+ case 'e':
+ settings.echoQuery = 1;
+ break;
+ case 'f':
+ qfilename = optarg;
+ break;
+ case 'F':
+ settings.opt.fieldSep = strdup(optarg);
+ break;
+ case 'l':
+ listDatabases = 1;
+ break;
+ case 'h':
+ host = optarg;
+ break;
+ case 'H':
+ settings.opt.html3 = 1;
+ break;
+ case 'n':
+ settings.useReadline = 0;
+ break;
+ case 'o':
+ setFout(&settings, optarg);
+ break;
+ case 'p':
+ port = optarg;
+ break;
+ case 'q':
+ settings.quiet = 1;
+ break;
+ case 's':
+ settings.singleStep = 1;
+ break;
+ case 'S':
+ settings.singleLineMode = 1;
+ break;
+ case 't':
+ settings.opt.header = 0;
+ break;
+ case 'T':
+ settings.opt.tableOpt = strdup(optarg);
+ break;
+ case 'u':
+ settings.getPassword = 1;
+ break;
+ case 'x':
+ settings.opt.expanded = 1;
+ break;
+ default:
+ usage(argv[0]);
+ break;
}
}
/* if we still have an argument, use it as the database name */
@@ -2073,9 +2071,9 @@ main(int argc, char **argv)
if (settings.getPassword)
{
- char username[9];
- char password[9];
- char *connect_string;
+ char username[9];
+ char password[9];
+ char *connect_string;
prompt_for_password(username, password);
@@ -2119,7 +2117,7 @@ main(int argc, char **argv)
* read in a file full of queries instead of reading in queries
* interactively
*/
- char *line;
+ char *line;
if (singleSlashCmd)
{
@@ -2138,8 +2136,7 @@ main(int argc, char **argv)
{
if (singleQuery)
{
- bool success; /* The query succeeded at the
- * backend */
+ bool success;/* The query succeeded at the backend */
SendQuery(&success, &settings, singleQuery, false, false, 0);
successResult = success;
@@ -2161,9 +2158,9 @@ main(int argc, char **argv)
static void
handleCopyOut(PGresult * res, bool quiet, FILE * copystream)
{
- bool copydone;
- char copybuf[COPYBUFSIZ];
- int ret;
+ bool copydone;
+ char copybuf[COPYBUFSIZ];
+ int ret;
copydone = false; /* Can't be done; haven't started. */
@@ -2182,14 +2179,14 @@ handleCopyOut(PGresult * res, bool quiet, FILE * copystream)
fputs(copybuf, copystream);
switch (ret)
{
- case EOF:
- copydone = true;
- /* FALLTHROUGH */
- case 0:
- fputc('\n', copystream);
- break;
- case 1:
- break;
+ case EOF:
+ copydone = true;
+ /* FALLTHROUGH */
+ case 0:
+ fputc('\n', copystream);
+ break;
+ case 1:
+ break;
}
}
}
@@ -2202,13 +2199,13 @@ handleCopyOut(PGresult * res, bool quiet, FILE * copystream)
static void
handleCopyIn(PGresult * res, const bool mustprompt, FILE * copystream)
{
- bool copydone = false;
- bool firstload;
- bool linedone;
- char copybuf[COPYBUFSIZ];
- char *s;
- int buflen;
- int c;
+ bool copydone = false;
+ bool firstload;
+ bool linedone;
+ char copybuf[COPYBUFSIZ];
+ char *s;
+ int buflen;
+ int c;
if (mustprompt)
{
@@ -2263,7 +2260,7 @@ handleCopyIn(PGresult * res, const bool mustprompt, FILE * copystream)
* try to open fname and return a FILE *, if it fails, use stdout, instead
*/
-static FILE *
+static FILE *
setFout(PsqlSettings * ps, char *fname)
{
if (ps->queryFout && ps->queryFout != stdout)
@@ -2304,11 +2301,11 @@ setFout(PsqlSettings * ps, char *fname)
static void
prompt_for_password(char *username, char *password)
{
- int length;
+ int length;
#ifdef HAVE_TERMIOS_H
- struct termios t_orig,
- t;
+ struct termios t_orig,
+ t;
#endif
@@ -2318,7 +2315,7 @@ prompt_for_password(char *username, char *password)
/* skip rest of the line */
if (length > 0 && username[length - 1] != '\n')
{
- static char buf[512];
+ static char buf[512];
do
{
@@ -2344,7 +2341,7 @@ prompt_for_password(char *username, char *password)
/* skip rest of the line */
if (length > 0 && password[length - 1] != '\n')
{
- static char buf[512];
+ static char buf[512];
do
{
@@ -2357,12 +2354,12 @@ prompt_for_password(char *username, char *password)
printf("\n\n");
}
-static char *
+static char *
make_connect_string(char *host, char *port, char *dbname,
char *username, char *password)
{
- int connect_string_len = 0;
- char *connect_string;
+ int connect_string_len = 0;
+ char *connect_string;
if (host)
connect_string_len += 6 + strlen(host); /* 6 == "host=" + " " */
diff --git a/src/bin/psql/psqlHelp.h b/src/bin/psql/psqlHelp.h
index f9f372a8ad..abc00b33f9 100644
--- a/src/bin/psql/psqlHelp.h
+++ b/src/bin/psql/psqlHelp.h
@@ -5,16 +5,16 @@
*
* Copyright (c) 1994, Regents of the University of California
*
- * $Id: psqlHelp.h,v 1.23 1997/09/07 04:55:23 momjian Exp $
+ * $Id: psqlHelp.h,v 1.24 1997/09/08 02:33:43 momjian Exp $
*
*-------------------------------------------------------------------------
*/
struct _helpStruct
{
- char *cmd; /* the command name */
- char *help; /* the help associated with it */
- char *syntax; /* the syntax associated with it */
+ char *cmd; /* the command name */
+ char *help; /* the help associated with it */
+ char *syntax; /* the syntax associated with it */
};
static struct _helpStruct QL_HELP[] = {
diff --git a/src/bin/psql/stringutils.c b/src/bin/psql/stringutils.c
index cf34622209..a868be9ddd 100644
--- a/src/bin/psql/stringutils.c
+++ b/src/bin/psql/stringutils.c
@@ -7,7 +7,7 @@
*
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/bin/psql/stringutils.c,v 1.11 1997/09/07 04:55:27 momjian Exp $
+ * $Header: /cvsroot/pgsql/src/bin/psql/stringutils.c,v 1.12 1997/09/08 02:33:45 momjian Exp $
*
*-------------------------------------------------------------------------
*/
@@ -30,12 +30,12 @@
/* MODIFIES the string passed in and returns the head of it */
#ifdef NOT_USED
-static char *
+static char *
leftTrim(char *s)
{
- char *s2 = s;
- int shift = 0;
- int j = 0;
+ char *s2 = s;
+ int shift = 0;
+ int j = 0;
while (isspace(*s))
{
@@ -53,10 +53,10 @@ leftTrim(char *s)
#endif
-char *
+char *
rightTrim(char *s)
{
- char *sEnd;
+ char *sEnd;
sEnd = s + strlen(s) - 1;
while (sEnd >= s && isspace(*sEnd))
@@ -69,7 +69,7 @@ rightTrim(char *s)
}
#ifdef NOT_USED
-static char *
+static char *
doubleTrim(char *s)
{
strcpy(s, leftTrim(rightTrim(s)));
@@ -82,18 +82,18 @@ doubleTrim(char *s)
void
testStringUtils()
{
- static char *tests[] = {" goodbye \n", /* space on both ends */
+ static char *tests[] = {" goodbye \n", /* space on both ends */
"hello world", /* no spaces to trim */
"", /* empty string */
"a", /* string with one char */
" ", /* string with one whitespace */
NULL_STR};
- int i = 0;
+ int i = 0;
while (tests[i] != NULL_STR)
{
- char *t;
+ char *t;
t = strdup(tests[i]);
printf("leftTrim(%s) = ", t);
diff --git a/src/bin/psql/stringutils.h b/src/bin/psql/stringutils.h
index 2bc8795f4c..79669d3452 100644
--- a/src/bin/psql/stringutils.h
+++ b/src/bin/psql/stringutils.h
@@ -5,7 +5,7 @@
*
* Copyright (c) 1994, Regents of the University of California
*
- * $Id: stringutils.h,v 1.5 1997/09/07 04:55:32 momjian Exp $
+ * $Id: stringutils.h,v 1.6 1997/09/08 02:33:46 momjian Exp $
*
*-------------------------------------------------------------------------
*/
@@ -27,10 +27,10 @@
/* removes whitespaces from the left, right and both sides of a string */
/* MODIFIES the string passed in and returns the head of it */
-extern char *rightTrim(char *s);
+extern char *rightTrim(char *s);
#ifdef STRINGUTILS_TEST
-extern void testStringUtils();
+extern void testStringUtils();
#endif