Commit Graph

94 Commits

Author SHA1 Message Date
Bruce Momjian add932ee91 I'm continuing to work on cleaning up code in psql. As things appear
now, my changes seem to work.  Some possible minor bugs got squished
on the way but I can't be sure without more feedback from people who
really put the code to the test.

The new patch mostly simplifies variable handling and reduces code
duplication.  Changes in the command parser eliminate some redundant
variables (boolean state + depth counter), replaces some
"else if" constructs with switches, and so on.  It is meant to be
applied together with my previous patch, although I hope they don't
conflict; I went back to the CVS version for this one.

One more thing I thought should perhaps be changed: an IGNOREEOF
value of n will ignore only n-1 EOFs.  I didn't want to touch this
for fear of breaking existing applications, but it does seem a tad
illogical.

Jeroen T. Vermeulen
2003-03-20 06:43:35 +00:00
Bruce Momjian ddd50a0bab This patch fixes a very small memory leak in psql, spotted with
valgrind.

Neil Conway
2003-03-19 22:49:43 +00:00
Peter Eisentraut cf1cf89649 Make the printing code somewhat more independent by not relying on
functions and global variables from the rest of psql.  Also clean up some
data type mismatches created by the last pager patch.
2003-03-18 22:15:44 +00:00
Bruce Momjian 51b2b6433b Cleanup up psql \connect and \pset pager setting display, Dennis
Bj?rklund.
2003-03-10 15:46:03 +00:00
Bruce Momjian adc3b34b9c Here's the patch I promised over on HACKERS - it alters the
implementation
of '\e' history tracking for systems that have a readline compatability
library without replace_history_entry.  I fall back to pushing the query
onto the history stack after the \e, rather than replacing it.

The patch adds one more place to look for readline headers, and a test
for replace_history_entry. I've only included the patch for configure.in

Ross J. Reedstrom
2003-02-19 04:04:04 +00:00
Bruce Momjian 6d8b8a5e4d [ Have readline save edit history.]
>
> > I already posted a one-line patch to implement this, but it doesn't
> > seem to hve come through to the list. Here it is inline, instead of as
> > an attachment:
>
> We need this to work without readline as well.  (Of course there won't be
> any history, but it needs to compile.)

<blush> Even after slogging my way through the nesting #ifdefs for readline
and win32, I forgot! Let's make that a three line patch, then.

Ross J. Reedstrom
2003-02-13 04:08:16 +00:00
Peter Eisentraut b7ca9bdf18 Do not shell-quote the name of the editor, so that the editor can be a
command with arguments.
2003-01-10 21:57:44 +00:00
Tom Lane b4b62cff93 Apply the proper version of Christopher Kings-Lynne's describe patch
(ie, the one with describe-schema support).  Minor code review.
Adjust display of casts to use standard type names.
2003-01-07 20:56:07 +00:00
Bruce Momjian 40c4472e22 TODO marked as done:
* Add schema, cast, and conversion backslash commands to psql

I had to create a new publically available function,
pg_conversion_is_visible, as it seemed to be missing from the catalogs.
This required me to do no small amount of hacking around in namespace.c

I have updated the \? help and sgml docs.

\dc - list conversions [PATTERN]
\dC - list casts
\dn list schemas

I didn't support patterns with casts as there's nothing obvious to match
against.

Catalog version incremented --- initdb required.

Christopher Kings-Lynne
2002-12-12 21:02:25 +00:00
Bruce Momjian b26dfbb0e3 Here is a patch that does just that, while maintaining the
"traditional" behavior, so the change should be transparent. Use the
command "\pset pager always" to turn it on. Anything else does the
normal toggle between "on" and "off"

Greg Sabino Mullane
2002-11-08 19:12:21 +00:00
Bruce Momjian 641b658c26 Page \h output and centralize psql paging code in PageOutput(). 2002-10-23 19:23:57 +00:00
Tom Lane 951ec872c7 Fix psql to cope with autocommit off, at least during startup.
Behavior of backslash commands (especially for large objects)
may still require some thought.
2002-10-15 02:24:16 +00:00
Bruce Momjian a0bf2503ea The attached patch fixes a number of issues related to compiling the
client
utilities (libpq.dll and psql.exe) for win32 (missing defines,
adjustments to
includes, pedantic casting, non-existent functions) per:
   http://developer.postgresql.org/docs/postgres/install-win32.html.

