File: psql.rb

# psql.rb

Path: | sample/psql.rb
Last Update: | Sat Mar 10 09:20:45 -0700 2007

an interactive front-end to postgreSQL

Original source code is written by C.

     Copyright (c) 1996, Regents of the University of California

ruby version is written by ematsu

     Copyright (c) 1997  Eiji-usagi-MATSUmoto <ematsu@pfu.co.jp>

Changes:

     Fri 12 Dec 19:56:34 JST 1997
     * replace puts -> print

$Id: psql.rb,v 1.1.1.3 2002/04/24 05:46:44 noboru Exp $

### Required files

postgres parsearg.rb psqlHelp.rb readline

### Methods

HandleSlashCmds MainLoop PSQLexec SendQuery do_connect do_copy do_edit do_help do_shell editFile gets handleCopyIn handleCopyOut listAllDbs main on setFout slashUsage tableDesc tableList toggle unescape usage

### Constants

PROMPT | = | "=> "
MAX_QUERY_BUFFER | = | 20000
DEFAULT_SHELL | = | "/bin/sh"
DEFAULT_EDITOR | = | "vi"
DEFAULT_FIELD_SEP | = | "|"
PsqlSettings | = | Struct.new("PsqlSettings", :db, :queryFout, :opt, :prompt, :gfname, :notty,:pipe, :echoQuery,:quiet, :singleStep, :singleLineMode, :useReadline)
PrintOpt | = | Struct.new("PrintOpt", :header, :align, :standard, :html3, :expanded, :pager, :fieldSep, :tableOpt, :caption, :fieldName)

### Public Instance methods

HandleSlashCmds(settings, line, query)
MainLoop(settings, source)
PSQLexec(ps, query)
SendQuery(settings, query, copy_in, copy_out, copystream)
do_connect(settings, new_dbname)
do_copy(settings, table, from_p, file)
do_edit(filename_arg, query)
do_help(topic)
do_shell(command)
editFile(fname)
gets(prompt, source)
handleCopyIn(settings, mustprompt, copystream)
handleCopyOut(settings, copystream)
listAllDbs(ps)
main()
on(f)
setFout(ps, fname)
slashUsage(ps)
tableDesc(ps, table)
tableList(ps, deep_tablelist, info_type, system_tables)
toggle(settings, sw, msg)
unescape(source)
usage()

[Validate]