From f71d0cf64ebd53fc277adddfd81c9913badb92ba Mon Sep 17 00:00:00 2001 From: Bruce Momjian Date: Thu, 3 Sep 1998 02:10:56 +0000 Subject: Attached is a patch to remove the definitions of libpq's internal structs from libpq-fe.h, as we previously discussed. There turned out to be sloppy coding practices in more places than I had realized :-(, but all in all I think it was a well-worth-while exercise. I ended up adding several routines to libpq's API in order to respond to application requirements that were exposed by this work. I owe the docs crew updates for libpq.sgml to describe these changes. I'm way too tired to work on the docs tonight, however. This is the last major change I intend to submit for 6.4. I do want to see if I can make libpgtcl work with Tcl 8.0 before we go final, but hopefully that will be a minor bug fix. --- src/bin/pg_dump/pg_dump.c | 6 +++--- src/bin/psql/psql.c | 35 ++++++++++++++++------------------- 2 files changed, 19 insertions(+), 22 deletions(-) (limited to 'src/bin') diff --git a/src/bin/pg_dump/pg_dump.c b/src/bin/pg_dump/pg_dump.c index d9c5ec1a006..746f2af2166 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.83 1998/09/01 04:33:45 momjian Exp $ + * $Header: /cvsroot/pgsql/src/bin/pg_dump/pg_dump.c,v 1.84 1998/09/03 02:10:36 momjian Exp $ * * Modifications - 6/10/96 - dave@bensoft.com - version 1.13.dhb * @@ -255,7 +255,7 @@ dumpClasses_nodumpData(FILE *fout, const char *classname, const bool oids) copydone = false; while (!copydone) { - ret = PQgetline(res->conn, copybuf, COPYBUFSIZ); + ret = PQgetline(g_conn, copybuf, COPYBUFSIZ); if (copybuf[0] == '\\' && copybuf[1] == '.' && @@ -281,7 +281,7 @@ dumpClasses_nodumpData(FILE *fout, const char *classname, const bool oids) } fprintf(fout, "\\.\n"); } - ret = PQendcopy(res->conn); + ret = PQendcopy(g_conn); if (ret != 0) { fprintf(stderr, "SQL query to dump the contents of Table '%s' " diff --git a/src/bin/psql/psql.c b/src/bin/psql/psql.c index ecb441fbc78..054faab480a 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.158 1998/09/01 04:33:51 momjian Exp $ + * $Header: /cvsroot/pgsql/src/bin/psql/Attic/psql.c,v 1.159 1998/09/03 02:10:38 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -148,7 +148,7 @@ struct winsize /* declarations for functions in this file */ static void usage(char *progname); static void slashUsage(); -static bool handleCopyOut(PGresult *res, FILE *copystream); +static bool handleCopyOut(PGconn *conn, FILE *copystream); static bool handleCopyIn(PGresult *res, const bool mustprompt, FILE *copystream); static int tableList(PsqlSettings *pset, bool deep_tablelist, @@ -1125,20 +1125,20 @@ SendQuery(bool *success_p, PsqlSettings *pset, const char *query, break; case PGRES_COPY_OUT: if (copy_out) - *success_p = handleCopyOut(results, copystream); + *success_p = handleCopyOut(pset->db, copystream); else { if (!pset->quiet) printf("Copy command returns...\n"); - *success_p = handleCopyOut(results, stdout); + *success_p = handleCopyOut(pset->db, stdout); } break; case PGRES_COPY_IN: if (copy_in) - *success_p = handleCopyIn(results, false, copystream); + *success_p = handleCopyIn(pset->db, false, copystream); else - *success_p = handleCopyIn(results, + *success_p = handleCopyIn(pset->db, !pset->quiet && !pset->notty, stdin); break; @@ -1437,11 +1437,8 @@ do_connect(const char *new_dbname, else userparam = PQuser(olddb); - /* - * libpq doesn't provide an accessor function for the password, so - * we cheat here. - */ - pwparam = olddb->pgpass; + /* FIXME: if changing user, ought to prompt for a new password? */ + pwparam = PQpass(olddb); pset->db = PQsetdbLogin(PQhost(olddb), PQport(olddb), NULL, NULL, dbparam, userparam, pwparam); @@ -2915,7 +2912,7 @@ main(int argc, char **argv) #define COPYBUFSIZ 8192 static bool -handleCopyOut(PGresult *res, FILE *copystream) +handleCopyOut(PGconn *conn, FILE *copystream) { bool copydone; char copybuf[COPYBUFSIZ]; @@ -2925,7 +2922,7 @@ handleCopyOut(PGresult *res, FILE *copystream) while (!copydone) { - ret = PQgetline(res->conn, copybuf, COPYBUFSIZ); + ret = PQgetline(conn, copybuf, COPYBUFSIZ); if (copybuf[0] == '\\' && copybuf[1] == '.' && @@ -2950,13 +2947,13 @@ handleCopyOut(PGresult *res, FILE *copystream) } } fflush(copystream); - return !PQendcopy(res->conn); + return ! PQendcopy(conn); } static bool -handleCopyIn(PGresult *res, const bool mustprompt, FILE *copystream) +handleCopyIn(PGconn *conn, const bool mustprompt, FILE *copystream) { bool copydone = false; bool firstload; @@ -2991,12 +2988,12 @@ handleCopyIn(PGresult *res, const bool mustprompt, FILE *copystream) *s++ = c; if (c == EOF) { - PQputline(res->conn, "\\."); + PQputline(conn, "\\."); copydone = true; break; } *s = '\0'; - PQputline(res->conn, copybuf); + PQputline(conn, copybuf); if (firstload) { if (!strcmp(copybuf, "\\.")) @@ -3004,9 +3001,9 @@ handleCopyIn(PGresult *res, const bool mustprompt, FILE *copystream) firstload = false; } } - PQputline(res->conn, "\n"); + PQputline(conn, "\n"); } - return !PQendcopy(res->conn); + return ! PQendcopy(conn); } -- cgit v1.2.3