It compiles cleanly under Windows 2000 using Visual Studio .net. Also
compiles clean and passes all regression tests (regular and contrib)
under Linux.

In addition to a review by the usual suspects, it would be very
desirable for  someone well versed in the peculiarities of win32 to take
a look.

Joe Conway
2002-10-03 17:09:42 +00:00
Peter Eisentraut 2972fd5d83 Translation updates, some messages tweaked. 2002-09-22 20:57:21 +00:00
Bruce Momjian e50f52a074 pgindent run. 2002-09-04 20:31:48 +00:00
Bruce Momjian a12b4e279b I checked all the previous string handling errors and most of them were
already fixed by You. However there were a few left and attached patch
should fix the rest of them.

I used StringInfo only in 2 places and both of them are inside debug
ifdefs. Only performance penalty will come from using strlen() like all
the other code does.

I also modified some of the already patched parts by changing
snprintf(buf, 2 * BUFSIZE, ... style lines to
snprintf(buf, sizeof(buf), ... where buf is an array.

Jukka Holappa
2002-09-02 06:11:43 +00:00
Bruce Momjian dec918479f I guess I'd vote for changing the code to be
sys = malloc(strlen(editorName) + strlen(fname) + 10 + 1);
        if (!sys)
                return false;
        sprintf(sys, "exec '%s' '%s'", editorName, fname);

(note the added quotes to provide a little protection against spaces
and such).  Then it's perfectly obvious what the calculation is doing.
I don't care about wasting 20-some bytes, but confusing readers of the
code is worth avoiding.

                        regards, tom lane
2002-08-14 05:49:22 +00:00
Bruce Momjian c028c2a703 Put back old code. 2002-08-13 21:04:36 +00:00
Bruce Momjian 46bb23ac01 Change NAMEDATALEN to 64, INDEX_MAX_KEYS/MAX_FUNC_ARGS to 32, per discussion on hackers. 2002-08-13 20:40:44 +00:00
Tom Lane 039cb47988 psql backslash commands are schema-aware. Pattern matching behavior
follows recent pghackers discussion.  This commit includes all the
relevant fixes from Greg Mullane's patch of 24-June.
2002-08-10 03:56:24 +00:00
Tatsuo Ishii eb335a034b I have committed many support files for CREATE CONVERSION. Default
conversion procs and conversions are added in initdb. Currently
supported conversions are:

UTF-8(UNICODE) <--> SQL_ASCII, ISO-8859-1 to 16, EUC_JP, EUC_KR,
		    EUC_CN, EUC_TW, SJIS, BIG5, GBK, GB18030, UHC,
		    JOHAB, TCVN

EUC_JP <--> SJIS
EUC_TW <--> BIG5
MULE_INTERNAL <--> EUC_JP, SJIS, EUC_TW, BIG5

Note that initial contents of pg_conversion system catalog are created
in the initdb process. So doing initdb required is ideal, it's
possible to add them to your databases by hand, however. To accomplish
this:

psql -f your_postgresql_install_path/share/conversion_create.sql your_database

So I did not bump up the version in cataversion.h.

TODO:
Add more conversion procs
Add [CASCADE|RESTRICT] to DROP CONVERSION
Add tuples to pg_depend
Add regression tests
Write docs
Add SQL99 CONVERT command?
--
Tatsuo Ishii
2002-07-18 02:02:30 +00:00
Bruce Momjian 91dfa1af97 Fix \? and \pset pager handling. \? wasn't honoring pager before. 2002-07-15 01:56:25 +00:00
Peter Eisentraut 3d726290c0 Remove traces of NAMEDATALEN and INDEX_MAX_KEYS from psql. Build buffers
dynamically with PQExpBuffer.
2002-04-24 05:24:00 +00:00
Peter Eisentraut d235d9b8a3 Reset parenthesis level counter upon \r. 2002-03-27 19:16:13 +00:00
Bruce Momjian a7ade2bb6b Add psql \dD listing of domains, from Jonathan Eisler. 2002-03-19 02:32:21 +00:00
Bruce Momjian 7d1b8fe716 Back out psql domain improvements until domain is applied. 2002-03-07 17:54:42 +00:00
Bruce Momjian c666d6fd41 Here is a diff of changes to the psql source code implementing a simple
'list domains' command '\dD'. This is the interface component of
rbt@zort.ca's domain backend modifications.

Jonathan Eisler
2002-03-06 20:39:45 +00:00
Bruce Momjian 25b0b09fd3 Add \timing patch to psql. Times all queries.
Greg Sabino Mullane
2002-03-05 00:01:03 +00:00
Tom Lane 86a07143d4 Tweak psql's \connect command to not downcase unquoted database and user
names.  This is a temporary measure to allow backwards compatibility with
7.2 and earlier pg_dump.  7.2.1 and later pg_dump will double-quote mixed
case names in \connect.  Once we feel that older dumps are not a problem
anymore, we can revert this change and treat \connect arguments as normal
SQL identifiers.
2002-02-25 21:37:42 +00:00
Tom Lane a40c17e17d Fix comment. 2002-02-20 22:47:12 +00:00
Tom Lane 3dfe80243c Add missing 'else', per report from sugita@sra.co.jp. 2002-01-18 16:14:54 +00:00
Bruce Momjian ea08e6cd55 New pgindent run with fixes suggested by Tom. Patch manually reviewed,
initdb/regression tests pass.
2001-11-05 17:46:40 +00:00
Bruce Momjian 6783b2372e Another pgindent run. Fixes enum indenting, and improves #endif
spacing.  Also adds space for one-line comments.
2001-10-28 06:26:15 +00:00
Bruce Momjian b81844b173 pgindent run on all C files. Java run to follow. initdb/regression
tests pass.
2001-10-25 05:50:21 +00:00
Bruce Momjian 78f7ba13cb Tatsuo Ishii <t-ishii@sra.co.jp> writes:
> As you can see, psql reconnect as any user if the password is same as
> foo. Of course this is due to the careless password setting, but I
> think it's better to prompt ANY TIME the user tries to switch to
> another user. Comments?

Yeah, I agree.  Looks like a simple change in dbconnect():

    /*
     * Use old password if no new one given (if you didn't have an old
     * one, fine)
     */
    if (!pwparam && oldconn)
        pwparam = PQpass(oldconn);

to

    /*
     * Use old password (if any) if no new one given and we are
     * reconnecting as same user
     */
    if (!pwparam && oldconn && PQuser(oldconn) && userparam &&
        strcmp(PQuser(oldconn), userparam) == 0)
        pwparam = PQpass(oldconn);

                        regards, tom lane
2001-10-11 16:54:18 +00:00
Bruce Momjian 453ef3f81f Attached is the updated version of the patch, which matches
on words as opposed to lines, which means that all of the
following work in psql:

\d foo \d bar
\d foo; \d bar
\d foo \d bar;;
\d foo; <space>


This one also uses "true and false" and strips semicolons
for the following backslash commands: \C \c \d \e \i \o \s \z

Greg Sabino Mullane
2001-10-05 19:01:13 +00:00
Bruce Momjian be18a49d39 > NOTE: in the command.c in three places there (I believe) is a typo:
>
> "parse error at [the] end of line"
>
> Attached patch also fixes it. I noticed this while editing the po file.
> If I'm wrong, please ignore the command.c.patch. I will revert my translation
> as well then.
>
> --
> Serguei A. Mokhov
2001-09-10 14:51:33 +00:00
Peter Eisentraut daac2d0ce3 Parse the arguments of \connect as SQL identifiers, so that they expose
the expected behavior in mixed-case situations.

bug report from James Pattie, 2001-08-31
2001-09-02 23:52:19 +00:00
Peter Eisentraut 0acd843c05 Finish German translation, edit (original) messages a bit. 2001-06-08 23:53:48 +00:00
Peter Eisentraut e542036461 Native Language Support (NLS)
Use --enable-nls to turn it on; see installation instructions for details.
See developer's guide how to make use of it in programs and how to add
translations.

psql sources have been almost fully prepared and an incomplete German
translation has been provided.  In the backend, only elog() calls are
currently translatable, and the provided German translation file is more
of a placeholder.
2001-06-02 18:25:18 +00:00
Peter Eisentraut b3f66d1980 Add command '\pset footer' to psql to turn off default "(x rows)" footer. 2001-05-12 19:44:46 +00:00
Tom Lane 02549a2d2c Add comment to explain need for bizarre-looking coding in HandleSlashCmds. 2001-05-12 17:37:15 +00:00
Bruce Momjian a79b698adb Here's a version of my suggested diffs transplanted to 7.1 beta 5. I'm
still looking at the best way to integrate Tom Vijlbrief's fixes
(insofar as they're still needed); would 7.2 be a suitable time for
incompatible API changes?


Jeroen


Changes:

(*) Introduced bool, true, false (replacing some int, 1, 0)
(*) Made some member functions const
(*) Documented GetIsNull()
(*) Marked DisplayTuples() and PrintTuples() as obsolescent; fixed possible
    portability problem (assumed that NULL pointer equals all-zero bit pattern)
(*) PrintTuples(): renamed width parameter to fillAlign to conform with other
    usage; fixed memory leak and compile issue w.r.t. field separator (should
    also slightly improve performance)
(*) Fixed some minor compilation issues
(*) Moved "using namespace std;" out of headers, where they didn't belong; used
    new (temporary) preprocessor macro PGSTD to do this
(*) Made ToString() static, removed unneeded memset(), made buffer size adapt
    to sizeof(int)
(*) Made some constructors explicit
(*) Changed some const std::string & parameters to plain std::string
(*) Marked PgCursor::Cursor(std::string) as obsolescent (setter with same name
    as getter--bad style)
(*) Renamed some paramaters previously named "string"
(*) Introduced size_type typedef for number of tuples in result set
(*) PgTransaction now supports re-opening after closing, and aborts if not
    explicitly committed prior to destruction

J. T. Vermeulen
2001-05-09 17:29:10 +00:00
Peter Eisentraut 232724af0d Add \cd command to psql. 2001-05-07 19:31:33 +00:00
Peter Eisentraut 9583aea9d0 Fix collateral damage from previous (rev 1.49) patch. 2001-05-06 21:15:51 +00:00
Peter Eisentraut 645ebc0403 Repair misbehavior of \! with immediately following argument that contains
spaces (e.g., '\!ls -l').  Also correct a comment.
2001-04-18 20:53:08 +00:00
Bruce Momjian 9e1552607a pgindent run. Make it all clean. 2001-03-22 04:01:46 +00:00
Tatsuo Ishii 2bc2738fc4 Fix a bug in psql. unescape() does not work for multi-byte encodings. 2001-02-17 10:03:33 +00:00
Tom Lane d08741eab5 Restructure the key include files per recent pghackers discussion: there
are now separate files "postgres.h" and "postgres_fe.h", which are meant
to be the primary include files for backend .c files and frontend .c files
respectively.  By default, only include files meant for frontend use are
installed into the installation include directory.  There is a new make
target 'make install-all-headers' that adds the whole content of the
src/include tree to the installed fileset, for use by people who want to
develop server-side code without keeping the complete source tree on hand.
Cleaned up a whole lot of crufty and inconsistent header inclusions.
2001-02-10 02:31:31 +00:00
Bruce Momjian d7f0b7ef6e Here is an update on the Win32 patch. Modified files are 'config.h.win32'
and two 'win32.mak'. Addresses the following:

1) Oops. Spelled fcntl.h wrong in the last one. D'uh.
2) PG_VERSION changed to be defined with " around it. psql/command.c failed
to compile without that.
3) Changed makefiles to use "/MD" and link both psql and libpq.dll against
MSVCRT.DLL instead of a static library. This takes care of the
crash-upon-free in psql.

I *think* this is what is on the "Open 7.1 Items" list as "Magnus Hagander
ODBC Issues?". It has nothing to do with ODBC, but it's the only issue I've
been involved with...

Magnus Hagander
2001-01-27 21:49:59 +00:00