aboutsummaryrefslogtreecommitdiff
path: root/src/bin/psql/startup.c
diff options
context:
space:
mode:
authorTom Lane <tgl@sss.pgh.pa.us>2006-08-29 22:25:08 +0000
committerTom Lane <tgl@sss.pgh.pa.us>2006-08-29 22:25:08 +0000
commitc2f60711d25b256dbe2c1ddce833c5c69ca051cc (patch)
tree37f805b925c2d8827d27e9930351cf778fdc9afb /src/bin/psql/startup.c
parent7c5ac5ce2234688a1048d4c26d9fa7cabeaa004f (diff)
downloadpostgresql-c2f60711d25b256dbe2c1ddce833c5c69ca051cc.tar.gz
postgresql-c2f60711d25b256dbe2c1ddce833c5c69ca051cc.zip
Create a FETCH_COUNT parameter that causes psql to execute SELECT-like
queries via a cursor, fetching a limited number of rows at a time and therefore not risking exhausting memory. A disadvantage of the scheme is that 'aligned' output mode will align each group of rows independently leading to odd-looking output, but all the other output formats work reasonably well. Chris Mair, with some additional hacking by moi.
Diffstat (limited to 'src/bin/psql/startup.c')
-rw-r--r--src/bin/psql/startup.c11
1 files changed, 10 insertions, 1 deletions
diff --git a/src/bin/psql/startup.c b/src/bin/psql/startup.c
index 8d3409bd194..6cbd95da9ed 100644
--- a/src/bin/psql/startup.c
+++ b/src/bin/psql/startup.c
@@ -3,7 +3,7 @@
*
* Copyright (c) 2000-2006, PostgreSQL Global Development Group
*
- * $PostgreSQL: pgsql/src/bin/psql/startup.c,v 1.136 2006/08/29 15:19:51 tgl Exp $
+ * $PostgreSQL: pgsql/src/bin/psql/startup.c,v 1.137 2006/08/29 22:25:08 tgl Exp $
*/
#include "postgres_fe.h"
@@ -145,6 +145,8 @@ main(int argc, char *argv[])
pset.popt.topt.format = PRINT_ALIGNED;
pset.popt.topt.border = 1;
pset.popt.topt.pager = 1;
+ pset.popt.topt.start_table = true;
+ pset.popt.topt.stop_table = true;
pset.popt.default_footer = true;
pset.notty = (!isatty(fileno(stdin)) || !isatty(fileno(stdout)));
@@ -799,6 +801,12 @@ singlestep_hook(const char *newval)
}
static void
+fetch_count_hook(const char *newval)
+{
+ pset.fetch_count = ParseVariableNum(newval, -1, -1, false);
+}
+
+static void
echo_hook(const char *newval)
{
if (newval == NULL)
@@ -899,6 +907,7 @@ EstablishVariableSpace(void)
SetVariableAssignHook(pset.vars, "QUIET", quiet_hook);
SetVariableAssignHook(pset.vars, "SINGLELINE", singleline_hook);
SetVariableAssignHook(pset.vars, "SINGLESTEP", singlestep_hook);
+ SetVariableAssignHook(pset.vars, "FETCH_COUNT", fetch_count_hook);
SetVariableAssignHook(pset.vars, "ECHO", echo_hook);
SetVariableAssignHook(pset.vars, "ECHO_HIDDEN", echo_hidden_hook);
SetVariableAssignHook(pset.vars, "ON_ERROR_ROLLBACK", on_error_rollback_hook);