Commit 72f76d38 authored by Marc G. Fournier's avatar Marc G. Fournier

libpq and psql.c have been modified to do various things they didn't do

before (plus some optimisations/bug fixes et al).  I've included a small
demo transcript below. Note that all of of the display
functionality/intelligence you see here, can be had merely by calling
the new LIBPQ PQprint() routine with the appropriate arguments/options,
including the HTML3 output guff.


submitted by:  Julian Assange <proff@suburbia.net>
parent bc0bd47c
......@@ -7,7 +7,7 @@
*
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/bin/monitor/Attic/monitor.c,v 1.1.1.1 1996/07/09 06:22:13 scrappy Exp $
* $Header: /cvsroot/pgsql/src/bin/monitor/Attic/monitor.c,v 1.2 1996/07/18 05:48:34 scrappy Exp $
*
*-------------------------------------------------------------------------
*/
......@@ -642,6 +642,7 @@ handle_execution(char *query)
{
PGresult *result;
int retval = 0;
PQprintOpt opt;
result = PQexec(conn, query);
......@@ -657,10 +658,17 @@ handle_execution(char *query)
break;
case PGRES_TUPLES_OK:
/* PQprintTuples(result,stdout,PrintAttNames,TerseOutput,COLWIDTH); */
if (TerseOutput)
/* if (TerseOutput)
PQdisplayTuples(result,stdout,1,"",PrintAttNames,TerseOutput);
else
PQdisplayTuples(result,stdout,1,"|",PrintAttNames,TerseOutput);
PQdisplayTuples(result,stdout,1,"|",PrintAttNames,TerseOutput); */
memset(&opt, 0, sizeof opt);
opt.header = opt.align = opt.standard = 1;
if (TerseOutput)
opt.fieldSep = "";
else
opt.fieldSep = "|";
PQprint(stdout, result, &opt);
break;
case PGRES_COPY_OUT:
handle_copy_out(result);
......
This diff is collapsed.
This diff is collapsed.
......@@ -6,7 +6,7 @@
*
* Copyright (c) 1994, Regents of the University of California
*
* $Id: libpq-fe.h,v 1.1.1.1 1996/07/09 06:22:17 scrappy Exp $
* $Id: libpq-fe.h,v 1.2 1996/07/18 05:48:57 scrappy Exp $
*
*-------------------------------------------------------------------------
*/
......@@ -127,6 +127,17 @@ typedef struct pg_result{
PGconn* conn;
} PGresult;
typedef struct _PQprintOpt {
bool header; /* print output field headers or not */
bool align; /* fill align the fields */
bool standard; /* old brain dead format */
bool html3; /* output html tables */
bool expanded; /* expand tables */
char *fieldSep; /* field separator */
char *tableOpt; /* insert to HTML <table ...> */
char *caption; /* HTML <caption> */
char **fieldName; /* null terminated array of repalcement field names */
} PQprintOpt;
/* === in fe-connect.c === */
/* make a new client connection to the backend */
......@@ -165,13 +176,6 @@ extern char* PQoidStatus(PGresult *res);
extern char* PQgetvalue(PGresult *res, int tup_num, int field_num);
extern int PQgetlength(PGresult *res, int tup_num, int field_num);
extern void PQclear(PGresult* res);
/* PQdisplayTuples() is a better version of PQprintTuples() */
extern void PQdisplayTuples(PGresult *res,
FILE *fp, /* where to send the output */
int fillAlign, /* pad the fields with spaces */
char *fieldSep, /* field separator */
int printHeader, /* display headers? */
int quiet);
extern void PQprintTuples(PGresult* res,
FILE* fout, /* output stream */
int printAttName,/* print attribute names or not*/
......@@ -179,6 +183,10 @@ extern void PQprintTuples(PGresult* res,
int width /* width of column,
if 0, use variable width */
);
extern void PQprint(FILE* fout, /* output stream */
PGresult* res,
PQprintOpt *ps /* option structure */
);
extern PGnotify* PQnotifies(PGconn *conn);
extern PGresult* PQfn(PGconn* conn,
int fnid,
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment