2000-01-19 00:30:24 +01:00
/*
* psql - the PostgreSQL interactive terminal
*
2002-08-10 05:56:24 +02:00
* Copyright 2000 - 2002 by PostgreSQL Global Development Group
2000-01-19 00:30:24 +01:00
*
2003-06-12 03:38:08 +02:00
* $ Header : / cvsroot / pgsql / src / bin / psql / tab - complete . c , v 1.80 2003 / 06 / 12 01 : 38 : 08 momjian Exp $
2000-01-19 00:30:24 +01:00
*/
2000-06-25 16:25:51 +02:00
/*----------------------------------------------------------------------
* This file implements a somewhat more sophisticated readline " TAB
* completion " in psql. It is not intended to be AI, to replace
* learning SQL , or to relieve you from thinking about what you ' re
* doing . Also it does not always give you all the syntactically legal
* completions , only those that are the most common or the ones that
* the programmer felt most like implementing .
*
* CAVEAT : Tab completion causes queries to be sent to the backend .
* The number tuples returned gets limited , in most default
* installations to 101 , but if you still don ' t like this prospect ,
* you can turn off tab completion in your ~ / . inputrc ( or else
* $ { INPUTRC } ) file so :
*
2001-03-22 05:01:46 +01:00
* $ if psql
* set disable - completion on
* $ endif
2000-06-25 16:25:51 +02:00
*
* See ` man 3 readline ' or ` info readline ' for the full details . Also ,
* hence the
*
* BUGS :
*
* - If you split your queries across lines , this whole things gets
2001-03-22 05:01:46 +01:00
* confused . ( To fix this , one would have to read psql ' s query
* buffer rather than readline ' s line buffer , which would require
* some major revisions of things . )
2000-06-25 16:25:51 +02:00
*
2002-07-30 18:35:05 +02:00
* - Table or attribute names with spaces in it may confuse it .
2000-06-25 16:25:51 +02:00
*
* - Quotes , parenthesis , and other funny characters are not handled
2001-03-22 05:01:46 +01:00
* all that gracefully .
2000-06-25 16:25:51 +02:00
* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
*/
* Includes tab completion. It's not magic, but it's very cool. At any
rate
it's better than what used to be there.
* Does proper SQL "host variable" substitution as pointed out by Andreas
Zeugwetter (thanks): select * from :foo; Also some changes in how ':'
and ';' are treated (escape with \ to send to backend). This does
_not_
affect the '::' cast operator, but perhaps others that contain : or ;
(but there are none right now).
* To show description with a <something> listing, append '?' to command
name, e.g., \df?. This seemed to be the convenient and logical
solution.
Or append a '+' to see more useless information, e.g., \df+.
* Fixed fflush()'ing bug pointed out by Jan during the regression test
discussion.
* Added LastOid variable. This ought to take care of TODO item "Add a
function to return the last inserted oid, for use in psql scripts"
(under CLIENTS)
E.g.,
insert into foo values(...);
insert into bar values(..., :LastOid);
\echo $LastOid
* \d command shows constraints, rules, and triggers defined on the table
(in addition to indices)
* Various fixes, optimizations, corrections
* Documentation update as well
Note: This now requires snprintf(), which, if necessary, is taken from
src/backend/port. This is certainly a little weird, but it should
suffice
until a source tree cleanup is done.
Enjoy.
--
Peter Eisentraut Sernanders väg 10:115
1999-11-26 05:24:17 +01:00
2001-02-10 03:31:31 +01:00
# include "postgres_fe.h"
* Includes tab completion. It's not magic, but it's very cool. At any
rate
it's better than what used to be there.
* Does proper SQL "host variable" substitution as pointed out by Andreas
Zeugwetter (thanks): select * from :foo; Also some changes in how ':'
and ';' are treated (escape with \ to send to backend). This does
_not_
affect the '::' cast operator, but perhaps others that contain : or ;
(but there are none right now).
* To show description with a <something> listing, append '?' to command
name, e.g., \df?. This seemed to be the convenient and logical
solution.
Or append a '+' to see more useless information, e.g., \df+.
* Fixed fflush()'ing bug pointed out by Jan during the regression test
discussion.
* Added LastOid variable. This ought to take care of TODO item "Add a
function to return the last inserted oid, for use in psql scripts"
(under CLIENTS)
E.g.,
insert into foo values(...);
insert into bar values(..., :LastOid);
\echo $LastOid
* \d command shows constraints, rules, and triggers defined on the table
(in addition to indices)
* Various fixes, optimizations, corrections
* Documentation update as well
Note: This now requires snprintf(), which, if necessary, is taken from
src/backend/port. This is certainly a little weird, but it should
suffice
until a source tree cleanup is done.
Enjoy.
--
Peter Eisentraut Sernanders väg 10:115
1999-11-26 05:24:17 +01:00
# include "tab-complete.h"
# include "input.h"
/* If we don't have this, we might as well forget about the whole thing: */
# ifdef USE_READLINE
2000-12-03 21:45:40 +01:00
# include <ctype.h>
* Includes tab completion. It's not magic, but it's very cool. At any
rate
it's better than what used to be there.
* Does proper SQL "host variable" substitution as pointed out by Andreas
Zeugwetter (thanks): select * from :foo; Also some changes in how ':'
and ';' are treated (escape with \ to send to backend). This does
_not_
affect the '::' cast operator, but perhaps others that contain : or ;
(but there are none right now).
* To show description with a <something> listing, append '?' to command
name, e.g., \df?. This seemed to be the convenient and logical
solution.
Or append a '+' to see more useless information, e.g., \df+.
* Fixed fflush()'ing bug pointed out by Jan during the regression test
discussion.
* Added LastOid variable. This ought to take care of TODO item "Add a
function to return the last inserted oid, for use in psql scripts"
(under CLIENTS)
E.g.,
insert into foo values(...);
insert into bar values(..., :LastOid);
\echo $LastOid
* \d command shows constraints, rules, and triggers defined on the table
(in addition to indices)
* Various fixes, optimizations, corrections
* Documentation update as well
Note: This now requires snprintf(), which, if necessary, is taken from
src/backend/port. This is certainly a little weird, but it should
suffice
until a source tree cleanup is done.
Enjoy.
--
Peter Eisentraut Sernanders väg 10:115
1999-11-26 05:24:17 +01:00
# ifdef USE_ASSERT_CHECKING
# include <assert.h>
# endif
2000-02-16 14:15:26 +01:00
# include "libpq-fe.h"
* Includes tab completion. It's not magic, but it's very cool. At any
rate
it's better than what used to be there.
* Does proper SQL "host variable" substitution as pointed out by Andreas
Zeugwetter (thanks): select * from :foo; Also some changes in how ':'
and ';' are treated (escape with \ to send to backend). This does
_not_
affect the '::' cast operator, but perhaps others that contain : or ;
(but there are none right now).
* To show description with a <something> listing, append '?' to command
name, e.g., \df?. This seemed to be the convenient and logical
solution.
Or append a '+' to see more useless information, e.g., \df+.
* Fixed fflush()'ing bug pointed out by Jan during the regression test
discussion.
* Added LastOid variable. This ought to take care of TODO item "Add a
function to return the last inserted oid, for use in psql scripts"
(under CLIENTS)
E.g.,
insert into foo values(...);
insert into bar values(..., :LastOid);
\echo $LastOid
* \d command shows constraints, rules, and triggers defined on the table
(in addition to indices)
* Various fixes, optimizations, corrections
* Documentation update as well
Note: This now requires snprintf(), which, if necessary, is taken from
src/backend/port. This is certainly a little weird, but it should
suffice
until a source tree cleanup is done.
Enjoy.
--
Peter Eisentraut Sernanders väg 10:115
1999-11-26 05:24:17 +01:00
# include "common.h"
2000-01-19 00:30:24 +01:00
# include "settings.h"
* Includes tab completion. It's not magic, but it's very cool. At any
rate
it's better than what used to be there.
* Does proper SQL "host variable" substitution as pointed out by Andreas
Zeugwetter (thanks): select * from :foo; Also some changes in how ':'
and ';' are treated (escape with \ to send to backend). This does
_not_
affect the '::' cast operator, but perhaps others that contain : or ;
(but there are none right now).
* To show description with a <something> listing, append '?' to command
name, e.g., \df?. This seemed to be the convenient and logical
solution.
Or append a '+' to see more useless information, e.g., \df+.
* Fixed fflush()'ing bug pointed out by Jan during the regression test
discussion.
* Added LastOid variable. This ought to take care of TODO item "Add a
function to return the last inserted oid, for use in psql scripts"
(under CLIENTS)
E.g.,
insert into foo values(...);
insert into bar values(..., :LastOid);
\echo $LastOid
* \d command shows constraints, rules, and triggers defined on the table
(in addition to indices)
* Various fixes, optimizations, corrections
* Documentation update as well
Note: This now requires snprintf(), which, if necessary, is taken from
src/backend/port. This is certainly a little weird, but it should
suffice
until a source tree cleanup is done.
Enjoy.
--
Peter Eisentraut Sernanders väg 10:115
1999-11-26 05:24:17 +01:00
2001-06-12 00:12:48 +02:00
# ifdef HAVE_RL_FILENAME_COMPLETION_FUNCTION
# define filename_completion_function rl_filename_completion_function
2001-06-20 20:39:14 +02:00
# else
/* missing in some header files */
extern char * filename_completion_function ( ) ;
2001-06-12 00:12:48 +02:00
# endif
2000-04-12 19:17:23 +02:00
2001-04-15 00:55:02 +02:00
# ifdef HAVE_RL_COMPLETION_MATCHES
2003-04-03 22:18:16 +02:00
# define completion_matches rl_completion_matches
2000-03-05 14:30:20 +01:00
# endif
* Includes tab completion. It's not magic, but it's very cool. At any
rate
it's better than what used to be there.
* Does proper SQL "host variable" substitution as pointed out by Andreas
Zeugwetter (thanks): select * from :foo; Also some changes in how ':'
and ';' are treated (escape with \ to send to backend). This does
_not_
affect the '::' cast operator, but perhaps others that contain : or ;
(but there are none right now).
* To show description with a <something> listing, append '?' to command
name, e.g., \df?. This seemed to be the convenient and logical
solution.
Or append a '+' to see more useless information, e.g., \df+.
* Fixed fflush()'ing bug pointed out by Jan during the regression test
discussion.
* Added LastOid variable. This ought to take care of TODO item "Add a
function to return the last inserted oid, for use in psql scripts"
(under CLIENTS)
E.g.,
insert into foo values(...);
insert into bar values(..., :LastOid);
\echo $LastOid
* \d command shows constraints, rules, and triggers defined on the table
(in addition to indices)
* Various fixes, optimizations, corrections
* Documentation update as well
Note: This now requires snprintf(), which, if necessary, is taken from
src/backend/port. This is certainly a little weird, but it should
suffice
until a source tree cleanup is done.
Enjoy.
--
Peter Eisentraut Sernanders väg 10:115
1999-11-26 05:24:17 +01:00
# define BUF_SIZE 2048
2000-04-12 19:17:23 +02:00
# define ERROR_QUERY_TOO_LONG /* empty */
* Includes tab completion. It's not magic, but it's very cool. At any
rate
it's better than what used to be there.
* Does proper SQL "host variable" substitution as pointed out by Andreas
Zeugwetter (thanks): select * from :foo; Also some changes in how ':'
and ';' are treated (escape with \ to send to backend). This does
_not_
affect the '::' cast operator, but perhaps others that contain : or ;
(but there are none right now).
* To show description with a <something> listing, append '?' to command
name, e.g., \df?. This seemed to be the convenient and logical
solution.
Or append a '+' to see more useless information, e.g., \df+.
* Fixed fflush()'ing bug pointed out by Jan during the regression test
discussion.
* Added LastOid variable. This ought to take care of TODO item "Add a
function to return the last inserted oid, for use in psql scripts"
(under CLIENTS)
E.g.,
insert into foo values(...);
insert into bar values(..., :LastOid);
\echo $LastOid
* \d command shows constraints, rules, and triggers defined on the table
(in addition to indices)
* Various fixes, optimizations, corrections
* Documentation update as well
Note: This now requires snprintf(), which, if necessary, is taken from
src/backend/port. This is certainly a little weird, but it should
suffice
until a source tree cleanup is done.
Enjoy.
--
Peter Eisentraut Sernanders väg 10:115
1999-11-26 05:24:17 +01:00
/* Forward declaration of functions */
2000-04-12 19:17:23 +02:00
static char * * psql_completion ( char * text , int start , int end ) ;
2003-04-03 22:18:16 +02:00
static char * create_command_generator ( const char * text , int state ) ;
static char * complete_from_query ( const char * text , int state ) ;
static char * complete_from_schema_query ( const char * text , int state ) ;
static char * _complete_from_query ( int is_schema_query ,
const char * text , int state ) ;
static char * complete_from_const ( const char * text , int state ) ;
static char * complete_from_list ( const char * text , int state ) ;
2000-04-12 19:17:23 +02:00
static PGresult * exec_query ( char * query ) ;
char * quote_file_name ( char * text , int match_type , char * quote_pointer ) ;
1999-11-26 18:26:38 +01:00
/*static char * dequote_file_name(char *text, char quote_char);*/
2000-04-12 19:17:23 +02:00
static char * previous_word ( int point , int skip ) ;
* Includes tab completion. It's not magic, but it's very cool. At any
rate
it's better than what used to be there.
* Does proper SQL "host variable" substitution as pointed out by Andreas
Zeugwetter (thanks): select * from :foo; Also some changes in how ':'
and ';' are treated (escape with \ to send to backend). This does
_not_
affect the '::' cast operator, but perhaps others that contain : or ;
(but there are none right now).
* To show description with a <something> listing, append '?' to command
name, e.g., \df?. This seemed to be the convenient and logical
solution.
Or append a '+' to see more useless information, e.g., \df+.
* Fixed fflush()'ing bug pointed out by Jan during the regression test
discussion.
* Added LastOid variable. This ought to take care of TODO item "Add a
function to return the last inserted oid, for use in psql scripts"
(under CLIENTS)
E.g.,
insert into foo values(...);
insert into bar values(..., :LastOid);
\echo $LastOid
* \d command shows constraints, rules, and triggers defined on the table
(in addition to indices)
* Various fixes, optimizations, corrections
* Documentation update as well
Note: This now requires snprintf(), which, if necessary, is taken from
src/backend/port. This is certainly a little weird, but it should
suffice
until a source tree cleanup is done.
Enjoy.
--
Peter Eisentraut Sernanders väg 10:115
1999-11-26 05:24:17 +01:00
/* These variables are used to pass information into the completion functions.
Realizing that this is the cardinal sin of programming , I don ' t see a better
way . */
2000-04-12 19:17:23 +02:00
char * completion_charp ; /* if you need to pass a string */
char * * completion_charpp ; /* if you need to pass a list of strings */
char * completion_info_charp ; /* if you need to pass another
* string */
* Includes tab completion. It's not magic, but it's very cool. At any
rate
it's better than what used to be there.
* Does proper SQL "host variable" substitution as pointed out by Andreas
Zeugwetter (thanks): select * from :foo; Also some changes in how ':'
and ';' are treated (escape with \ to send to backend). This does
_not_
affect the '::' cast operator, but perhaps others that contain : or ;
(but there are none right now).
* To show description with a <something> listing, append '?' to command
name, e.g., \df?. This seemed to be the convenient and logical
solution.
Or append a '+' to see more useless information, e.g., \df+.
* Fixed fflush()'ing bug pointed out by Jan during the regression test
discussion.
* Added LastOid variable. This ought to take care of TODO item "Add a
function to return the last inserted oid, for use in psql scripts"
(under CLIENTS)
E.g.,
insert into foo values(...);
insert into bar values(..., :LastOid);
\echo $LastOid
* \d command shows constraints, rules, and triggers defined on the table
(in addition to indices)
* Various fixes, optimizations, corrections
* Documentation update as well
Note: This now requires snprintf(), which, if necessary, is taken from
src/backend/port. This is certainly a little weird, but it should
suffice
until a source tree cleanup is done.
Enjoy.
--
Peter Eisentraut Sernanders väg 10:115
1999-11-26 05:24:17 +01:00
/* Store how many records from a database query we want to return at most
( implemented via SELECT . . . LIMIT xx ) . */
2000-04-12 19:17:23 +02:00
static int completion_max_records ;
* Includes tab completion. It's not magic, but it's very cool. At any
rate
it's better than what used to be there.
* Does proper SQL "host variable" substitution as pointed out by Andreas
Zeugwetter (thanks): select * from :foo; Also some changes in how ':'
and ';' are treated (escape with \ to send to backend). This does
_not_
affect the '::' cast operator, but perhaps others that contain : or ;
(but there are none right now).
* To show description with a <something> listing, append '?' to command
name, e.g., \df?. This seemed to be the convenient and logical
solution.
Or append a '+' to see more useless information, e.g., \df+.
* Fixed fflush()'ing bug pointed out by Jan during the regression test
discussion.
* Added LastOid variable. This ought to take care of TODO item "Add a
function to return the last inserted oid, for use in psql scripts"
(under CLIENTS)
E.g.,
insert into foo values(...);
insert into bar values(..., :LastOid);
\echo $LastOid
* \d command shows constraints, rules, and triggers defined on the table
(in addition to indices)
* Various fixes, optimizations, corrections
* Documentation update as well
Note: This now requires snprintf(), which, if necessary, is taken from
src/backend/port. This is certainly a little weird, but it should
suffice
until a source tree cleanup is done.
Enjoy.
--
Peter Eisentraut Sernanders väg 10:115
1999-11-26 05:24:17 +01:00
/* Initialize the readline library for our purposes. */
2000-04-12 19:17:23 +02:00
void
initialize_readline ( void )
* Includes tab completion. It's not magic, but it's very cool. At any
rate
it's better than what used to be there.
* Does proper SQL "host variable" substitution as pointed out by Andreas
Zeugwetter (thanks): select * from :foo; Also some changes in how ':'
and ';' are treated (escape with \ to send to backend). This does
_not_
affect the '::' cast operator, but perhaps others that contain : or ;
(but there are none right now).
* To show description with a <something> listing, append '?' to command
name, e.g., \df?. This seemed to be the convenient and logical
solution.
Or append a '+' to see more useless information, e.g., \df+.
* Fixed fflush()'ing bug pointed out by Jan during the regression test
discussion.
* Added LastOid variable. This ought to take care of TODO item "Add a
function to return the last inserted oid, for use in psql scripts"
(under CLIENTS)
E.g.,
insert into foo values(...);
insert into bar values(..., :LastOid);
\echo $LastOid
* \d command shows constraints, rules, and triggers defined on the table
(in addition to indices)
* Various fixes, optimizations, corrections
* Documentation update as well
Note: This now requires snprintf(), which, if necessary, is taken from
src/backend/port. This is certainly a little weird, but it should
suffice
until a source tree cleanup is done.
Enjoy.
--
Peter Eisentraut Sernanders väg 10:115
1999-11-26 05:24:17 +01:00
{
2000-04-12 19:17:23 +02:00
rl_readline_name = pset . progname ;
2001-10-25 07:50:21 +02:00
rl_attempted_completion_function = ( void * ) psql_completion ;
2000-04-12 19:17:23 +02:00
2000-12-31 12:57:58 +01:00
rl_basic_word_break_characters = " \t \n @$><=;|&{( " ;
* Includes tab completion. It's not magic, but it's very cool. At any
rate
it's better than what used to be there.
* Does proper SQL "host variable" substitution as pointed out by Andreas
Zeugwetter (thanks): select * from :foo; Also some changes in how ':'
and ';' are treated (escape with \ to send to backend). This does
_not_
affect the '::' cast operator, but perhaps others that contain : or ;
(but there are none right now).
* To show description with a <something> listing, append '?' to command
name, e.g., \df?. This seemed to be the convenient and logical
solution.
Or append a '+' to see more useless information, e.g., \df+.
* Fixed fflush()'ing bug pointed out by Jan during the regression test
discussion.
* Added LastOid variable. This ought to take care of TODO item "Add a
function to return the last inserted oid, for use in psql scripts"
(under CLIENTS)
E.g.,
insert into foo values(...);
insert into bar values(..., :LastOid);
\echo $LastOid
* \d command shows constraints, rules, and triggers defined on the table
(in addition to indices)
* Various fixes, optimizations, corrections
* Documentation update as well
Note: This now requires snprintf(), which, if necessary, is taken from
src/backend/port. This is certainly a little weird, but it should
suffice
until a source tree cleanup is done.
Enjoy.
--
Peter Eisentraut Sernanders väg 10:115
1999-11-26 05:24:17 +01:00
2000-04-12 19:17:23 +02:00
completion_max_records = 100 ;
* Includes tab completion. It's not magic, but it's very cool. At any
rate
it's better than what used to be there.
* Does proper SQL "host variable" substitution as pointed out by Andreas
Zeugwetter (thanks): select * from :foo; Also some changes in how ':'
and ';' are treated (escape with \ to send to backend). This does
_not_
affect the '::' cast operator, but perhaps others that contain : or ;
(but there are none right now).
* To show description with a <something> listing, append '?' to command
name, e.g., \df?. This seemed to be the convenient and logical
solution.
Or append a '+' to see more useless information, e.g., \df+.
* Fixed fflush()'ing bug pointed out by Jan during the regression test
discussion.
* Added LastOid variable. This ought to take care of TODO item "Add a
function to return the last inserted oid, for use in psql scripts"
(under CLIENTS)
E.g.,
insert into foo values(...);
insert into bar values(..., :LastOid);
\echo $LastOid
* \d command shows constraints, rules, and triggers defined on the table
(in addition to indices)
* Various fixes, optimizations, corrections
* Documentation update as well
Note: This now requires snprintf(), which, if necessary, is taken from
src/backend/port. This is certainly a little weird, but it should
suffice
until a source tree cleanup is done.
Enjoy.
--
Peter Eisentraut Sernanders väg 10:115
1999-11-26 05:24:17 +01:00
2000-04-12 19:17:23 +02:00
/*
* There is a variable rl_completion_query_items for this but
* apparently it ' s not defined everywhere .
*/
* Includes tab completion. It's not magic, but it's very cool. At any
rate
it's better than what used to be there.
* Does proper SQL "host variable" substitution as pointed out by Andreas
Zeugwetter (thanks): select * from :foo; Also some changes in how ':'
and ';' are treated (escape with \ to send to backend). This does
_not_
affect the '::' cast operator, but perhaps others that contain : or ;
(but there are none right now).
* To show description with a <something> listing, append '?' to command
name, e.g., \df?. This seemed to be the convenient and logical
solution.
Or append a '+' to see more useless information, e.g., \df+.
* Fixed fflush()'ing bug pointed out by Jan during the regression test
discussion.
* Added LastOid variable. This ought to take care of TODO item "Add a
function to return the last inserted oid, for use in psql scripts"
(under CLIENTS)
E.g.,
insert into foo values(...);
insert into bar values(..., :LastOid);
\echo $LastOid
* \d command shows constraints, rules, and triggers defined on the table
(in addition to indices)
* Various fixes, optimizations, corrections
* Documentation update as well
Note: This now requires snprintf(), which, if necessary, is taken from
src/backend/port. This is certainly a little weird, but it should
suffice
until a source tree cleanup is done.
Enjoy.
--
Peter Eisentraut Sernanders väg 10:115
1999-11-26 05:24:17 +01:00
}
2002-08-10 05:56:24 +02:00
/*
* Queries to get lists of names of various kinds of things , possibly
* restricted to names matching a partially entered name . In these queries ,
* the % s will be replaced by the text entered so far , the % d by its length .
*/
2003-03-27 17:45:01 +01:00
# define Query_for_list_of_aggregates \
" SELECT DISTINCT proname " \
" FROM pg_catalog.pg_proc " \
" WHERE proisagg " \
" AND substr(proname,1,%d)='%s' " \
" UNION " \
" SELECT nspname || '.' AS relname " \
" FROM pg_catalog.pg_namespace " \
" WHERE substr(nspname,1,%d)='%s' " \
" UNION " \
" SELECT DISTINCT nspname || '.' || proname AS relname " \
" FROM pg_catalog.pg_proc p, pg_catalog.pg_namespace n " \
" WHERE proisagg " \
" AND substr(nspname || '.' || proname,1,%d)='%s' " \
" AND pronamespace = n.oid " \
" AND ('%s' ~ '^.* \\ \\ .' " \
" OR (SELECT TRUE " \
" FROM pg_catalog.pg_namespace " \
" WHERE substr(nspname,1,%d)='%s' " \
" HAVING COUNT(nspname)=1)) "
# define Query_for_list_of_attributes \
" SELECT a.attname FROM pg_catalog.pg_attribute a, pg_catalog.pg_class c " \
" WHERE c.oid = a.attrelid " \
" AND a.attnum > 0 " \
" AND NOT a.attisdropped " \
" AND substr(a.attname,1,%d)='%s' " \
" AND c.relname='%s' " \
" AND pg_catalog.pg_table_is_visible(c.oid) "
# define Query_for_list_of_databases \
" SELECT datname FROM pg_catalog.pg_database " \
" WHERE substr(datname,1,%d)='%s' "
# define Query_for_list_of_datatypes \
" SELECT pg_catalog.format_type(t.oid, NULL) " \
" FROM pg_catalog.pg_type t " \
" WHERE (t.typrelid = 0 " \
" OR (SELECT c.relkind = 'c' FROM pg_catalog.pg_class c WHERE c.oid = t.typrelid)) " \
" AND t.typname !~ '^_' " \
" AND substr(pg_catalog.format_type(t.oid, NULL),1,%d)='%s' " \
" UNION " \
" SELECT nspname || '.' AS relname " \
" FROM pg_catalog.pg_namespace " \
" WHERE substr(nspname,1,%d)='%s' " \
" UNION " \
" SELECT nspname || '.' || pg_catalog.format_type(t.oid, NULL) AS relname " \
" FROM pg_catalog.pg_type t, pg_catalog.pg_namespace n " \
" WHERE(t.typrelid = 0 " \
" OR (SELECT c.relkind = 'c' FROM pg_catalog.pg_class c WHERE c.oid = t.typrelid)) " \
" AND t.typname !~ '^_' " \
" AND substr(nspname || '.' || pg_catalog.format_type(t.oid, NULL),1,%d)='%s' " \
" AND typnamespace = n.oid " \
" AND ('%s' ~ '^.* \\ \\ .' " \
" OR (SELECT TRUE " \
" FROM pg_catalog.pg_namespace " \
" WHERE substr(nspname,1,%d)='%s' " \
" HAVING COUNT(nspname)=1)) "
# define Query_for_list_of_domains \
" SELECT typname " \
" FROM pg_catalog.pg_type t " \
" WHERE typtype = 'd' " \
" AND substr(typname,1,%d)='%s' " \
" UNION " \
" SELECT nspname || '.' " \
" FROM pg_catalog.pg_namespace " \
" WHERE substr(nspname,1,%d)='%s' " \
" UNION " \
" SELECT nspname || '.' || pg_catalog.format_type(t.oid, NULL) " \
" FROM pg_catalog.pg_type t, pg_catalog.pg_namespace n " \
" WHERE typtype = 'd' " \
" AND substr(nspname || '.' || typname,1,%d)='%s' " \
" AND typnamespace = n.oid " \
" AND ('%s' ~ '^.* \\ \\ .' " \
" OR (SELECT TRUE " \
" FROM pg_catalog.pg_namespace " \
" WHERE substr(nspname,1,%d)='%s' " \
" HAVING COUNT(nspname)=1)) "
2003-06-12 03:38:08 +02:00
# define Query_for_list_of_encodings \
" SELECT DISTINCT pg_catalog.pg_encoding_to_char(conforencoding) " \
" FROM pg_catalog.pg_conversion " \
" WHERE substr(pg_catalog.pg_encoding_to_char(conforencoding),1,%d)=UPPER('%s') "
2003-03-27 17:45:01 +01:00
# define Query_for_list_of_functions \
" SELECT DISTINCT proname || '()' " \
" FROM pg_catalog.pg_proc p, pg_catalog.pg_namespace n " \
" WHERE substr(proname,1,%d)='%s' " \
" AND pg_catalog.pg_function_is_visible(p.oid) " \
" AND pronamespace = n.oid " \
" UNION " \
" SELECT nspname || '.' " \
" FROM pg_catalog.pg_namespace " \
" WHERE substr(nspname,1,%d)='%s' " \
" UNION " \
" SELECT nspname || '.' || proname " \
" FROM pg_catalog.pg_proc p, pg_catalog.pg_namespace n " \
" WHERE substr(nspname || '.' || proname,1,%d)='%s' " \
" AND pronamespace = n.oid " \
" AND ('%s' ~ '^.* \\ \\ .' " \
" OR (SELECT TRUE " \
" FROM pg_catalog.pg_namespace " \
" WHERE substr(nspname,1,%d)='%s' " \
" HAVING COUNT(nspname)=1)) "
# define Query_for_list_of_indexes \
" SELECT relname " \
" FROM pg_catalog.pg_class c, pg_catalog.pg_namespace n " \
" WHERE relkind='i' " \
" AND substr(relname,1,%d)='%s' " \
" AND pg_catalog.pg_table_is_visible(c.oid) " \
" AND relnamespace = n.oid " \
" AND n.nspname NOT IN ('pg_catalog', 'pg_toast') " \
" UNION " \
" SELECT nspname || '.' " \
" FROM pg_catalog.pg_namespace " \
" WHERE substr(nspname,1,%d)='%s' " \
" UNION " \
" SELECT nspname || '.' || relname " \
" FROM pg_catalog.pg_class c, pg_catalog.pg_namespace n " \
" WHERE relkind='i' " \
" AND substr(nspname || '.' || relname,1,%d)='%s' " \
" AND relnamespace = n.oid " \
" AND ('%s' ~ '^.* \\ \\ .' " \
" OR (SELECT TRUE " \
" FROM pg_catalog.pg_namespace " \
" WHERE substr(nspname,1,%d)='%s' " \
" HAVING COUNT(nspname)=1)) "
# define Query_for_list_of_languages \
" SELECT lanname " \
" FROM pg_language " \
" WHERE lanname != 'internal' " \
" AND substr(lanname,1,%d)='%s' "
# define Query_for_list_of_schemas \
" SELECT nspname FROM pg_catalog.pg_namespace " \
" WHERE substr(nspname,1,%d)='%s' "
# define Query_for_list_of_sequences \
" SELECT relname " \
" FROM pg_catalog.pg_class c, pg_catalog.pg_namespace n " \
" WHERE relkind='S' " \
" AND substr(relname,1,%d)='%s' " \
" AND pg_catalog.pg_table_is_visible(c.oid) " \
" AND relnamespace = n.oid " \
" AND n.nspname NOT IN ('pg_catalog', 'pg_toast') " \
" UNION " \
" SELECT nspname || '.' " \
" FROM pg_catalog.pg_namespace " \
" WHERE substr(nspname,1,%d)='%s' " \
" UNION " \
" SELECT nspname || '.' || relname " \
" FROM pg_catalog.pg_class c, pg_catalog.pg_namespace n " \
" WHERE relkind='S' " \
" AND substr(nspname || '.' || relname,1,%d)='%s' " \
" AND relnamespace = n.oid " \
" AND ('%s' ~ '^.* \\ \\ .' " \
" OR (SELECT TRUE " \
" FROM pg_catalog.pg_namespace " \
" WHERE substr(nspname,1,%d)='%s' " \
" HAVING COUNT(nspname)=1)) "
# define Query_for_list_of_system_relations \
" SELECT c.relname FROM pg_catalog.pg_class c, pg_catalog.pg_namespace n " \
" WHERE (c.relkind='r' OR c.relkind='v' OR c.relkind='s' OR c.relkind='S') " \
" AND substr(c.relname,1,%d)='%s' " \
" AND pg_catalog.pg_table_is_visible(c.oid) " \
" AND relnamespace = n.oid " \
" AND n.nspname = 'pg_catalog' "
# define Query_for_list_of_tables \
" SELECT relname " \
" FROM pg_catalog.pg_class c, pg_catalog.pg_namespace n " \
" WHERE relkind='r' " \
" AND substr(relname,1,%d)='%s' " \
" AND pg_catalog.pg_table_is_visible(c.oid) " \
" AND relnamespace = n.oid " \
" AND n.nspname NOT IN ('pg_catalog', 'pg_toast') " \
" UNION " \
" SELECT nspname || '.' " \
" FROM pg_catalog.pg_namespace " \
" WHERE substr(nspname || '.',1,%d)='%s' " \
" UNION " \
" SELECT nspname || '.' || relname " \
" FROM pg_catalog.pg_class c, pg_catalog.pg_namespace n " \
" WHERE relkind='r' " \
" AND substr(nspname || '.' || relname,1,%d)='%s' " \
" AND relnamespace = n.oid " \
" AND ('%s' ~ '^.* \\ \\ .' " \
" OR (SELECT TRUE " \
" FROM pg_catalog.pg_namespace n1 " \
" WHERE substr(nspname ||'.',1,%d)='%s' " \
" HAVING COUNT(nspname)=1)) "
# define Query_for_list_of_tisv \
" SELECT relname " \
" FROM pg_catalog.pg_class c, pg_catalog.pg_namespace n " \
" WHERE (relkind='r' OR relkind='i' OR relkind='S' OR relkind='v') " \
" AND substr(relname,1,%d)='%s' " \
" AND pg_catalog.pg_table_is_visible(c.oid) " \
" AND relnamespace = n.oid " \
" AND n.nspname NOT IN ('pg_catalog', 'pg_toast') " \
" UNION " \
" SELECT nspname || '.' " \
" FROM pg_catalog.pg_namespace " \
" WHERE substr(nspname,1,%d)='%s' " \
" UNION " \
" SELECT nspname || '.' || relname " \
" FROM pg_catalog.pg_class c, pg_catalog.pg_namespace n " \
" WHERE (relkind='r' OR relkind='i' OR relkind='S' OR relkind='v') " \
" AND substr(nspname || '.' || relname,1,%d)='%s' " \
" AND relnamespace = n.oid " \
" AND ('%s' ~ '^.* \\ \\ .' " \
" OR (SELECT TRUE " \
" FROM pg_catalog.pg_namespace " \
" WHERE substr(nspname,1,%d)='%s' " \
" HAVING COUNT(nspname)=1)) "
# define Query_for_list_of_tsv \
" SELECT relname " \
" FROM pg_catalog.pg_class c, pg_catalog.pg_namespace n " \
" WHERE (relkind='r' OR relkind='S' OR relkind='v') " \
" AND substr(relname,1,%d)='%s' " \
" AND pg_catalog.pg_table_is_visible(c.oid) " \
" AND relnamespace = n.oid " \
" AND n.nspname NOT IN ('pg_catalog', 'pg_toast') " \
" UNION " \
" SELECT nspname || '.' " \
" FROM pg_catalog.pg_namespace " \
" WHERE substr(nspname,1,%d)='%s' " \
" UNION " \
" SELECT nspname || '.' || relname " \
" FROM pg_catalog.pg_class c, pg_catalog.pg_namespace n " \
" WHERE (relkind='r' OR relkind='S' OR relkind='v') " \
" AND substr(nspname || '.' || relname,1,%d)='%s' " \
" AND relnamespace = n.oid " \
" AND ('%s' ~ '^.* \\ \\ .' " \
" OR (SELECT TRUE " \
" FROM pg_catalog.pg_namespace " \
" WHERE substr(nspname,1,%d)='%s' " \
" HAVING COUNT(nspname)=1)) "
# define Query_for_list_of_views \
" SELECT relname " \
" FROM pg_catalog.pg_class c, pg_catalog.pg_namespace n " \
" WHERE relkind='v' " \
" AND substr(relname,1,%d)='%s' " \
" AND pg_catalog.pg_table_is_visible(c.oid) " \
" AND relnamespace = n.oid " \
" AND n.nspname NOT IN ('pg_catalog', 'pg_toast') " \
" UNION " \
" SELECT nspname || '.' " \
" FROM pg_catalog.pg_namespace " \
" WHERE substr(nspname,1,%d)='%s' " \
" UNION " \
" SELECT nspname || '.' || relname " \
" FROM pg_catalog.pg_class c, pg_catalog.pg_namespace n " \
" WHERE relkind='v' " \
" AND substr(nspname || '.' || relname,1,%d)='%s' " \
" AND relnamespace = n.oid " \
" AND ('%s' ~ '^.* \\ \\ .' " \
" OR (SELECT TRUE " \
" FROM pg_catalog.pg_namespace " \
" WHERE substr(nspname,1,%d)='%s' " \
" HAVING COUNT(nspname)=1)) "
# define Query_for_list_of_users \
" SELECT usename " \
" FROM pg_catalog.pg_user " \
" WHERE substr(usename,1,%d)='%s' "
2002-08-10 05:56:24 +02:00
* Includes tab completion. It's not magic, but it's very cool. At any
rate
it's better than what used to be there.
* Does proper SQL "host variable" substitution as pointed out by Andreas
Zeugwetter (thanks): select * from :foo; Also some changes in how ':'
and ';' are treated (escape with \ to send to backend). This does
_not_
affect the '::' cast operator, but perhaps others that contain : or ;
(but there are none right now).
* To show description with a <something> listing, append '?' to command
name, e.g., \df?. This seemed to be the convenient and logical
solution.
Or append a '+' to see more useless information, e.g., \df+.
* Fixed fflush()'ing bug pointed out by Jan during the regression test
discussion.
* Added LastOid variable. This ought to take care of TODO item "Add a
function to return the last inserted oid, for use in psql scripts"
(under CLIENTS)
E.g.,
insert into foo values(...);
insert into bar values(..., :LastOid);
\echo $LastOid
* \d command shows constraints, rules, and triggers defined on the table
(in addition to indices)
* Various fixes, optimizations, corrections
* Documentation update as well
Note: This now requires snprintf(), which, if necessary, is taken from
src/backend/port. This is certainly a little weird, but it should
suffice
until a source tree cleanup is done.
Enjoy.
--
Peter Eisentraut Sernanders väg 10:115
1999-11-26 05:24:17 +01:00
/* This is a list of all "things" in Pgsql, which can show up after CREATE or
DROP ; and there is also a query to get a list of them .
*/
2003-03-27 17:45:01 +01:00
# define WITH_SCHEMA 1
# define NO_SCHEMA 0
2000-04-12 19:17:23 +02:00
typedef struct
{
char * name ;
2003-03-27 17:45:01 +01:00
int with_schema ;
2000-04-12 19:17:23 +02:00
char * query ;
* Includes tab completion. It's not magic, but it's very cool. At any
rate
it's better than what used to be there.
* Does proper SQL "host variable" substitution as pointed out by Andreas
Zeugwetter (thanks): select * from :foo; Also some changes in how ':'
and ';' are treated (escape with \ to send to backend). This does
_not_
affect the '::' cast operator, but perhaps others that contain : or ;
(but there are none right now).
* To show description with a <something> listing, append '?' to command
name, e.g., \df?. This seemed to be the convenient and logical
solution.
Or append a '+' to see more useless information, e.g., \df+.
* Fixed fflush()'ing bug pointed out by Jan during the regression test
discussion.
* Added LastOid variable. This ought to take care of TODO item "Add a
function to return the last inserted oid, for use in psql scripts"
(under CLIENTS)
E.g.,
insert into foo values(...);
insert into bar values(..., :LastOid);
\echo $LastOid
* \d command shows constraints, rules, and triggers defined on the table
(in addition to indices)
* Various fixes, optimizations, corrections
* Documentation update as well
Note: This now requires snprintf(), which, if necessary, is taken from
src/backend/port. This is certainly a little weird, but it should
suffice
until a source tree cleanup is done.
Enjoy.
--
Peter Eisentraut Sernanders väg 10:115
1999-11-26 05:24:17 +01:00
} pgsql_thing_t ;
pgsql_thing_t words_after_create [ ] = {
2003-03-27 17:45:01 +01:00
{ " AGGREGATE " , WITH_SCHEMA , Query_for_list_of_aggregates } ,
2003-03-28 17:34:50 +01:00
{ " CAST " , NO_SCHEMA , NULL } , /* Casts have complex structures for namees, so skip it */
2003-03-27 17:45:01 +01:00
{ " CONVERSION " , NO_SCHEMA , " SELECT conname FROM pg_catalog.pg_conversion WHERE substr(conname,1,%d)='%s' " } ,
{ " DATABASE " , NO_SCHEMA , Query_for_list_of_databases } ,
{ " DOMAIN " , WITH_SCHEMA , Query_for_list_of_domains } ,
{ " FUNCTION " , WITH_SCHEMA , Query_for_list_of_functions } ,
{ " GROUP " , NO_SCHEMA , " SELECT groname FROM pg_catalog.pg_group WHERE substr(groname,1,%d)='%s' " } ,
{ " LANGUAGE " , NO_SCHEMA , Query_for_list_of_languages } ,
{ " INDEX " , WITH_SCHEMA , Query_for_list_of_indexes } ,
2003-03-28 17:34:50 +01:00
{ " OPERATOR " , NO_SCHEMA , NULL } , /* Querying for this is probably not such
2002-09-04 22:31:48 +02:00
* a good idea . */
2003-03-27 17:45:01 +01:00
{ " RULE " , NO_SCHEMA , " SELECT rulename FROM pg_catalog.pg_rules WHERE substr(rulename,1,%d)='%s' " } ,
{ " SCHEMA " , NO_SCHEMA , Query_for_list_of_schemas } ,
{ " SEQUENCE " , WITH_SCHEMA , Query_for_list_of_sequences } ,
{ " TABLE " , WITH_SCHEMA , Query_for_list_of_tables } ,
2003-03-28 17:34:50 +01:00
{ " TEMP " , NO_SCHEMA , NULL } , /* for CREATE TEMP TABLE ... */
2003-03-27 17:45:01 +01:00
{ " TRIGGER " , NO_SCHEMA , " SELECT tgname FROM pg_catalog.pg_trigger WHERE substr(tgname,1,%d)='%s' " } ,
{ " TYPE " , WITH_SCHEMA , Query_for_list_of_datatypes } ,
2003-03-28 17:34:50 +01:00
{ " UNIQUE " , NO_SCHEMA , NULL } , /* for CREATE UNIQUE INDEX ... */
2003-03-27 17:45:01 +01:00
{ " USER " , NO_SCHEMA , Query_for_list_of_users } ,
{ " VIEW " , WITH_SCHEMA , Query_for_list_of_views } ,
2003-03-28 17:34:50 +01:00
{ NULL , NO_SCHEMA , NULL } /* end of list */
* Includes tab completion. It's not magic, but it's very cool. At any
rate
it's better than what used to be there.
* Does proper SQL "host variable" substitution as pointed out by Andreas
Zeugwetter (thanks): select * from :foo; Also some changes in how ':'
and ';' are treated (escape with \ to send to backend). This does
_not_
affect the '::' cast operator, but perhaps others that contain : or ;
(but there are none right now).
* To show description with a <something> listing, append '?' to command
name, e.g., \df?. This seemed to be the convenient and logical
solution.
Or append a '+' to see more useless information, e.g., \df+.
* Fixed fflush()'ing bug pointed out by Jan during the regression test
discussion.
* Added LastOid variable. This ought to take care of TODO item "Add a
function to return the last inserted oid, for use in psql scripts"
(under CLIENTS)
E.g.,
insert into foo values(...);
insert into bar values(..., :LastOid);
\echo $LastOid
* \d command shows constraints, rules, and triggers defined on the table
(in addition to indices)
* Various fixes, optimizations, corrections
* Documentation update as well
Note: This now requires snprintf(), which, if necessary, is taken from
src/backend/port. This is certainly a little weird, but it should
suffice
until a source tree cleanup is done.
Enjoy.
--
Peter Eisentraut Sernanders väg 10:115
1999-11-26 05:24:17 +01:00
} ;
/* A couple of macros to ease typing. You can use these to complete the given
string with
2002-08-10 05:56:24 +02:00
1 ) The results from a query you pass it . ( Perhaps one of those above ? )
2003-03-27 17:45:01 +01:00
2 ) The results from a schema query you pass it .
3 ) The items from a null - pointer - terminated list .
4 ) A string constant
5 ) The list of attributes to the given table .
* Includes tab completion. It's not magic, but it's very cool. At any
rate
it's better than what used to be there.
* Does proper SQL "host variable" substitution as pointed out by Andreas
Zeugwetter (thanks): select * from :foo; Also some changes in how ':'
and ';' are treated (escape with \ to send to backend). This does
_not_
affect the '::' cast operator, but perhaps others that contain : or ;
(but there are none right now).
* To show description with a <something> listing, append '?' to command
name, e.g., \df?. This seemed to be the convenient and logical
solution.
Or append a '+' to see more useless information, e.g., \df+.
* Fixed fflush()'ing bug pointed out by Jan during the regression test
discussion.
* Added LastOid variable. This ought to take care of TODO item "Add a
function to return the last inserted oid, for use in psql scripts"
(under CLIENTS)
E.g.,
insert into foo values(...);
insert into bar values(..., :LastOid);
\echo $LastOid
* \d command shows constraints, rules, and triggers defined on the table
(in addition to indices)
* Various fixes, optimizations, corrections
* Documentation update as well
Note: This now requires snprintf(), which, if necessary, is taken from
src/backend/port. This is certainly a little weird, but it should
suffice
until a source tree cleanup is done.
Enjoy.
--
Peter Eisentraut Sernanders väg 10:115
1999-11-26 05:24:17 +01:00
*/
# define COMPLETE_WITH_QUERY(query) \
do { completion_charp = query ; matches = completion_matches ( text , complete_from_query ) ; } while ( 0 )
2003-03-27 17:45:01 +01:00
# define COMPLETE_WITH_SCHEMA_QUERY(query) \
do { completion_charp = query ; matches = completion_matches ( text , complete_from_schema_query ) ; } while ( 0 )
* Includes tab completion. It's not magic, but it's very cool. At any
rate
it's better than what used to be there.
* Does proper SQL "host variable" substitution as pointed out by Andreas
Zeugwetter (thanks): select * from :foo; Also some changes in how ':'
and ';' are treated (escape with \ to send to backend). This does
_not_
affect the '::' cast operator, but perhaps others that contain : or ;
(but there are none right now).
* To show description with a <something> listing, append '?' to command
name, e.g., \df?. This seemed to be the convenient and logical
solution.
Or append a '+' to see more useless information, e.g., \df+.
* Fixed fflush()'ing bug pointed out by Jan during the regression test
discussion.
* Added LastOid variable. This ought to take care of TODO item "Add a
function to return the last inserted oid, for use in psql scripts"
(under CLIENTS)
E.g.,
insert into foo values(...);
insert into bar values(..., :LastOid);
\echo $LastOid
* \d command shows constraints, rules, and triggers defined on the table
(in addition to indices)
* Various fixes, optimizations, corrections
* Documentation update as well
Note: This now requires snprintf(), which, if necessary, is taken from
src/backend/port. This is certainly a little weird, but it should
suffice
until a source tree cleanup is done.
Enjoy.
--
Peter Eisentraut Sernanders väg 10:115
1999-11-26 05:24:17 +01:00
# define COMPLETE_WITH_LIST(list) \
do { completion_charpp = list ; matches = completion_matches ( text , complete_from_list ) ; } while ( 0 )
# define COMPLETE_WITH_CONST(string) \
do { completion_charp = string ; matches = completion_matches ( text , complete_from_const ) ; } while ( 0 )
# define COMPLETE_WITH_ATTR(table) \
do { completion_charp = Query_for_list_of_attributes ; completion_info_charp = table ; matches = completion_matches ( text , complete_from_query ) ; } while ( 0 )
/* The completion function. Acc. to readline spec this gets passed the text
entered to far and its start and end in the readline buffer . The return value
is some partially obscure list format that can be generated by the readline
libraries completion_matches ( ) function , so we don ' t have to worry about it .
*/
2000-04-21 05:01:54 +02:00
static char * *
2000-04-12 19:17:23 +02:00
psql_completion ( char * text , int start , int end )
* Includes tab completion. It's not magic, but it's very cool. At any
rate
it's better than what used to be there.
* Does proper SQL "host variable" substitution as pointed out by Andreas
Zeugwetter (thanks): select * from :foo; Also some changes in how ':'
and ';' are treated (escape with \ to send to backend). This does
_not_
affect the '::' cast operator, but perhaps others that contain : or ;
(but there are none right now).
* To show description with a <something> listing, append '?' to command
name, e.g., \df?. This seemed to be the convenient and logical
solution.
Or append a '+' to see more useless information, e.g., \df+.
* Fixed fflush()'ing bug pointed out by Jan during the regression test
discussion.
* Added LastOid variable. This ought to take care of TODO item "Add a
function to return the last inserted oid, for use in psql scripts"
(under CLIENTS)
E.g.,
insert into foo values(...);
insert into bar values(..., :LastOid);
\echo $LastOid
* \d command shows constraints, rules, and triggers defined on the table
(in addition to indices)
* Various fixes, optimizations, corrections
* Documentation update as well
Note: This now requires snprintf(), which, if necessary, is taken from
src/backend/port. This is certainly a little weird, but it should
suffice
until a source tree cleanup is done.
Enjoy.
--
Peter Eisentraut Sernanders väg 10:115
1999-11-26 05:24:17 +01:00
{
2000-04-12 19:17:23 +02:00
/* This is the variable we'll return. */
char * * matches = NULL ;
/* These are going to contain some scannage of the input line. */
char * prev_wd ,
* prev2_wd ,
* prev3_wd ,
* prev4_wd ;
static char * sql_commands [ ] = {
Clean up psql:
Add simple ALTER DATABASE, ALTER TRIGGER, CHECK POINT, CREATE
CONVERSION, CREATE DOMAIN, CREATE LANGUAGE, DEALLOCATE, DROP CONVERSION,
DROP DOMAIN, DROP LANGUAGE, EXECUTE, PREPARE
Complete CAST in CREATE CAST and DROP CAST but doesn't suggest what
should follow.
Add many more SET / SHOW variables to the list. Taken from SHOW ALL
output.
Complete a case sensitive search to allow \dD, \dd, \dS, \ds, \h, \H to
complete properly. But there are no matches, then try a case
insensitive search to allow case conversion. Add all missing help
options.
\Q<tab> -> \q
\dD<tab> -> \dD
\dd<tab> -> \dd
\D<tab><tab><tab> -> \d (with listing of \d? commands)
sel<tab> -> SELECT
Rod Taylor
2002-11-15 04:07:52 +01:00
" ABORT " , " ALTER " , " ANALYZE " , " BEGIN " , " CHECKPOINT " , " CLOSE " , " CLUSTER " , " COMMENT " ,
" COMMIT " , " COPY " , " CREATE " , " DEALLOCATE " , " DECLARE " , " DELETE " , " DROP " , " EXECUTE " ,
" EXPLAIN " , " FETCH " , " GRANT " , " INSERT " , " LISTEN " , " LOAD " , " LOCK " , " MOVE " , " NOTIFY " ,
" PREPARE " , " REINDEX " , " RESET " , " REVOKE " , " ROLLBACK " , " SELECT " , " SET " , " SHOW " ,
" TRUNCATE " , " UNLISTEN " , " UPDATE " , " VACUUM " , NULL
2000-04-12 19:17:23 +02:00
} ;
static char * pgsql_variables [ ] = {
2000-02-15 21:49:31 +01:00
/* these SET arguments are known in gram.y */
2000-06-25 16:25:51 +02:00
" CONSTRAINTS " ,
2000-02-15 21:49:31 +01:00
" NAMES " ,
2001-05-08 23:06:43 +02:00
" SESSION " ,
2003-01-10 23:03:30 +01:00
" TRANSACTION " ,
2001-03-22 05:01:46 +01:00
/*
2003-02-06 21:25:33 +01:00
* the rest should match USERSET and possibly SUSET entries in
* backend / utils / misc / guc . c .
2001-03-22 05:01:46 +01:00
*/
2003-06-12 00:13:22 +02:00
" add_missing_from " ,
Clean up psql:
Add simple ALTER DATABASE, ALTER TRIGGER, CHECK POINT, CREATE
CONVERSION, CREATE DOMAIN, CREATE LANGUAGE, DEALLOCATE, DROP CONVERSION,
DROP DOMAIN, DROP LANGUAGE, EXECUTE, PREPARE
Complete CAST in CREATE CAST and DROP CAST but doesn't suggest what
should follow.
Add many more SET / SHOW variables to the list. Taken from SHOW ALL
output.
Complete a case sensitive search to allow \dD, \dd, \dS, \ds, \h, \H to
complete properly. But there are no matches, then try a case
insensitive search to allow case conversion. Add all missing help
options.
\Q<tab> -> \q
\dD<tab> -> \dD
\dd<tab> -> \dd
\D<tab><tab><tab> -> \d (with listing of \d? commands)
sel<tab> -> SELECT
Rod Taylor
2002-11-15 04:07:52 +01:00
" australian_timezones " ,
2003-01-10 23:03:30 +01:00
" client_encoding " ,
Commit to match discussed elog() changes. Only update is that LOG is
now just below FATAL in server_min_messages. Added more text to
highlight ordering difference between it and client_min_messages.
---------------------------------------------------------------------------
REALLYFATAL => PANIC
STOP => PANIC
New INFO level the prints to client by default
New LOG level the prints to server log by default
Cause VACUUM information to print only to the client
NOTICE => INFO where purely information messages are sent
DEBUG => LOG for purely server status messages
DEBUG removed, kept as backward compatible
DEBUG5, DEBUG4, DEBUG3, DEBUG2, DEBUG1 added
DebugLvl removed in favor of new DEBUG[1-5] symbols
New server_min_messages GUC parameter with values:
DEBUG[5-1], INFO, NOTICE, ERROR, LOG, FATAL, PANIC
New client_min_messages GUC parameter with values:
DEBUG[5-1], LOG, INFO, NOTICE, ERROR, FATAL, PANIC
Server startup now logged with LOG instead of DEBUG
Remove debug_level GUC parameter
elog() numbers now start at 10
Add test to print error message if older elog() values are passed to elog()
Bootstrap mode now has a -d that requires an argument, like postmaster
2002-03-02 22:39:36 +01:00
" client_min_messages " ,
Clean up psql:
Add simple ALTER DATABASE, ALTER TRIGGER, CHECK POINT, CREATE
CONVERSION, CREATE DOMAIN, CREATE LANGUAGE, DEALLOCATE, DROP CONVERSION,
DROP DOMAIN, DROP LANGUAGE, EXECUTE, PREPARE
Complete CAST in CREATE CAST and DROP CAST but doesn't suggest what
should follow.
Add many more SET / SHOW variables to the list. Taken from SHOW ALL
output.
Complete a case sensitive search to allow \dD, \dd, \dS, \ds, \h, \H to
complete properly. But there are no matches, then try a case
insensitive search to allow case conversion. Add all missing help
options.
\Q<tab> -> \q
\dD<tab> -> \dD
\dd<tab> -> \dd
\D<tab><tab><tab> -> \d (with listing of \d? commands)
sel<tab> -> SELECT
Rod Taylor
2002-11-15 04:07:52 +01:00
" commit_delay " ,
" commit_siblings " ,
" cpu_index_tuple_cost " ,
" cpu_operator_cost " ,
" cpu_tuple_cost " ,
2003-01-10 23:03:30 +01:00
" DateStyle " ,
Clean up psql:
Add simple ALTER DATABASE, ALTER TRIGGER, CHECK POINT, CREATE
CONVERSION, CREATE DOMAIN, CREATE LANGUAGE, DEALLOCATE, DROP CONVERSION,
DROP DOMAIN, DROP LANGUAGE, EXECUTE, PREPARE
Complete CAST in CREATE CAST and DROP CAST but doesn't suggest what
should follow.
Add many more SET / SHOW variables to the list. Taken from SHOW ALL
output.
Complete a case sensitive search to allow \dD, \dd, \dS, \ds, \h, \H to
complete properly. But there are no matches, then try a case
insensitive search to allow case conversion. Add all missing help
options.
\Q<tab> -> \q
\dD<tab> -> \dD
\dd<tab> -> \dd
\D<tab><tab><tab> -> \d (with listing of \d? commands)
sel<tab> -> SELECT
Rod Taylor
2002-11-15 04:07:52 +01:00
" deadlock_timeout " ,
" debug_pretty_print " ,
2000-12-03 15:36:47 +01:00
" debug_print_parse " ,
" debug_print_plan " ,
Clean up psql:
Add simple ALTER DATABASE, ALTER TRIGGER, CHECK POINT, CREATE
CONVERSION, CREATE DOMAIN, CREATE LANGUAGE, DEALLOCATE, DROP CONVERSION,
DROP DOMAIN, DROP LANGUAGE, EXECUTE, PREPARE
Complete CAST in CREATE CAST and DROP CAST but doesn't suggest what
should follow.
Add many more SET / SHOW variables to the list. Taken from SHOW ALL
output.
Complete a case sensitive search to allow \dD, \dd, \dS, \ds, \h, \H to
complete properly. But there are no matches, then try a case
insensitive search to allow case conversion. Add all missing help
options.
\Q<tab> -> \q
\dD<tab> -> \dD
\dd<tab> -> \dd
\D<tab><tab><tab> -> \d (with listing of \d? commands)
sel<tab> -> SELECT
Rod Taylor
2002-11-15 04:07:52 +01:00
" debug_print_rewritten " ,
2002-07-31 19:19:54 +02:00
" default_statistics_target " ,
Clean up psql:
Add simple ALTER DATABASE, ALTER TRIGGER, CHECK POINT, CREATE
CONVERSION, CREATE DOMAIN, CREATE LANGUAGE, DEALLOCATE, DROP CONVERSION,
DROP DOMAIN, DROP LANGUAGE, EXECUTE, PREPARE
Complete CAST in CREATE CAST and DROP CAST but doesn't suggest what
should follow.
Add many more SET / SHOW variables to the list. Taken from SHOW ALL
output.
Complete a case sensitive search to allow \dD, \dd, \dS, \ds, \h, \H to
complete properly. But there are no matches, then try a case
insensitive search to allow case conversion. Add all missing help
options.
\Q<tab> -> \q
\dD<tab> -> \dD
\dd<tab> -> \dd
\D<tab><tab><tab> -> \d (with listing of \d? commands)
sel<tab> -> SELECT
Rod Taylor
2002-11-15 04:07:52 +01:00
" default_transaction_isolation " ,
2003-02-06 21:25:33 +01:00
" default_transaction_read_only " ,
Clean up psql:
Add simple ALTER DATABASE, ALTER TRIGGER, CHECK POINT, CREATE
CONVERSION, CREATE DOMAIN, CREATE LANGUAGE, DEALLOCATE, DROP CONVERSION,
DROP DOMAIN, DROP LANGUAGE, EXECUTE, PREPARE
Complete CAST in CREATE CAST and DROP CAST but doesn't suggest what
should follow.
Add many more SET / SHOW variables to the list. Taken from SHOW ALL
output.
Complete a case sensitive search to allow \dD, \dd, \dS, \ds, \h, \H to
complete properly. But there are no matches, then try a case
insensitive search to allow case conversion. Add all missing help
options.
\Q<tab> -> \q
\dD<tab> -> \dD
\dd<tab> -> \dd
\D<tab><tab><tab> -> \d (with listing of \d? commands)
sel<tab> -> SELECT
Rod Taylor
2002-11-15 04:07:52 +01:00
" dynamic_library_path " ,
" effective_cache_size " ,
2003-02-06 21:25:33 +01:00
" enable_hashagg " ,
Clean up psql:
Add simple ALTER DATABASE, ALTER TRIGGER, CHECK POINT, CREATE
CONVERSION, CREATE DOMAIN, CREATE LANGUAGE, DEALLOCATE, DROP CONVERSION,
DROP DOMAIN, DROP LANGUAGE, EXECUTE, PREPARE
Complete CAST in CREATE CAST and DROP CAST but doesn't suggest what
should follow.
Add many more SET / SHOW variables to the list. Taken from SHOW ALL
output.
Complete a case sensitive search to allow \dD, \dd, \dS, \ds, \h, \H to
complete properly. But there are no matches, then try a case
insensitive search to allow case conversion. Add all missing help
options.
\Q<tab> -> \q
\dD<tab> -> \dD
\dd<tab> -> \dd
\D<tab><tab><tab> -> \d (with listing of \d? commands)
sel<tab> -> SELECT
Rod Taylor
2002-11-15 04:07:52 +01:00
" enable_hashjoin " ,
" enable_indexscan " ,
" enable_mergejoin " ,
" enable_nestloop " ,
" enable_seqscan " ,
" enable_sort " ,
" enable_tidscan " ,
" explain_pretty_print " ,
" extra_float_digits " ,
2003-01-26 00:10:30 +01:00
" from_collapse_limit " ,
Clean up psql:
Add simple ALTER DATABASE, ALTER TRIGGER, CHECK POINT, CREATE
CONVERSION, CREATE DOMAIN, CREATE LANGUAGE, DEALLOCATE, DROP CONVERSION,
DROP DOMAIN, DROP LANGUAGE, EXECUTE, PREPARE
Complete CAST in CREATE CAST and DROP CAST but doesn't suggest what
should follow.
Add many more SET / SHOW variables to the list. Taken from SHOW ALL
output.
Complete a case sensitive search to allow \dD, \dd, \dS, \ds, \h, \H to
complete properly. But there are no matches, then try a case
insensitive search to allow case conversion. Add all missing help
options.
\Q<tab> -> \q
\dD<tab> -> \dD
\dd<tab> -> \dd
\D<tab><tab><tab> -> \d (with listing of \d? commands)
sel<tab> -> SELECT
Rod Taylor
2002-11-15 04:07:52 +01:00
" fsync " ,
" geqo " ,
2000-12-03 15:36:47 +01:00
" geqo_effort " ,
" geqo_generations " ,
Clean up psql:
Add simple ALTER DATABASE, ALTER TRIGGER, CHECK POINT, CREATE
CONVERSION, CREATE DOMAIN, CREATE LANGUAGE, DEALLOCATE, DROP CONVERSION,
DROP DOMAIN, DROP LANGUAGE, EXECUTE, PREPARE
Complete CAST in CREATE CAST and DROP CAST but doesn't suggest what
should follow.
Add many more SET / SHOW variables to the list. Taken from SHOW ALL
output.
Complete a case sensitive search to allow \dD, \dd, \dS, \ds, \h, \H to
complete properly. But there are no matches, then try a case
insensitive search to allow case conversion. Add all missing help
options.
\Q<tab> -> \q
\dD<tab> -> \dD
\dd<tab> -> \dd
\D<tab><tab><tab> -> \d (with listing of \d? commands)
sel<tab> -> SELECT
Rod Taylor
2002-11-15 04:07:52 +01:00
" geqo_pool_size " ,
2000-12-03 15:36:47 +01:00
" geqo_random_seed " ,
Clean up psql:
Add simple ALTER DATABASE, ALTER TRIGGER, CHECK POINT, CREATE
CONVERSION, CREATE DOMAIN, CREATE LANGUAGE, DEALLOCATE, DROP CONVERSION,
DROP DOMAIN, DROP LANGUAGE, EXECUTE, PREPARE
Complete CAST in CREATE CAST and DROP CAST but doesn't suggest what
should follow.
Add many more SET / SHOW variables to the list. Taken from SHOW ALL
output.
Complete a case sensitive search to allow \dD, \dd, \dS, \ds, \h, \H to
complete properly. But there are no matches, then try a case
insensitive search to allow case conversion. Add all missing help
options.
\Q<tab> -> \q
\dD<tab> -> \dD
\dd<tab> -> \dd
\D<tab><tab><tab> -> \d (with listing of \d? commands)
sel<tab> -> SELECT
Rod Taylor
2002-11-15 04:07:52 +01:00
" geqo_selection_bias " ,
" geqo_threshold " ,
2003-01-26 00:10:30 +01:00
" join_collapse_limit " ,
Clean up psql:
Add simple ALTER DATABASE, ALTER TRIGGER, CHECK POINT, CREATE
CONVERSION, CREATE DOMAIN, CREATE LANGUAGE, DEALLOCATE, DROP CONVERSION,
DROP DOMAIN, DROP LANGUAGE, EXECUTE, PREPARE
Complete CAST in CREATE CAST and DROP CAST but doesn't suggest what
should follow.
Add many more SET / SHOW variables to the list. Taken from SHOW ALL
output.
Complete a case sensitive search to allow \dD, \dd, \dS, \ds, \h, \H to
complete properly. But there are no matches, then try a case
insensitive search to allow case conversion. Add all missing help
options.
\Q<tab> -> \q
\dD<tab> -> \dD
\dd<tab> -> \dd
\D<tab><tab><tab> -> \d (with listing of \d? commands)
sel<tab> -> SELECT
Rod Taylor
2002-11-15 04:07:52 +01:00
" krb_server_keyfile " ,
" lc_messages " ,
" lc_monetary " ,
" lc_numeric " ,
2003-01-10 23:03:30 +01:00
" lc_time " ,
Clean up psql:
Add simple ALTER DATABASE, ALTER TRIGGER, CHECK POINT, CREATE
CONVERSION, CREATE DOMAIN, CREATE LANGUAGE, DEALLOCATE, DROP CONVERSION,
DROP DOMAIN, DROP LANGUAGE, EXECUTE, PREPARE
Complete CAST in CREATE CAST and DROP CAST but doesn't suggest what
should follow.
Add many more SET / SHOW variables to the list. Taken from SHOW ALL
output.
Complete a case sensitive search to allow \dD, \dd, \dS, \ds, \h, \H to
complete properly. But there are no matches, then try a case
insensitive search to allow case conversion. Add all missing help
options.
\Q<tab> -> \q
\dD<tab> -> \dD
\dd<tab> -> \dd
\D<tab><tab><tab> -> \d (with listing of \d? commands)
sel<tab> -> SELECT
Rod Taylor
2002-11-15 04:07:52 +01:00
" log_duration " ,
2003-02-06 21:25:33 +01:00
" log_executor_stats " ,
2003-06-11 20:01:14 +02:00
" log_min_duration_statement " ,
Clean up psql:
Add simple ALTER DATABASE, ALTER TRIGGER, CHECK POINT, CREATE
CONVERSION, CREATE DOMAIN, CREATE LANGUAGE, DEALLOCATE, DROP CONVERSION,
DROP DOMAIN, DROP LANGUAGE, EXECUTE, PREPARE
Complete CAST in CREATE CAST and DROP CAST but doesn't suggest what
should follow.
Add many more SET / SHOW variables to the list. Taken from SHOW ALL
output.
Complete a case sensitive search to allow \dD, \dd, \dS, \ds, \h, \H to
complete properly. But there are no matches, then try a case
insensitive search to allow case conversion. Add all missing help
options.
\Q<tab> -> \q
\dD<tab> -> \dD
\dd<tab> -> \dd
\D<tab><tab><tab> -> \d (with listing of \d? commands)
sel<tab> -> SELECT
Rod Taylor
2002-11-15 04:07:52 +01:00
" log_min_error_statement " ,
2003-02-06 21:25:33 +01:00
" log_min_messages " ,
" log_parser_stats " ,
" log_planner_stats " ,
Clean up psql:
Add simple ALTER DATABASE, ALTER TRIGGER, CHECK POINT, CREATE
CONVERSION, CREATE DOMAIN, CREATE LANGUAGE, DEALLOCATE, DROP CONVERSION,
DROP DOMAIN, DROP LANGUAGE, EXECUTE, PREPARE
Complete CAST in CREATE CAST and DROP CAST but doesn't suggest what
should follow.
Add many more SET / SHOW variables to the list. Taken from SHOW ALL
output.
Complete a case sensitive search to allow \dD, \dd, \dS, \ds, \h, \H to
complete properly. But there are no matches, then try a case
insensitive search to allow case conversion. Add all missing help
options.
\Q<tab> -> \q
\dD<tab> -> \dD
\dd<tab> -> \dd
\D<tab><tab><tab> -> \d (with listing of \d? commands)
sel<tab> -> SELECT
Rod Taylor
2002-11-15 04:07:52 +01:00
" log_statement " ,
2003-02-06 21:25:33 +01:00
" log_statement_stats " ,
Clean up psql:
Add simple ALTER DATABASE, ALTER TRIGGER, CHECK POINT, CREATE
CONVERSION, CREATE DOMAIN, CREATE LANGUAGE, DEALLOCATE, DROP CONVERSION,
DROP DOMAIN, DROP LANGUAGE, EXECUTE, PREPARE
Complete CAST in CREATE CAST and DROP CAST but doesn't suggest what
should follow.
Add many more SET / SHOW variables to the list. Taken from SHOW ALL
output.
Complete a case sensitive search to allow \dD, \dd, \dS, \ds, \h, \H to
complete properly. But there are no matches, then try a case
insensitive search to allow case conversion. Add all missing help
options.
\Q<tab> -> \q
\dD<tab> -> \dD
\dd<tab> -> \dd
\D<tab><tab><tab> -> \d (with listing of \d? commands)
sel<tab> -> SELECT
Rod Taylor
2002-11-15 04:07:52 +01:00
" max_connections " ,
2000-03-17 06:29:07 +01:00
" max_expr_depth " ,
Clean up psql:
Add simple ALTER DATABASE, ALTER TRIGGER, CHECK POINT, CREATE
CONVERSION, CREATE DOMAIN, CREATE LANGUAGE, DEALLOCATE, DROP CONVERSION,
DROP DOMAIN, DROP LANGUAGE, EXECUTE, PREPARE
Complete CAST in CREATE CAST and DROP CAST but doesn't suggest what
should follow.
Add many more SET / SHOW variables to the list. Taken from SHOW ALL
output.
Complete a case sensitive search to allow \dD, \dd, \dS, \ds, \h, \H to
complete properly. But there are no matches, then try a case
insensitive search to allow case conversion. Add all missing help
options.
\Q<tab> -> \q
\dD<tab> -> \dD
\dd<tab> -> \dd
\D<tab><tab><tab> -> \d (with listing of \d? commands)
sel<tab> -> SELECT
Rod Taylor
2002-11-15 04:07:52 +01:00
" max_files_per_process " ,
" max_fsm_pages " ,
" max_fsm_relations " ,
" max_locks_per_transaction " ,
" password_encryption " ,
" port " ,
2000-06-25 16:25:51 +02:00
" random_page_cost " ,
2003-02-06 21:25:33 +01:00
" regex_flavor " ,
2002-04-01 05:34:27 +02:00
" search_path " ,
Clean up psql:
Add simple ALTER DATABASE, ALTER TRIGGER, CHECK POINT, CREATE
CONVERSION, CREATE DOMAIN, CREATE LANGUAGE, DEALLOCATE, DROP CONVERSION,
DROP DOMAIN, DROP LANGUAGE, EXECUTE, PREPARE
Complete CAST in CREATE CAST and DROP CAST but doesn't suggest what
should follow.
Add many more SET / SHOW variables to the list. Taken from SHOW ALL
output.
Complete a case sensitive search to allow \dD, \dd, \dS, \ds, \h, \H to
complete properly. But there are no matches, then try a case
insensitive search to allow case conversion. Add all missing help
options.
\Q<tab> -> \q
\dD<tab> -> \dD
\dd<tab> -> \dd
\D<tab><tab><tab> -> \d (with listing of \d? commands)
sel<tab> -> SELECT
Rod Taylor
2002-11-15 04:07:52 +01:00
" shared_buffers " ,
2003-01-10 23:03:30 +01:00
" seed " ,
" server_encoding " ,
Clean up psql:
Add simple ALTER DATABASE, ALTER TRIGGER, CHECK POINT, CREATE
CONVERSION, CREATE DOMAIN, CREATE LANGUAGE, DEALLOCATE, DROP CONVERSION,
DROP DOMAIN, DROP LANGUAGE, EXECUTE, PREPARE
Complete CAST in CREATE CAST and DROP CAST but doesn't suggest what
should follow.
Add many more SET / SHOW variables to the list. Taken from SHOW ALL
output.
Complete a case sensitive search to allow \dD, \dd, \dS, \ds, \h, \H to
complete properly. But there are no matches, then try a case
insensitive search to allow case conversion. Add all missing help
options.
\Q<tab> -> \q
\dD<tab> -> \dD
\dd<tab> -> \dd
\D<tab><tab><tab> -> \d (with listing of \d? commands)
sel<tab> -> SELECT
Rod Taylor
2002-11-15 04:07:52 +01:00
" sort_mem " ,
" sql_inheritance " ,
" ssl " ,
2002-07-13 03:02:14 +02:00
" statement_timeout " ,
Clean up psql:
Add simple ALTER DATABASE, ALTER TRIGGER, CHECK POINT, CREATE
CONVERSION, CREATE DOMAIN, CREATE LANGUAGE, DEALLOCATE, DROP CONVERSION,
DROP DOMAIN, DROP LANGUAGE, EXECUTE, PREPARE
Complete CAST in CREATE CAST and DROP CAST but doesn't suggest what
should follow.
Add many more SET / SHOW variables to the list. Taken from SHOW ALL
output.
Complete a case sensitive search to allow \dD, \dd, \dS, \ds, \h, \H to
complete properly. But there are no matches, then try a case
insensitive search to allow case conversion. Add all missing help
options.
\Q<tab> -> \q
\dD<tab> -> \dD
\dd<tab> -> \dd
\D<tab><tab><tab> -> \d (with listing of \d? commands)
sel<tab> -> SELECT
Rod Taylor
2002-11-15 04:07:52 +01:00
" stats_block_level " ,
" stats_command_string " ,
" stats_reset_on_server_start " ,
" stats_row_level " ,
" stats_start_collector " ,
" superuser_reserved_connections " ,
" syslog " ,
" syslog_facility " ,
" syslog_ident " ,
" tcpip_socket " ,
2003-01-10 23:03:30 +01:00
" TimeZone " ,
Clean up psql:
Add simple ALTER DATABASE, ALTER TRIGGER, CHECK POINT, CREATE
CONVERSION, CREATE DOMAIN, CREATE LANGUAGE, DEALLOCATE, DROP CONVERSION,
DROP DOMAIN, DROP LANGUAGE, EXECUTE, PREPARE
Complete CAST in CREATE CAST and DROP CAST but doesn't suggest what
should follow.
Add many more SET / SHOW variables to the list. Taken from SHOW ALL
output.
Complete a case sensitive search to allow \dD, \dd, \dS, \ds, \h, \H to
complete properly. But there are no matches, then try a case
insensitive search to allow case conversion. Add all missing help
options.
\Q<tab> -> \q
\dD<tab> -> \dD
\dd<tab> -> \dd
\D<tab><tab><tab> -> \d (with listing of \d? commands)
sel<tab> -> SELECT
Rod Taylor
2002-11-15 04:07:52 +01:00
" trace_notify " ,
" transform_null_equals " ,
" unix_socket_directory " ,
" unix_socket_group " ,
" unix_socket_permissions " ,
" vacuum_mem " ,
" wal_buffers " ,
" wal_debug " ,
" wal_sync_method " ,
2000-04-12 19:17:23 +02:00
NULL
} ;
* Includes tab completion. It's not magic, but it's very cool. At any
rate
it's better than what used to be there.
* Does proper SQL "host variable" substitution as pointed out by Andreas
Zeugwetter (thanks): select * from :foo; Also some changes in how ':'
and ';' are treated (escape with \ to send to backend). This does
_not_
affect the '::' cast operator, but perhaps others that contain : or ;
(but there are none right now).
* To show description with a <something> listing, append '?' to command
name, e.g., \df?. This seemed to be the convenient and logical
solution.
Or append a '+' to see more useless information, e.g., \df+.
* Fixed fflush()'ing bug pointed out by Jan during the regression test
discussion.
* Added LastOid variable. This ought to take care of TODO item "Add a
function to return the last inserted oid, for use in psql scripts"
(under CLIENTS)
E.g.,
insert into foo values(...);
insert into bar values(..., :LastOid);
\echo $LastOid
* \d command shows constraints, rules, and triggers defined on the table
(in addition to indices)
* Various fixes, optimizations, corrections
* Documentation update as well
Note: This now requires snprintf(), which, if necessary, is taken from
src/backend/port. This is certainly a little weird, but it should
suffice
until a source tree cleanup is done.
Enjoy.
--
Peter Eisentraut Sernanders väg 10:115
1999-11-26 05:24:17 +01:00
2000-04-12 19:17:23 +02:00
static char * backslash_commands [ ] = {
Clean up psql:
Add simple ALTER DATABASE, ALTER TRIGGER, CHECK POINT, CREATE
CONVERSION, CREATE DOMAIN, CREATE LANGUAGE, DEALLOCATE, DROP CONVERSION,
DROP DOMAIN, DROP LANGUAGE, EXECUTE, PREPARE
Complete CAST in CREATE CAST and DROP CAST but doesn't suggest what
should follow.
Add many more SET / SHOW variables to the list. Taken from SHOW ALL
output.
Complete a case sensitive search to allow \dD, \dd, \dS, \ds, \h, \H to
complete properly. But there are no matches, then try a case
insensitive search to allow case conversion. Add all missing help
options.
\Q<tab> -> \q
\dD<tab> -> \dD
\dd<tab> -> \dd
\D<tab><tab><tab> -> \d (with listing of \d? commands)
sel<tab> -> SELECT
Rod Taylor
2002-11-15 04:07:52 +01:00
" \\ a " , " \\ connect " , " \\ C " , " \\ cd " , " \\ copy " , " \\ copyright " ,
2003-03-27 17:45:01 +01:00
" \\ d " , " \\ da " , " \\ dc " , " \\ dC " , " \\ dd " , " \\ dD " , " \\ df " , " \\ di " ,
" \\ dl " , " \\ dn " , " \\ do " , " \\ dp " , " \\ ds " , " \\ dS " , " \\ dt " , " \\ dT " ,
" \\ dv " , " \\ du " ,
Clean up psql:
Add simple ALTER DATABASE, ALTER TRIGGER, CHECK POINT, CREATE
CONVERSION, CREATE DOMAIN, CREATE LANGUAGE, DEALLOCATE, DROP CONVERSION,
DROP DOMAIN, DROP LANGUAGE, EXECUTE, PREPARE
Complete CAST in CREATE CAST and DROP CAST but doesn't suggest what
should follow.
Add many more SET / SHOW variables to the list. Taken from SHOW ALL
output.
Complete a case sensitive search to allow \dD, \dd, \dS, \ds, \h, \H to
complete properly. But there are no matches, then try a case
insensitive search to allow case conversion. Add all missing help
options.
\Q<tab> -> \q
\dD<tab> -> \dD
\dd<tab> -> \dd
\D<tab><tab><tab> -> \d (with listing of \d? commands)
sel<tab> -> SELECT
Rod Taylor
2002-11-15 04:07:52 +01:00
" \\ e " , " \\ echo " , " \\ encoding " ,
" \\ f " , " \\ g " , " \\ h " , " \\ help " , " \\ H " , " \\ i " , " \\ l " ,
2000-04-12 19:17:23 +02:00
" \\ lo_import " , " \\ lo_export " , " \\ lo_list " , " \\ lo_unlink " ,
Clean up psql:
Add simple ALTER DATABASE, ALTER TRIGGER, CHECK POINT, CREATE
CONVERSION, CREATE DOMAIN, CREATE LANGUAGE, DEALLOCATE, DROP CONVERSION,
DROP DOMAIN, DROP LANGUAGE, EXECUTE, PREPARE
Complete CAST in CREATE CAST and DROP CAST but doesn't suggest what
should follow.
Add many more SET / SHOW variables to the list. Taken from SHOW ALL
output.
Complete a case sensitive search to allow \dD, \dd, \dS, \ds, \h, \H to
complete properly. But there are no matches, then try a case
insensitive search to allow case conversion. Add all missing help
options.
\Q<tab> -> \q
\dD<tab> -> \dD
\dd<tab> -> \dd
\D<tab><tab><tab> -> \d (with listing of \d? commands)
sel<tab> -> SELECT
Rod Taylor
2002-11-15 04:07:52 +01:00
" \\ o " , " \\ p " , " \\ pset " , " \\ q " , " \\ qecho " , " \\ r " , " \\ set " , " \\ t " , " \\ T " ,
2002-03-05 01:01:03 +01:00
" \\ timing " , " \\ unset " , " \\ x " , " \\ w " , " \\ z " , " \\ ! " , NULL
2000-04-12 19:17:23 +02:00
} ;
* Includes tab completion. It's not magic, but it's very cool. At any
rate
it's better than what used to be there.
* Does proper SQL "host variable" substitution as pointed out by Andreas
Zeugwetter (thanks): select * from :foo; Also some changes in how ':'
and ';' are treated (escape with \ to send to backend). This does
_not_
affect the '::' cast operator, but perhaps others that contain : or ;
(but there are none right now).
* To show description with a <something> listing, append '?' to command
name, e.g., \df?. This seemed to be the convenient and logical
solution.
Or append a '+' to see more useless information, e.g., \df+.
* Fixed fflush()'ing bug pointed out by Jan during the regression test
discussion.
* Added LastOid variable. This ought to take care of TODO item "Add a
function to return the last inserted oid, for use in psql scripts"
(under CLIENTS)
E.g.,
insert into foo values(...);
insert into bar values(..., :LastOid);
\echo $LastOid
* \d command shows constraints, rules, and triggers defined on the table
(in addition to indices)
* Various fixes, optimizations, corrections
* Documentation update as well
Note: This now requires snprintf(), which, if necessary, is taken from
src/backend/port. This is certainly a little weird, but it should
suffice
until a source tree cleanup is done.
Enjoy.
--
Peter Eisentraut Sernanders väg 10:115
1999-11-26 05:24:17 +01:00
2000-04-12 19:17:23 +02:00
( void ) end ; /* not used */
* Includes tab completion. It's not magic, but it's very cool. At any
rate
it's better than what used to be there.
* Does proper SQL "host variable" substitution as pointed out by Andreas
Zeugwetter (thanks): select * from :foo; Also some changes in how ':'
and ';' are treated (escape with \ to send to backend). This does
_not_
affect the '::' cast operator, but perhaps others that contain : or ;
(but there are none right now).
* To show description with a <something> listing, append '?' to command
name, e.g., \df?. This seemed to be the convenient and logical
solution.
Or append a '+' to see more useless information, e.g., \df+.
* Fixed fflush()'ing bug pointed out by Jan during the regression test
discussion.
* Added LastOid variable. This ought to take care of TODO item "Add a
function to return the last inserted oid, for use in psql scripts"
(under CLIENTS)
E.g.,
insert into foo values(...);
insert into bar values(..., :LastOid);
\echo $LastOid
* \d command shows constraints, rules, and triggers defined on the table
(in addition to indices)
* Various fixes, optimizations, corrections
* Documentation update as well
Note: This now requires snprintf(), which, if necessary, is taken from
src/backend/port. This is certainly a little weird, but it should
suffice
until a source tree cleanup is done.
Enjoy.
--
Peter Eisentraut Sernanders väg 10:115
1999-11-26 05:24:17 +01:00
2000-02-20 15:28:28 +01:00
# ifdef HAVE_RL_COMPLETION_APPEND_CHARACTER
2000-04-12 19:17:23 +02:00
rl_completion_append_character = ' ' ;
2000-02-20 15:28:28 +01:00
# endif
2000-04-12 19:17:23 +02:00
/* Clear a few things. */
completion_charp = NULL ;
completion_charpp = NULL ;
completion_info_charp = NULL ;
/*
* Scan the input line before our current position for the last four
* words . According to those we ' ll make some smart decisions on what
* the user is probably intending to type . TODO : Use strtokx ( ) to do
* this .
*/
prev_wd = previous_word ( start , 0 ) ;
prev2_wd = previous_word ( start , 1 ) ;
prev3_wd = previous_word ( start , 2 ) ;
prev4_wd = previous_word ( start , 3 ) ;
/* If a backslash command was started, continue */
if ( text [ 0 ] = = ' \\ ' )
COMPLETE_WITH_LIST ( backslash_commands ) ;
/* If no previous word, suggest one of the basic sql commands */
else if ( ! prev_wd )
COMPLETE_WITH_LIST ( sql_commands ) ;
* Includes tab completion. It's not magic, but it's very cool. At any
rate
it's better than what used to be there.
* Does proper SQL "host variable" substitution as pointed out by Andreas
Zeugwetter (thanks): select * from :foo; Also some changes in how ':'
and ';' are treated (escape with \ to send to backend). This does
_not_
affect the '::' cast operator, but perhaps others that contain : or ;
(but there are none right now).
* To show description with a <something> listing, append '?' to command
name, e.g., \df?. This seemed to be the convenient and logical
solution.
Or append a '+' to see more useless information, e.g., \df+.
* Fixed fflush()'ing bug pointed out by Jan during the regression test
discussion.
* Added LastOid variable. This ought to take care of TODO item "Add a
function to return the last inserted oid, for use in psql scripts"
(under CLIENTS)
E.g.,
insert into foo values(...);
insert into bar values(..., :LastOid);
\echo $LastOid
* \d command shows constraints, rules, and triggers defined on the table
(in addition to indices)
* Various fixes, optimizations, corrections
* Documentation update as well
Note: This now requires snprintf(), which, if necessary, is taken from
src/backend/port. This is certainly a little weird, but it should
suffice
until a source tree cleanup is done.
Enjoy.
--
Peter Eisentraut Sernanders väg 10:115
1999-11-26 05:24:17 +01:00
2002-12-13 06:36:24 +01:00
/* CREATE or DROP but not ALTER TABLE sth DROP */
2000-04-12 19:17:23 +02:00
/* complete with something you can create or drop */
2002-12-13 06:36:24 +01:00
else if ( strcasecmp ( prev_wd , " CREATE " ) = = 0 | |
( strcasecmp ( prev_wd , " DROP " ) = = 0 & &
strcasecmp ( prev3_wd , " TABLE " ) ! = 0 ) )
matches = completion_matches ( text , create_command_generator ) ;
* Includes tab completion. It's not magic, but it's very cool. At any
rate
it's better than what used to be there.
* Does proper SQL "host variable" substitution as pointed out by Andreas
Zeugwetter (thanks): select * from :foo; Also some changes in how ':'
and ';' are treated (escape with \ to send to backend). This does
_not_
affect the '::' cast operator, but perhaps others that contain : or ;
(but there are none right now).
* To show description with a <something> listing, append '?' to command
name, e.g., \df?. This seemed to be the convenient and logical
solution.
Or append a '+' to see more useless information, e.g., \df+.
* Fixed fflush()'ing bug pointed out by Jan during the regression test
discussion.
* Added LastOid variable. This ought to take care of TODO item "Add a
function to return the last inserted oid, for use in psql scripts"
(under CLIENTS)
E.g.,
insert into foo values(...);
insert into bar values(..., :LastOid);
\echo $LastOid
* \d command shows constraints, rules, and triggers defined on the table
(in addition to indices)
* Various fixes, optimizations, corrections
* Documentation update as well
Note: This now requires snprintf(), which, if necessary, is taken from
src/backend/port. This is certainly a little weird, but it should
suffice
until a source tree cleanup is done.
Enjoy.
--
Peter Eisentraut Sernanders väg 10:115
1999-11-26 05:24:17 +01:00
/* ALTER */
2002-12-13 06:36:24 +01:00
/* complete with what you can alter (TABLE, GROUP, USER, ...)
* unless we ' re in ALTER TABLE sth ALTER */
else if ( strcasecmp ( prev_wd , " ALTER " ) = = 0 & &
strcasecmp ( prev3_wd , " TABLE " ) ! = 0 )
2000-04-12 19:17:23 +02:00
{
2002-12-13 06:36:24 +01:00
char * list_ALTER [ ] = { " DATABASE " , " GROUP " , " SCHEMA " , " TABLE " ,
" TRIGGER " , " USER " , NULL } ;
2000-04-12 19:17:23 +02:00
COMPLETE_WITH_LIST ( list_ALTER ) ;
}
2001-03-22 05:01:46 +01:00
Clean up psql:
Add simple ALTER DATABASE, ALTER TRIGGER, CHECK POINT, CREATE
CONVERSION, CREATE DOMAIN, CREATE LANGUAGE, DEALLOCATE, DROP CONVERSION,
DROP DOMAIN, DROP LANGUAGE, EXECUTE, PREPARE
Complete CAST in CREATE CAST and DROP CAST but doesn't suggest what
should follow.
Add many more SET / SHOW variables to the list. Taken from SHOW ALL
output.
Complete a case sensitive search to allow \dD, \dd, \dS, \ds, \h, \H to
complete properly. But there are no matches, then try a case
insensitive search to allow case conversion. Add all missing help
options.
\Q<tab> -> \q
\dD<tab> -> \dD
\dd<tab> -> \dd
\D<tab><tab><tab> -> \d (with listing of \d? commands)
sel<tab> -> SELECT
Rod Taylor
2002-11-15 04:07:52 +01:00
/* ALTER DATABASE <name> */
2002-12-13 06:36:24 +01:00
else if ( strcasecmp ( prev3_wd , " ALTER " ) = = 0 & &
strcasecmp ( prev2_wd , " DATABASE " ) = = 0 )
Clean up psql:
Add simple ALTER DATABASE, ALTER TRIGGER, CHECK POINT, CREATE
CONVERSION, CREATE DOMAIN, CREATE LANGUAGE, DEALLOCATE, DROP CONVERSION,
DROP DOMAIN, DROP LANGUAGE, EXECUTE, PREPARE
Complete CAST in CREATE CAST and DROP CAST but doesn't suggest what
should follow.
Add many more SET / SHOW variables to the list. Taken from SHOW ALL
output.
Complete a case sensitive search to allow \dD, \dd, \dS, \ds, \h, \H to
complete properly. But there are no matches, then try a case
insensitive search to allow case conversion. Add all missing help
options.
\Q<tab> -> \q
\dD<tab> -> \dD
\dd<tab> -> \dd
\D<tab><tab><tab> -> \d (with listing of \d? commands)
sel<tab> -> SELECT
Rod Taylor
2002-11-15 04:07:52 +01:00
{
char * list_ALTERDATABASE [ ] = { " RESET " , " SET " , NULL } ;
COMPLETE_WITH_LIST ( list_ALTERDATABASE ) ;
}
/* ALTER TRIGGER <name>, add ON */
2002-12-13 06:36:24 +01:00
else if ( strcasecmp ( prev3_wd , " ALTER " ) = = 0 & &
strcasecmp ( prev2_wd , " TRIGGER " ) = = 0 )
Clean up psql:
Add simple ALTER DATABASE, ALTER TRIGGER, CHECK POINT, CREATE
CONVERSION, CREATE DOMAIN, CREATE LANGUAGE, DEALLOCATE, DROP CONVERSION,
DROP DOMAIN, DROP LANGUAGE, EXECUTE, PREPARE
Complete CAST in CREATE CAST and DROP CAST but doesn't suggest what
should follow.
Add many more SET / SHOW variables to the list. Taken from SHOW ALL
output.
Complete a case sensitive search to allow \dD, \dd, \dS, \ds, \h, \H to
complete properly. But there are no matches, then try a case
insensitive search to allow case conversion. Add all missing help
options.
\Q<tab> -> \q
\dD<tab> -> \dD
\dd<tab> -> \dd
\D<tab><tab><tab> -> \d (with listing of \d? commands)
sel<tab> -> SELECT
Rod Taylor
2002-11-15 04:07:52 +01:00
COMPLETE_WITH_CONST ( " ON " ) ;
/*
* If we have ALTER TRIGGER < sth > ON , then add the correct tablename
*/
2002-12-13 06:36:24 +01:00
else if ( strcasecmp ( prev4_wd , " ALTER " ) = = 0 & &
strcasecmp ( prev3_wd , " TRIGGER " ) = = 0 & &
strcasecmp ( prev_wd , " ON " ) = = 0 )
2003-03-27 17:45:01 +01:00
COMPLETE_WITH_SCHEMA_QUERY ( Query_for_list_of_tables ) ;
Clean up psql:
Add simple ALTER DATABASE, ALTER TRIGGER, CHECK POINT, CREATE
CONVERSION, CREATE DOMAIN, CREATE LANGUAGE, DEALLOCATE, DROP CONVERSION,
DROP DOMAIN, DROP LANGUAGE, EXECUTE, PREPARE
Complete CAST in CREATE CAST and DROP CAST but doesn't suggest what
should follow.
Add many more SET / SHOW variables to the list. Taken from SHOW ALL
output.
Complete a case sensitive search to allow \dD, \dd, \dS, \ds, \h, \H to
complete properly. But there are no matches, then try a case
insensitive search to allow case conversion. Add all missing help
options.
\Q<tab> -> \q
\dD<tab> -> \dD
\dd<tab> -> \dd
\D<tab><tab><tab> -> \d (with listing of \d? commands)
sel<tab> -> SELECT
Rod Taylor
2002-11-15 04:07:52 +01:00
2001-03-22 05:01:46 +01:00
/*
2002-12-13 06:36:24 +01:00
* If we detect ALTER TABLE < name > , suggest either ADD , DROP , ALTER ,
* RENAME , or OWNER
2001-03-22 05:01:46 +01:00
*/
2002-12-13 06:36:24 +01:00
else if ( strcasecmp ( prev3_wd , " ALTER " ) = = 0 & &
strcasecmp ( prev2_wd , " TABLE " ) = = 0 )
2000-04-12 19:17:23 +02:00
{
2002-12-13 06:36:24 +01:00
char * list_ALTER2 [ ] = { " ADD " , " ALTER " , " DROP " , " RENAME " ,
" OWNER TO " , NULL } ;
2000-04-12 19:17:23 +02:00
COMPLETE_WITH_LIST ( list_ALTER2 ) ;
}
2000-06-25 16:25:51 +02:00
/* If we have TABLE <sth> ALTER|RENAME, provide list of columns */
2000-04-12 19:17:23 +02:00
else if ( strcasecmp ( prev3_wd , " TABLE " ) = = 0 & &
2002-12-13 06:36:24 +01:00
( strcasecmp ( prev_wd , " ALTER " ) = = 0 | |
strcasecmp ( prev_wd , " RENAME " ) = = 0 ) )
2000-04-12 19:17:23 +02:00
COMPLETE_WITH_ATTR ( prev2_wd ) ;
* Includes tab completion. It's not magic, but it's very cool. At any
rate
it's better than what used to be there.
* Does proper SQL "host variable" substitution as pointed out by Andreas
Zeugwetter (thanks): select * from :foo; Also some changes in how ':'
and ';' are treated (escape with \ to send to backend). This does
_not_
affect the '::' cast operator, but perhaps others that contain : or ;
(but there are none right now).
* To show description with a <something> listing, append '?' to command
name, e.g., \df?. This seemed to be the convenient and logical
solution.
Or append a '+' to see more useless information, e.g., \df+.
* Fixed fflush()'ing bug pointed out by Jan during the regression test
discussion.
* Added LastOid variable. This ought to take care of TODO item "Add a
function to return the last inserted oid, for use in psql scripts"
(under CLIENTS)
E.g.,
insert into foo values(...);
insert into bar values(..., :LastOid);
\echo $LastOid
* \d command shows constraints, rules, and triggers defined on the table
(in addition to indices)
* Various fixes, optimizations, corrections
* Documentation update as well
Note: This now requires snprintf(), which, if necessary, is taken from
src/backend/port. This is certainly a little weird, but it should
suffice
until a source tree cleanup is done.
Enjoy.
--
Peter Eisentraut Sernanders väg 10:115
1999-11-26 05:24:17 +01:00
2002-12-13 06:36:24 +01:00
/* If we have TABLE <sth> DROP, provide COLUMN or CONSTRAINT */
else if ( strcasecmp ( prev3_wd , " TABLE " ) = = 0 & &
strcasecmp ( prev_wd , " DROP " ) = = 0 )
{
char * list_TABLEDROP [ ] = { " COLUMN " , " CONSTRAINT " , NULL } ;
COMPLETE_WITH_LIST ( list_TABLEDROP ) ;
}
/* If we have TABLE <sth> DROP COLUMN, provide list of columns */
else if ( strcasecmp ( prev4_wd , " TABLE " ) = = 0 & &
strcasecmp ( prev2_wd , " DROP " ) = = 0 & &
strcasecmp ( prev_wd , " COLUMN " ) = = 0 )
COMPLETE_WITH_ATTR ( prev3_wd ) ;
2000-06-25 16:25:51 +02:00
/* complete ALTER GROUP <foo> with ADD or DROP */
2002-12-13 06:36:24 +01:00
else if ( strcasecmp ( prev3_wd , " ALTER " ) = = 0 & &
strcasecmp ( prev2_wd , " GROUP " ) = = 0 )
2000-06-25 16:25:51 +02:00
{
char * list_ALTERGROUP [ ] = { " ADD " , " DROP " , NULL } ;
2001-03-22 05:01:46 +01:00
2000-06-25 16:25:51 +02:00
COMPLETE_WITH_LIST ( list_ALTERGROUP ) ;
}
/* complete ALTER GROUP <foo> ADD|DROP with USER */
2002-12-13 06:36:24 +01:00
else if ( strcasecmp ( prev4_wd , " ALTER " ) = = 0 & &
strcasecmp ( prev3_wd , " GROUP " ) = = 0 & &
( strcasecmp ( prev_wd , " ADD " ) = = 0 | |
strcasecmp ( prev_wd , " DROP " ) = = 0 ) )
2000-06-25 16:25:51 +02:00
COMPLETE_WITH_CONST ( " USER " ) ;
/* complete {ALTER} GROUP <foo> ADD|DROP USER with a user name */
2002-12-13 06:36:24 +01:00
else if ( strcasecmp ( prev4_wd , " GROUP " ) = = 0 & &
( strcasecmp ( prev2_wd , " ADD " ) = = 0 | |
strcasecmp ( prev2_wd , " DROP " ) = = 0 ) & &
strcasecmp ( prev_wd , " USER " ) = = 0 )
2000-06-25 16:25:51 +02:00
COMPLETE_WITH_QUERY ( Query_for_list_of_users ) ;
2002-08-15 04:49:04 +02:00
/* ANALYZE */
/* If the previous word is ANALYZE, produce list of tables. */
else if ( strcasecmp ( prev_wd , " ANALYZE " ) = = 0 )
2003-03-27 17:45:01 +01:00
COMPLETE_WITH_SCHEMA_QUERY ( Query_for_list_of_tables ) ;
2002-08-15 04:49:04 +02:00
/* If we have ANALYZE <table>, complete with semicolon. */
else if ( strcasecmp ( prev2_wd , " ANALYZE " ) = = 0 )
COMPLETE_WITH_CONST ( " ; " ) ;
* Includes tab completion. It's not magic, but it's very cool. At any
rate
it's better than what used to be there.
* Does proper SQL "host variable" substitution as pointed out by Andreas
Zeugwetter (thanks): select * from :foo; Also some changes in how ':'
and ';' are treated (escape with \ to send to backend). This does
_not_
affect the '::' cast operator, but perhaps others that contain : or ;
(but there are none right now).
* To show description with a <something> listing, append '?' to command
name, e.g., \df?. This seemed to be the convenient and logical
solution.
Or append a '+' to see more useless information, e.g., \df+.
* Fixed fflush()'ing bug pointed out by Jan during the regression test
discussion.
* Added LastOid variable. This ought to take care of TODO item "Add a
function to return the last inserted oid, for use in psql scripts"
(under CLIENTS)
E.g.,
insert into foo values(...);
insert into bar values(..., :LastOid);
\echo $LastOid
* \d command shows constraints, rules, and triggers defined on the table
(in addition to indices)
* Various fixes, optimizations, corrections
* Documentation update as well
Note: This now requires snprintf(), which, if necessary, is taken from
src/backend/port. This is certainly a little weird, but it should
suffice
until a source tree cleanup is done.
Enjoy.
--
Peter Eisentraut Sernanders väg 10:115
1999-11-26 05:24:17 +01:00
/* CLUSTER */
2000-04-12 19:17:23 +02:00
/* If the previous word is CLUSTER, produce list of indexes. */
else if ( strcasecmp ( prev_wd , " CLUSTER " ) = = 0 )
2003-03-27 17:45:01 +01:00
COMPLETE_WITH_SCHEMA_QUERY ( Query_for_list_of_indexes ) ;
2000-04-12 19:17:23 +02:00
/* If we have CLUSTER <sth>, then add "ON" */
else if ( strcasecmp ( prev2_wd , " CLUSTER " ) = = 0 )
COMPLETE_WITH_CONST ( " ON " ) ;
/*
* If we have CLUSTER < sth > ON , then add the correct tablename as
* well .
*/
2002-12-13 06:36:24 +01:00
else if ( strcasecmp ( prev3_wd , " CLUSTER " ) = = 0 & &
strcasecmp ( prev_wd , " ON " ) = = 0 )
2000-04-12 19:17:23 +02:00
{
char query_buffer [ BUF_SIZE ] ; /* Some room to build
* queries . */
if ( snprintf ( query_buffer , BUF_SIZE ,
2002-08-10 05:56:24 +02:00
" SELECT c1.relname FROM pg_catalog.pg_class c1, pg_catalog.pg_class c2, pg_catalog.pg_index i WHERE c1.oid=i.indrelid and i.indexrelid=c2.oid and c2.relname='%s' and pg_catalog.pg_table_is_visible(c2.oid) " ,
2000-04-12 19:17:23 +02:00
prev2_wd ) = = - 1 )
ERROR_QUERY_TOO_LONG ;
else
COMPLETE_WITH_QUERY ( query_buffer ) ;
}
* Includes tab completion. It's not magic, but it's very cool. At any
rate
it's better than what used to be there.
* Does proper SQL "host variable" substitution as pointed out by Andreas
Zeugwetter (thanks): select * from :foo; Also some changes in how ':'
and ';' are treated (escape with \ to send to backend). This does
_not_
affect the '::' cast operator, but perhaps others that contain : or ;
(but there are none right now).
* To show description with a <something> listing, append '?' to command
name, e.g., \df?. This seemed to be the convenient and logical
solution.
Or append a '+' to see more useless information, e.g., \df+.
* Fixed fflush()'ing bug pointed out by Jan during the regression test
discussion.
* Added LastOid variable. This ought to take care of TODO item "Add a
function to return the last inserted oid, for use in psql scripts"
(under CLIENTS)
E.g.,
insert into foo values(...);
insert into bar values(..., :LastOid);
\echo $LastOid
* \d command shows constraints, rules, and triggers defined on the table
(in addition to indices)
* Various fixes, optimizations, corrections
* Documentation update as well
Note: This now requires snprintf(), which, if necessary, is taken from
src/backend/port. This is certainly a little weird, but it should
suffice
until a source tree cleanup is done.
Enjoy.
--
Peter Eisentraut Sernanders väg 10:115
1999-11-26 05:24:17 +01:00
2000-06-25 16:25:51 +02:00
/* COMMENT */
2001-03-22 05:01:46 +01:00
else if ( strcasecmp ( prev_wd , " COMMENT " ) = = 0 )
2000-06-25 16:25:51 +02:00
COMPLETE_WITH_CONST ( " ON " ) ;
2002-12-13 06:36:24 +01:00
else if ( strcasecmp ( prev2_wd , " COMMENT " ) = = 0 & &
strcasecmp ( prev_wd , " ON " ) = = 0 )
2000-06-25 16:25:51 +02:00
{
2001-03-22 05:01:46 +01:00
char * list_COMMENT [ ] =
2002-12-13 06:36:24 +01:00
{ " DATABASE " , " INDEX " , " RULE " , " SCHEMA " , " SEQUENCE " , " TABLE " ,
" TYPE " , " VIEW " , " COLUMN " , " AGGREGATE " , " FUNCTION " , " OPERATOR " ,
" TRIGGER " , " CONSTRAINT " , " DOMAIN " , NULL } ;
2001-03-22 05:01:46 +01:00
2000-06-25 16:25:51 +02:00
COMPLETE_WITH_LIST ( list_COMMENT ) ;
}
2002-12-13 06:36:24 +01:00
else if ( strcasecmp ( prev4_wd , " COMMENT " ) = = 0 & &
strcasecmp ( prev3_wd , " ON " ) = = 0 )
2000-06-25 16:25:51 +02:00
COMPLETE_WITH_CONST ( " IS " ) ;
* Includes tab completion. It's not magic, but it's very cool. At any
rate
it's better than what used to be there.
* Does proper SQL "host variable" substitution as pointed out by Andreas
Zeugwetter (thanks): select * from :foo; Also some changes in how ':'
and ';' are treated (escape with \ to send to backend). This does
_not_
affect the '::' cast operator, but perhaps others that contain : or ;
(but there are none right now).
* To show description with a <something> listing, append '?' to command
name, e.g., \df?. This seemed to be the convenient and logical
solution.
Or append a '+' to see more useless information, e.g., \df+.
* Fixed fflush()'ing bug pointed out by Jan during the regression test
discussion.
* Added LastOid variable. This ought to take care of TODO item "Add a
function to return the last inserted oid, for use in psql scripts"
(under CLIENTS)
E.g.,
insert into foo values(...);
insert into bar values(..., :LastOid);
\echo $LastOid
* \d command shows constraints, rules, and triggers defined on the table
(in addition to indices)
* Various fixes, optimizations, corrections
* Documentation update as well
Note: This now requires snprintf(), which, if necessary, is taken from
src/backend/port. This is certainly a little weird, but it should
suffice
until a source tree cleanup is done.
Enjoy.
--
Peter Eisentraut Sernanders väg 10:115
1999-11-26 05:24:17 +01:00
/* COPY */
2000-04-12 19:17:23 +02:00
/*
* If we have COPY [ BINARY ] ( which you ' d have to type yourself ) , offer
* list of tables ( Also cover the analogous backslash command )
*/
else if ( strcasecmp ( prev_wd , " COPY " ) = = 0 | |
strcasecmp ( prev_wd , " \\ copy " ) = = 0 | |
2002-12-13 06:36:24 +01:00
( strcasecmp ( prev2_wd , " COPY " ) = = 0 & &
strcasecmp ( prev_wd , " BINARY " ) = = 0 ) )
2003-03-27 17:45:01 +01:00
COMPLETE_WITH_SCHEMA_QUERY ( Query_for_list_of_tables ) ;
2000-04-12 19:17:23 +02:00
/* If we have COPY|BINARY <sth>, complete it with "TO" or "FROM" */
else if ( strcasecmp ( prev2_wd , " COPY " ) = = 0 | |
strcasecmp ( prev2_wd , " \\ copy " ) = = 0 | |
strcasecmp ( prev2_wd , " BINARY " ) = = 0 )
{
char * list_FROMTO [ ] = { " FROM " , " TO " , NULL } ;
COMPLETE_WITH_LIST ( list_FROMTO ) ;
}
* Includes tab completion. It's not magic, but it's very cool. At any
rate
it's better than what used to be there.
* Does proper SQL "host variable" substitution as pointed out by Andreas
Zeugwetter (thanks): select * from :foo; Also some changes in how ':'
and ';' are treated (escape with \ to send to backend). This does
_not_
affect the '::' cast operator, but perhaps others that contain : or ;
(but there are none right now).
* To show description with a <something> listing, append '?' to command
name, e.g., \df?. This seemed to be the convenient and logical
solution.
Or append a '+' to see more useless information, e.g., \df+.
* Fixed fflush()'ing bug pointed out by Jan during the regression test
discussion.
* Added LastOid variable. This ought to take care of TODO item "Add a
function to return the last inserted oid, for use in psql scripts"
(under CLIENTS)
E.g.,
insert into foo values(...);
insert into bar values(..., :LastOid);
\echo $LastOid
* \d command shows constraints, rules, and triggers defined on the table
(in addition to indices)
* Various fixes, optimizations, corrections
* Documentation update as well
Note: This now requires snprintf(), which, if necessary, is taken from
src/backend/port. This is certainly a little weird, but it should
suffice
until a source tree cleanup is done.
Enjoy.
--
Peter Eisentraut Sernanders väg 10:115
1999-11-26 05:24:17 +01:00
/* CREATE INDEX */
2000-04-12 19:17:23 +02:00
/* First off we complete CREATE UNIQUE with "INDEX" */
2002-12-13 06:36:24 +01:00
else if ( strcasecmp ( prev2_wd , " CREATE " ) = = 0 & &
strcasecmp ( prev_wd , " UNIQUE " ) = = 0 )
2000-04-12 19:17:23 +02:00
COMPLETE_WITH_CONST ( " INDEX " ) ;
/* If we have CREATE|UNIQUE INDEX <sth>, then add "ON" */
else if ( strcasecmp ( prev2_wd , " INDEX " ) = = 0 & &
2002-12-13 06:36:24 +01:00
( strcasecmp ( prev3_wd , " CREATE " ) = = 0 | |
strcasecmp ( prev3_wd , " UNIQUE " ) = = 0 ) )
2000-04-12 19:17:23 +02:00
COMPLETE_WITH_CONST ( " ON " ) ;
/* Complete ... INDEX <name> ON with a list of tables */
2002-12-13 06:36:24 +01:00
else if ( strcasecmp ( prev3_wd , " INDEX " ) = = 0 & &
strcasecmp ( prev_wd , " ON " ) = = 0 )
2003-03-27 17:45:01 +01:00
COMPLETE_WITH_SCHEMA_QUERY ( Query_for_list_of_tables ) ;
2000-04-12 19:17:23 +02:00
/*
* Complete INDEX < name > ON < table > with a list of table columns
* ( which should really be in parens )
*/
2002-12-13 06:36:24 +01:00
else if ( strcasecmp ( prev4_wd , " INDEX " ) = = 0 & &
strcasecmp ( prev2_wd , " ON " ) = = 0 )
2000-04-12 19:17:23 +02:00
COMPLETE_WITH_ATTR ( prev_wd ) ;
/* same if you put in USING */
2002-12-13 06:36:24 +01:00
else if ( strcasecmp ( prev4_wd , " ON " ) = = 0 & &
strcasecmp ( prev2_wd , " USING " ) = = 0 )
2000-04-12 19:17:23 +02:00
COMPLETE_WITH_ATTR ( prev3_wd ) ;
/* Complete USING with an index method */
else if ( strcasecmp ( prev_wd , " USING " ) = = 0 )
{
2002-08-10 05:56:24 +02:00
char * index_mth [ ] = { " BTREE " , " RTREE " , " HASH " , " GIST " , NULL } ;
2000-04-12 19:17:23 +02:00
COMPLETE_WITH_LIST ( index_mth ) ;
}
* Includes tab completion. It's not magic, but it's very cool. At any
rate
it's better than what used to be there.
* Does proper SQL "host variable" substitution as pointed out by Andreas
Zeugwetter (thanks): select * from :foo; Also some changes in how ':'
and ';' are treated (escape with \ to send to backend). This does
_not_
affect the '::' cast operator, but perhaps others that contain : or ;
(but there are none right now).
* To show description with a <something> listing, append '?' to command
name, e.g., \df?. This seemed to be the convenient and logical
solution.
Or append a '+' to see more useless information, e.g., \df+.
* Fixed fflush()'ing bug pointed out by Jan during the regression test
discussion.
* Added LastOid variable. This ought to take care of TODO item "Add a
function to return the last inserted oid, for use in psql scripts"
(under CLIENTS)
E.g.,
insert into foo values(...);
insert into bar values(..., :LastOid);
\echo $LastOid
* \d command shows constraints, rules, and triggers defined on the table
(in addition to indices)
* Various fixes, optimizations, corrections
* Documentation update as well
Note: This now requires snprintf(), which, if necessary, is taken from
src/backend/port. This is certainly a little weird, but it should
suffice
until a source tree cleanup is done.
Enjoy.
--
Peter Eisentraut Sernanders väg 10:115
1999-11-26 05:24:17 +01:00
/* CREATE RULE */
2000-04-12 19:17:23 +02:00
/* Complete "CREATE RULE <sth>" with "AS" */
2002-12-13 06:36:24 +01:00
else if ( strcasecmp ( prev3_wd , " CREATE " ) = = 0 & &
strcasecmp ( prev2_wd , " RULE " ) = = 0 )
2000-04-12 19:17:23 +02:00
COMPLETE_WITH_CONST ( " AS " ) ;
/* Complete "CREATE RULE <sth> AS with "ON" */
else if ( strcasecmp ( prev4_wd , " CREATE " ) = = 0 & &
strcasecmp ( prev3_wd , " RULE " ) = = 0 & &
strcasecmp ( prev_wd , " AS " ) = = 0 )
COMPLETE_WITH_CONST ( " ON " ) ;
/* Complete "RULE * AS ON" with SELECT|UPDATE|DELETE|INSERT */
else if ( strcasecmp ( prev4_wd , " RULE " ) = = 0 & &
strcasecmp ( prev2_wd , " AS " ) = = 0 & &
strcasecmp ( prev_wd , " ON " ) = = 0 )
{
2002-12-13 06:36:24 +01:00
char * rule_events [ ] = { " SELECT " , " UPDATE " , " INSERT " ,
" DELETE " , NULL } ;
2000-04-12 19:17:23 +02:00
COMPLETE_WITH_LIST ( rule_events ) ;
}
/* Complete "AS ON <sth with a 'T' :)>" with a "TO" */
else if ( strcasecmp ( prev3_wd , " AS " ) = = 0 & &
strcasecmp ( prev2_wd , " ON " ) = = 0 & &
2000-12-03 21:45:40 +01:00
( toupper ( ( unsigned char ) prev_wd [ 4 ] ) = = ' T ' | |
toupper ( ( unsigned char ) prev_wd [ 5 ] ) = = ' T ' ) )
2000-04-12 19:17:23 +02:00
COMPLETE_WITH_CONST ( " TO " ) ;
/* Complete "AS ON <sth> TO" with a table name */
else if ( strcasecmp ( prev4_wd , " AS " ) = = 0 & &
strcasecmp ( prev3_wd , " ON " ) = = 0 & &
strcasecmp ( prev_wd , " TO " ) = = 0 )
2003-03-27 17:45:01 +01:00
COMPLETE_WITH_SCHEMA_QUERY ( Query_for_list_of_tables ) ;
* Includes tab completion. It's not magic, but it's very cool. At any
rate
it's better than what used to be there.
* Does proper SQL "host variable" substitution as pointed out by Andreas
Zeugwetter (thanks): select * from :foo; Also some changes in how ':'
and ';' are treated (escape with \ to send to backend). This does
_not_
affect the '::' cast operator, but perhaps others that contain : or ;
(but there are none right now).
* To show description with a <something> listing, append '?' to command
name, e.g., \df?. This seemed to be the convenient and logical
solution.
Or append a '+' to see more useless information, e.g., \df+.
* Fixed fflush()'ing bug pointed out by Jan during the regression test
discussion.
* Added LastOid variable. This ought to take care of TODO item "Add a
function to return the last inserted oid, for use in psql scripts"
(under CLIENTS)
E.g.,
insert into foo values(...);
insert into bar values(..., :LastOid);
\echo $LastOid
* \d command shows constraints, rules, and triggers defined on the table
(in addition to indices)
* Various fixes, optimizations, corrections
* Documentation update as well
Note: This now requires snprintf(), which, if necessary, is taken from
src/backend/port. This is certainly a little weird, but it should
suffice
until a source tree cleanup is done.
Enjoy.
--
Peter Eisentraut Sernanders väg 10:115
1999-11-26 05:24:17 +01:00
/* CREATE TABLE */
2000-04-12 19:17:23 +02:00
/* Complete CREATE TEMP with "TABLE" */
2002-12-13 06:36:24 +01:00
else if ( strcasecmp ( prev2_wd , " CREATE " ) = = 0 & &
strcasecmp ( prev_wd , " TEMP " ) = = 0 )
2000-04-12 19:17:23 +02:00
COMPLETE_WITH_CONST ( " TABLE " ) ;
* Includes tab completion. It's not magic, but it's very cool. At any
rate
it's better than what used to be there.
* Does proper SQL "host variable" substitution as pointed out by Andreas
Zeugwetter (thanks): select * from :foo; Also some changes in how ':'
and ';' are treated (escape with \ to send to backend). This does
_not_
affect the '::' cast operator, but perhaps others that contain : or ;
(but there are none right now).
* To show description with a <something> listing, append '?' to command
name, e.g., \df?. This seemed to be the convenient and logical
solution.
Or append a '+' to see more useless information, e.g., \df+.
* Fixed fflush()'ing bug pointed out by Jan during the regression test
discussion.
* Added LastOid variable. This ought to take care of TODO item "Add a
function to return the last inserted oid, for use in psql scripts"
(under CLIENTS)
E.g.,
insert into foo values(...);
insert into bar values(..., :LastOid);
\echo $LastOid
* \d command shows constraints, rules, and triggers defined on the table
(in addition to indices)
* Various fixes, optimizations, corrections
* Documentation update as well
Note: This now requires snprintf(), which, if necessary, is taken from
src/backend/port. This is certainly a little weird, but it should
suffice
until a source tree cleanup is done.
Enjoy.
--
Peter Eisentraut Sernanders väg 10:115
1999-11-26 05:24:17 +01:00
/* CREATE TRIGGER */
2000-04-12 19:17:23 +02:00
/* is on the agenda . . . */
* Includes tab completion. It's not magic, but it's very cool. At any
rate
it's better than what used to be there.
* Does proper SQL "host variable" substitution as pointed out by Andreas
Zeugwetter (thanks): select * from :foo; Also some changes in how ':'
and ';' are treated (escape with \ to send to backend). This does
_not_
affect the '::' cast operator, but perhaps others that contain : or ;
(but there are none right now).
* To show description with a <something> listing, append '?' to command
name, e.g., \df?. This seemed to be the convenient and logical
solution.
Or append a '+' to see more useless information, e.g., \df+.
* Fixed fflush()'ing bug pointed out by Jan during the regression test
discussion.
* Added LastOid variable. This ought to take care of TODO item "Add a
function to return the last inserted oid, for use in psql scripts"
(under CLIENTS)
E.g.,
insert into foo values(...);
insert into bar values(..., :LastOid);
\echo $LastOid
* \d command shows constraints, rules, and triggers defined on the table
(in addition to indices)
* Various fixes, optimizations, corrections
* Documentation update as well
Note: This now requires snprintf(), which, if necessary, is taken from
src/backend/port. This is certainly a little weird, but it should
suffice
until a source tree cleanup is done.
Enjoy.
--
Peter Eisentraut Sernanders väg 10:115
1999-11-26 05:24:17 +01:00
/* CREATE VIEW */
2000-04-12 19:17:23 +02:00
/* Complete "CREATE VIEW <name>" with "AS" */
2002-12-13 06:36:24 +01:00
else if ( strcasecmp ( prev3_wd , " CREATE " ) = = 0 & &
strcasecmp ( prev2_wd , " VIEW " ) = = 0 )
2000-04-12 19:17:23 +02:00
COMPLETE_WITH_CONST ( " AS " ) ;
/* Complete "CREATE VIEW <sth> AS with "SELECT" */
else if ( strcasecmp ( prev4_wd , " CREATE " ) = = 0 & &
strcasecmp ( prev3_wd , " VIEW " ) = = 0 & &
strcasecmp ( prev_wd , " AS " ) = = 0 )
COMPLETE_WITH_CONST ( " SELECT " ) ;
* Includes tab completion. It's not magic, but it's very cool. At any
rate
it's better than what used to be there.
* Does proper SQL "host variable" substitution as pointed out by Andreas
Zeugwetter (thanks): select * from :foo; Also some changes in how ':'
and ';' are treated (escape with \ to send to backend). This does
_not_
affect the '::' cast operator, but perhaps others that contain : or ;
(but there are none right now).
* To show description with a <something> listing, append '?' to command
name, e.g., \df?. This seemed to be the convenient and logical
solution.
Or append a '+' to see more useless information, e.g., \df+.
* Fixed fflush()'ing bug pointed out by Jan during the regression test
discussion.
* Added LastOid variable. This ought to take care of TODO item "Add a
function to return the last inserted oid, for use in psql scripts"
(under CLIENTS)
E.g.,
insert into foo values(...);
insert into bar values(..., :LastOid);
\echo $LastOid
* \d command shows constraints, rules, and triggers defined on the table
(in addition to indices)
* Various fixes, optimizations, corrections
* Documentation update as well
Note: This now requires snprintf(), which, if necessary, is taken from
src/backend/port. This is certainly a little weird, but it should
suffice
until a source tree cleanup is done.
Enjoy.
--
Peter Eisentraut Sernanders väg 10:115
1999-11-26 05:24:17 +01:00
/* DELETE */
2000-04-12 19:17:23 +02:00
/*
* Complete DELETE with FROM ( only if the word before that is not " ON "
2002-06-15 21:43:47 +02:00
* ( cf . rules ) or " BEFORE " or " AFTER " ( cf . triggers ) or GRANT )
2000-04-12 19:17:23 +02:00
*/
else if ( strcasecmp ( prev_wd , " DELETE " ) = = 0 & &
! ( strcasecmp ( prev2_wd , " ON " ) = = 0 | |
2002-06-15 21:43:47 +02:00
strcasecmp ( prev2_wd , " GRANT " ) = = 0 | |
2000-04-12 19:17:23 +02:00
strcasecmp ( prev2_wd , " BEFORE " ) = = 0 | |
strcasecmp ( prev2_wd , " AFTER " ) = = 0 ) )
COMPLETE_WITH_CONST ( " FROM " ) ;
/* Complete DELETE FROM with a list of tables */
2002-12-13 06:36:24 +01:00
else if ( strcasecmp ( prev2_wd , " DELETE " ) = = 0 & &
strcasecmp ( prev_wd , " FROM " ) = = 0 )
2003-03-27 17:45:01 +01:00
COMPLETE_WITH_SCHEMA_QUERY ( Query_for_list_of_tables ) ;
2000-04-12 19:17:23 +02:00
/* Complete DELETE FROM <table> with "WHERE" (perhaps a safe idea?) */
2002-12-13 06:36:24 +01:00
else if ( strcasecmp ( prev3_wd , " DELETE " ) = = 0 & &
strcasecmp ( prev2_wd , " FROM " ) = = 0 )
2000-04-12 19:17:23 +02:00
COMPLETE_WITH_CONST ( " WHERE " ) ;
* Includes tab completion. It's not magic, but it's very cool. At any
rate
it's better than what used to be there.
* Does proper SQL "host variable" substitution as pointed out by Andreas
Zeugwetter (thanks): select * from :foo; Also some changes in how ':'
and ';' are treated (escape with \ to send to backend). This does
_not_
affect the '::' cast operator, but perhaps others that contain : or ;
(but there are none right now).
* To show description with a <something> listing, append '?' to command
name, e.g., \df?. This seemed to be the convenient and logical
solution.
Or append a '+' to see more useless information, e.g., \df+.
* Fixed fflush()'ing bug pointed out by Jan during the regression test
discussion.
* Added LastOid variable. This ought to take care of TODO item "Add a
function to return the last inserted oid, for use in psql scripts"
(under CLIENTS)
E.g.,
insert into foo values(...);
insert into bar values(..., :LastOid);
\echo $LastOid
* \d command shows constraints, rules, and triggers defined on the table
(in addition to indices)
* Various fixes, optimizations, corrections
* Documentation update as well
Note: This now requires snprintf(), which, if necessary, is taken from
src/backend/port. This is certainly a little weird, but it should
suffice
until a source tree cleanup is done.
Enjoy.
--
Peter Eisentraut Sernanders väg 10:115
1999-11-26 05:24:17 +01:00
/* EXPLAIN */
2000-04-12 19:17:23 +02:00
/*
* Complete EXPLAIN [ VERBOSE ] ( which you ' d have to type yourself ) with
* the list of SQL commands
*/
else if ( strcasecmp ( prev_wd , " EXPLAIN " ) = = 0 | |
2002-12-13 06:36:24 +01:00
( strcasecmp ( prev2_wd , " EXPLAIN " ) = = 0 & &
strcasecmp ( prev_wd , " VERBOSE " ) = = 0 ) )
2000-04-12 19:17:23 +02:00
COMPLETE_WITH_LIST ( sql_commands ) ;
* Includes tab completion. It's not magic, but it's very cool. At any
rate
it's better than what used to be there.
* Does proper SQL "host variable" substitution as pointed out by Andreas
Zeugwetter (thanks): select * from :foo; Also some changes in how ':'
and ';' are treated (escape with \ to send to backend). This does
_not_
affect the '::' cast operator, but perhaps others that contain : or ;
(but there are none right now).
* To show description with a <something> listing, append '?' to command
name, e.g., \df?. This seemed to be the convenient and logical
solution.
Or append a '+' to see more useless information, e.g., \df+.
* Fixed fflush()'ing bug pointed out by Jan during the regression test
discussion.
* Added LastOid variable. This ought to take care of TODO item "Add a
function to return the last inserted oid, for use in psql scripts"
(under CLIENTS)
E.g.,
insert into foo values(...);
insert into bar values(..., :LastOid);
\echo $LastOid
* \d command shows constraints, rules, and triggers defined on the table
(in addition to indices)
* Various fixes, optimizations, corrections
* Documentation update as well
Note: This now requires snprintf(), which, if necessary, is taken from
src/backend/port. This is certainly a little weird, but it should
suffice
until a source tree cleanup is done.
Enjoy.
--
Peter Eisentraut Sernanders väg 10:115
1999-11-26 05:24:17 +01:00
/* FETCH && MOVE */
2000-04-12 19:17:23 +02:00
/* Complete FETCH with one of FORWARD, BACKWARD, RELATIVE */
2002-12-13 06:36:24 +01:00
else if ( strcasecmp ( prev_wd , " FETCH " ) = = 0 | |
strcasecmp ( prev_wd , " MOVE " ) = = 0 )
2000-04-12 19:17:23 +02:00
{
char * list_FETCH1 [ ] = { " FORWARD " , " BACKWARD " , " RELATIVE " , NULL } ;
COMPLETE_WITH_LIST ( list_FETCH1 ) ;
}
/* Complete FETCH <sth> with one of ALL, NEXT, PRIOR */
2002-12-13 06:36:24 +01:00
else if ( strcasecmp ( prev2_wd , " FETCH " ) = = 0 | |
strcasecmp ( prev2_wd , " MOVE " ) = = 0 )
2000-04-12 19:17:23 +02:00
{
char * list_FETCH2 [ ] = { " ALL " , " NEXT " , " PRIOR " , NULL } ;
COMPLETE_WITH_LIST ( list_FETCH2 ) ;
}
/*
* Complete FETCH < sth1 > < sth2 > with " FROM " or " TO " . ( Is there a
* difference ? If not , remove one . )
*/
2002-12-13 06:36:24 +01:00
else if ( strcasecmp ( prev3_wd , " FETCH " ) = = 0 | |
strcasecmp ( prev3_wd , " MOVE " ) = = 0 )
2000-04-12 19:17:23 +02:00
{
char * list_FROMTO [ ] = { " FROM " , " TO " , NULL } ;
COMPLETE_WITH_LIST ( list_FROMTO ) ;
}
* Includes tab completion. It's not magic, but it's very cool. At any
rate
it's better than what used to be there.
* Does proper SQL "host variable" substitution as pointed out by Andreas
Zeugwetter (thanks): select * from :foo; Also some changes in how ':'
and ';' are treated (escape with \ to send to backend). This does
_not_
affect the '::' cast operator, but perhaps others that contain : or ;
(but there are none right now).
* To show description with a <something> listing, append '?' to command
name, e.g., \df?. This seemed to be the convenient and logical
solution.
Or append a '+' to see more useless information, e.g., \df+.
* Fixed fflush()'ing bug pointed out by Jan during the regression test
discussion.
* Added LastOid variable. This ought to take care of TODO item "Add a
function to return the last inserted oid, for use in psql scripts"
(under CLIENTS)
E.g.,
insert into foo values(...);
insert into bar values(..., :LastOid);
\echo $LastOid
* \d command shows constraints, rules, and triggers defined on the table
(in addition to indices)
* Various fixes, optimizations, corrections
* Documentation update as well
Note: This now requires snprintf(), which, if necessary, is taken from
src/backend/port. This is certainly a little weird, but it should
suffice
until a source tree cleanup is done.
Enjoy.
--
Peter Eisentraut Sernanders väg 10:115
1999-11-26 05:24:17 +01:00
/* GRANT && REVOKE*/
2000-04-12 19:17:23 +02:00
/* Complete GRANT/REVOKE with a list of privileges */
2002-12-13 06:36:24 +01:00
else if ( strcasecmp ( prev_wd , " GRANT " ) = = 0 | |
strcasecmp ( prev_wd , " REVOKE " ) = = 0 )
2000-04-12 19:17:23 +02:00
{
2002-08-10 05:56:24 +02:00
char * list_privileg [ ] = { " SELECT " , " INSERT " , " UPDATE " , " DELETE " , " RULE " , " REFERENCES " , " TRIGGER " , " CREATE " , " TEMPORARY " , " EXECUTE " , " USAGE " , " ALL " , NULL } ;
2000-04-12 19:17:23 +02:00
COMPLETE_WITH_LIST ( list_privileg ) ;
}
/* Complete GRANT/REVOKE <sth> with "ON" */
2002-12-13 06:36:24 +01:00
else if ( strcasecmp ( prev2_wd , " GRANT " ) = = 0 | |
strcasecmp ( prev2_wd , " REVOKE " ) = = 0 )
2000-04-12 19:17:23 +02:00
COMPLETE_WITH_CONST ( " ON " ) ;
/*
* Complete GRANT / REVOKE < sth > ON with a list of tables , views ,
2002-08-10 05:56:24 +02:00
* sequences , and indexes
*
2003-03-27 17:45:01 +01:00
* keywords DATABASE , FUNCTION , LANGUAGE , SCHEMA added to query result
* via UNION ; seems to work intuitively
*
* Note : GRANT / REVOKE can get quite complex ; tab - completion as implemented
* here will only work if the privilege list contains exactly one privilege
2000-04-12 19:17:23 +02:00
*/
2002-12-13 06:36:24 +01:00
else if ( ( strcasecmp ( prev3_wd , " GRANT " ) = = 0 | |
strcasecmp ( prev3_wd , " REVOKE " ) = = 0 ) & &
2000-04-12 19:17:23 +02:00
strcasecmp ( prev_wd , " ON " ) = = 0 )
2003-03-27 17:45:01 +01:00
COMPLETE_WITH_QUERY ( " SELECT relname FROM pg_catalog.pg_class c, pg_catalog.pg_namespace n "
" WHERE relkind in ('r','S','v') "
" AND substr(relname,1,%d)='%s' "
" AND pg_catalog.pg_table_is_visible(c.oid) "
" AND relnamespace = n.oid "
" AND n.nspname NOT IN ('pg_catalog', 'pg_toast') "
" UNION "
" SELECT 'DATABASE' AS relname "
" UNION "
" SELECT 'FUNCTION' AS relname "
" UNION "
" SELECT 'LANGUAGE' AS relname "
" UNION "
" SELECT 'SCHEMA' AS relname " ) ;
/* Complete "GRANT/REVOKE * ON * " with "TO" */
else if ( ( strcasecmp ( prev4_wd , " GRANT " ) = = 0 | |
strcasecmp ( prev4_wd , " REVOKE " ) = = 0 ) & &
2002-12-13 06:36:24 +01:00
strcasecmp ( prev2_wd , " ON " ) = = 0 )
2003-03-27 17:45:01 +01:00
{
if ( strcasecmp ( prev_wd , " DATABASE " ) = = 0 )
COMPLETE_WITH_QUERY ( Query_for_list_of_databases ) ;
else if ( strcasecmp ( prev_wd , " FUNCTION " ) = = 0 )
COMPLETE_WITH_SCHEMA_QUERY ( Query_for_list_of_functions ) ;
else if ( strcasecmp ( prev_wd , " LANGUAGE " ) = = 0 )
COMPLETE_WITH_QUERY ( Query_for_list_of_languages ) ;
else if ( strcasecmp ( prev_wd , " SCHEMA " ) = = 0 )
COMPLETE_WITH_QUERY ( Query_for_list_of_schemas ) ;
else
COMPLETE_WITH_CONST ( " TO " ) ;
}
2000-04-12 19:17:23 +02:00
/*
* TODO : to complete with user name we need prev5_wd - - wait for a
* more general solution there
2003-03-27 17:45:01 +01:00
* same for GRANT < sth > ON { DATABASE | FUNCTION | LANGUAGE | SCHEMA } xxx TO
2000-04-12 19:17:23 +02:00
*/
* Includes tab completion. It's not magic, but it's very cool. At any
rate
it's better than what used to be there.
* Does proper SQL "host variable" substitution as pointed out by Andreas
Zeugwetter (thanks): select * from :foo; Also some changes in how ':'
and ';' are treated (escape with \ to send to backend). This does
_not_
affect the '::' cast operator, but perhaps others that contain : or ;
(but there are none right now).
* To show description with a <something> listing, append '?' to command
name, e.g., \df?. This seemed to be the convenient and logical
solution.
Or append a '+' to see more useless information, e.g., \df+.
* Fixed fflush()'ing bug pointed out by Jan during the regression test
discussion.
* Added LastOid variable. This ought to take care of TODO item "Add a
function to return the last inserted oid, for use in psql scripts"
(under CLIENTS)
E.g.,
insert into foo values(...);
insert into bar values(..., :LastOid);
\echo $LastOid
* \d command shows constraints, rules, and triggers defined on the table
(in addition to indices)
* Various fixes, optimizations, corrections
* Documentation update as well
Note: This now requires snprintf(), which, if necessary, is taken from
src/backend/port. This is certainly a little weird, but it should
suffice
until a source tree cleanup is done.
Enjoy.
--
Peter Eisentraut Sernanders väg 10:115
1999-11-26 05:24:17 +01:00
/* INSERT */
2000-04-12 19:17:23 +02:00
/* Complete INSERT with "INTO" */
else if ( strcasecmp ( prev_wd , " INSERT " ) = = 0 )
COMPLETE_WITH_CONST ( " INTO " ) ;
/* Complete INSERT INTO with table names */
2002-12-13 06:36:24 +01:00
else if ( strcasecmp ( prev2_wd , " INSERT " ) = = 0 & &
strcasecmp ( prev_wd , " INTO " ) = = 0 )
2003-03-27 17:45:01 +01:00
COMPLETE_WITH_SCHEMA_QUERY ( Query_for_list_of_tables ) ;
2002-07-30 18:35:05 +02:00
/* Complete "INSERT INTO <table> (" with attribute names */
2002-12-13 06:36:24 +01:00
else if ( rl_line_buffer [ start - 1 ] = = ' ( ' & &
strcasecmp ( prev3_wd , " INSERT " ) = = 0 & &
strcasecmp ( prev2_wd , " INTO " ) = = 0 )
2002-07-30 18:35:05 +02:00
COMPLETE_WITH_ATTR ( prev_wd ) ;
2001-10-25 07:50:21 +02:00
/*
* Complete INSERT INTO < table > with " VALUES " or " SELECT " or " DEFAULT
* VALUES "
*/
2002-12-13 06:36:24 +01:00
else if ( strcasecmp ( prev3_wd , " INSERT " ) = = 0 & &
strcasecmp ( prev2_wd , " INTO " ) = = 0 )
2000-04-12 19:17:23 +02:00
{
2001-08-30 15:17:03 +02:00
char * list_INSERT [ ] = { " DEFAULT VALUES " , " SELECT " , " VALUES " , NULL } ;
2002-09-04 22:31:48 +02:00
2000-04-12 19:17:23 +02:00
COMPLETE_WITH_LIST ( list_INSERT ) ;
}
2002-07-30 18:35:05 +02:00
/* Complete INSERT INTO <table> (attribs) with "VALUES" or "SELECT" */
2002-12-13 06:36:24 +01:00
else if ( strcasecmp ( prev4_wd , " INSERT " ) = = 0 & &
strcasecmp ( prev3_wd , " INTO " ) = = 0 & &
2002-09-04 22:31:48 +02:00
prev_wd [ strlen ( prev_wd ) - 1 ] = = ' ) ' )
2002-07-30 18:35:05 +02:00
{
char * list_INSERT [ ] = { " SELECT " , " VALUES " , NULL } ;
2002-09-04 22:31:48 +02:00
2002-07-30 18:35:05 +02:00
COMPLETE_WITH_LIST ( list_INSERT ) ;
}
2000-04-12 19:17:23 +02:00
/* Insert an open parenthesis after "VALUES" */
2002-12-13 06:36:24 +01:00
else if ( strcasecmp ( prev_wd , " VALUES " ) = = 0 & &
strcasecmp ( prev2_wd , " DEFAULT " ) ! = 0 )
2000-04-12 19:17:23 +02:00
COMPLETE_WITH_CONST ( " ( " ) ;
* Includes tab completion. It's not magic, but it's very cool. At any
rate
it's better than what used to be there.
* Does proper SQL "host variable" substitution as pointed out by Andreas
Zeugwetter (thanks): select * from :foo; Also some changes in how ':'
and ';' are treated (escape with \ to send to backend). This does
_not_
affect the '::' cast operator, but perhaps others that contain : or ;
(but there are none right now).
* To show description with a <something> listing, append '?' to command
name, e.g., \df?. This seemed to be the convenient and logical
solution.
Or append a '+' to see more useless information, e.g., \df+.
* Fixed fflush()'ing bug pointed out by Jan during the regression test
discussion.
* Added LastOid variable. This ought to take care of TODO item "Add a
function to return the last inserted oid, for use in psql scripts"
(under CLIENTS)
E.g.,
insert into foo values(...);
insert into bar values(..., :LastOid);
\echo $LastOid
* \d command shows constraints, rules, and triggers defined on the table
(in addition to indices)
* Various fixes, optimizations, corrections
* Documentation update as well
Note: This now requires snprintf(), which, if necessary, is taken from
src/backend/port. This is certainly a little weird, but it should
suffice
until a source tree cleanup is done.
Enjoy.
--
Peter Eisentraut Sernanders väg 10:115
1999-11-26 05:24:17 +01:00
/* LOCK */
2002-07-30 18:35:05 +02:00
/* Complete LOCK [TABLE] with a list of tables */
2002-12-13 06:36:24 +01:00
else if ( strcasecmp ( prev_wd , " LOCK " ) = = 0 | |
( strcasecmp ( prev_wd , " TABLE " ) = = 0 & &
2003-03-27 17:45:01 +01:00
strcasecmp ( prev2_wd , " LOCK " ) = = 0 ) )
COMPLETE_WITH_SCHEMA_QUERY ( Query_for_list_of_tables ) ;
2002-07-30 18:35:05 +02:00
/* For the following, handle the case of a single table only for now */
/* Complete LOCK [TABLE] <table> with "IN" */
2002-12-13 06:36:24 +01:00
else if ( ( strcasecmp ( prev2_wd , " LOCK " ) = = 0 & &
strcasecmp ( prev_wd , " TABLE " ) ) | |
( strcasecmp ( prev2_wd , " TABLE " ) = = 0 & &
strcasecmp ( prev3_wd , " LOCK " ) = = 0 ) )
2002-09-04 22:31:48 +02:00
COMPLETE_WITH_CONST ( " IN " ) ;
2002-07-30 18:35:05 +02:00
/* Complete LOCK [TABLE] <table> IN with a lock mode */
else if ( strcasecmp ( prev_wd , " IN " ) = = 0 & &
( strcasecmp ( prev3_wd , " LOCK " ) = = 0 | |
2002-12-13 06:36:24 +01:00
( strcasecmp ( prev3_wd , " TABLE " ) = = 0 & &
2003-03-27 17:45:01 +01:00
strcasecmp ( prev4_wd , " LOCK " ) = = 0 ) ) )
2002-07-30 18:35:05 +02:00
{
2002-12-13 06:36:24 +01:00
char * lock_modes [ ] = { " ACCESS SHARE MODE " ,
" ROW SHARE MODE " , " ROW EXCLUSIVE MODE " ,
" SHARE UPDATE EXCLUSIVE MODE " , " SHARE MODE " ,
" SHARE ROW EXCLUSIVE MODE " ,
" EXCLUSIVE MODE " , " ACCESS EXCLUSIVE MODE " , NULL } ;
2002-09-04 22:31:48 +02:00
COMPLETE_WITH_LIST ( lock_modes ) ;
2002-07-30 18:35:05 +02:00
}
* Includes tab completion. It's not magic, but it's very cool. At any
rate
it's better than what used to be there.
* Does proper SQL "host variable" substitution as pointed out by Andreas
Zeugwetter (thanks): select * from :foo; Also some changes in how ':'
and ';' are treated (escape with \ to send to backend). This does
_not_
affect the '::' cast operator, but perhaps others that contain : or ;
(but there are none right now).
* To show description with a <something> listing, append '?' to command
name, e.g., \df?. This seemed to be the convenient and logical
solution.
Or append a '+' to see more useless information, e.g., \df+.
* Fixed fflush()'ing bug pointed out by Jan during the regression test
discussion.
* Added LastOid variable. This ought to take care of TODO item "Add a
function to return the last inserted oid, for use in psql scripts"
(under CLIENTS)
E.g.,
insert into foo values(...);
insert into bar values(..., :LastOid);
\echo $LastOid
* \d command shows constraints, rules, and triggers defined on the table
(in addition to indices)
* Various fixes, optimizations, corrections
* Documentation update as well
Note: This now requires snprintf(), which, if necessary, is taken from
src/backend/port. This is certainly a little weird, but it should
suffice
until a source tree cleanup is done.
Enjoy.
--
Peter Eisentraut Sernanders väg 10:115
1999-11-26 05:24:17 +01:00
2000-06-25 16:25:51 +02:00
/* NOTIFY */
2001-03-22 05:01:46 +01:00
else if ( strcasecmp ( prev_wd , " NOTIFY " ) = = 0 )
2002-07-30 18:35:05 +02:00
COMPLETE_WITH_QUERY ( " SELECT relname FROM pg_catalog.pg_listener WHERE substr(relname,1,%d)='%s' " ) ;
2000-06-25 16:25:51 +02:00
/* REINDEX */
else if ( strcasecmp ( prev_wd , " REINDEX " ) = = 0 )
{
2001-03-22 05:01:46 +01:00
char * list_REINDEX [ ] = { " TABLE " , " DATABASE " , " INDEX " , NULL } ;
2000-06-25 16:25:51 +02:00
COMPLETE_WITH_LIST ( list_REINDEX ) ;
}
2001-03-22 05:01:46 +01:00
else if ( strcasecmp ( prev2_wd , " REINDEX " ) = = 0 )
2000-06-25 16:25:51 +02:00
{
2001-03-22 05:01:46 +01:00
if ( strcasecmp ( prev_wd , " TABLE " ) = = 0 )
2003-03-27 17:45:01 +01:00
COMPLETE_WITH_SCHEMA_QUERY ( Query_for_list_of_tables ) ;
2001-03-22 05:01:46 +01:00
else if ( strcasecmp ( prev_wd , " DATABASE " ) = = 0 )
2000-06-25 16:25:51 +02:00
COMPLETE_WITH_QUERY ( Query_for_list_of_databases ) ;
2001-03-22 05:01:46 +01:00
else if ( strcasecmp ( prev_wd , " INDEX " ) = = 0 )
2003-03-27 17:45:01 +01:00
COMPLETE_WITH_SCHEMA_QUERY ( Query_for_list_of_indexes ) ;
2000-06-25 16:25:51 +02:00
}
* Includes tab completion. It's not magic, but it's very cool. At any
rate
it's better than what used to be there.
* Does proper SQL "host variable" substitution as pointed out by Andreas
Zeugwetter (thanks): select * from :foo; Also some changes in how ':'
and ';' are treated (escape with \ to send to backend). This does
_not_
affect the '::' cast operator, but perhaps others that contain : or ;
(but there are none right now).
* To show description with a <something> listing, append '?' to command
name, e.g., \df?. This seemed to be the convenient and logical
solution.
Or append a '+' to see more useless information, e.g., \df+.
* Fixed fflush()'ing bug pointed out by Jan during the regression test
discussion.
* Added LastOid variable. This ought to take care of TODO item "Add a
function to return the last inserted oid, for use in psql scripts"
(under CLIENTS)
E.g.,
insert into foo values(...);
insert into bar values(..., :LastOid);
\echo $LastOid
* \d command shows constraints, rules, and triggers defined on the table
(in addition to indices)
* Various fixes, optimizations, corrections
* Documentation update as well
Note: This now requires snprintf(), which, if necessary, is taken from
src/backend/port. This is certainly a little weird, but it should
suffice
until a source tree cleanup is done.
Enjoy.
--
Peter Eisentraut Sernanders väg 10:115
1999-11-26 05:24:17 +01:00
/* SELECT */
2000-04-12 19:17:23 +02:00
/* naah . . . */
* Includes tab completion. It's not magic, but it's very cool. At any
rate
it's better than what used to be there.
* Does proper SQL "host variable" substitution as pointed out by Andreas
Zeugwetter (thanks): select * from :foo; Also some changes in how ':'
and ';' are treated (escape with \ to send to backend). This does
_not_
affect the '::' cast operator, but perhaps others that contain : or ;
(but there are none right now).
* To show description with a <something> listing, append '?' to command
name, e.g., \df?. This seemed to be the convenient and logical
solution.
Or append a '+' to see more useless information, e.g., \df+.
* Fixed fflush()'ing bug pointed out by Jan during the regression test
discussion.
* Added LastOid variable. This ought to take care of TODO item "Add a
function to return the last inserted oid, for use in psql scripts"
(under CLIENTS)
E.g.,
insert into foo values(...);
insert into bar values(..., :LastOid);
\echo $LastOid
* \d command shows constraints, rules, and triggers defined on the table
(in addition to indices)
* Various fixes, optimizations, corrections
* Documentation update as well
Note: This now requires snprintf(), which, if necessary, is taken from
src/backend/port. This is certainly a little weird, but it should
suffice
until a source tree cleanup is done.
Enjoy.
--
Peter Eisentraut Sernanders väg 10:115
1999-11-26 05:24:17 +01:00
/* SET, RESET, SHOW */
2000-04-12 19:17:23 +02:00
/* Complete with a variable name */
2002-12-13 06:36:24 +01:00
else if ( ( strcasecmp ( prev_wd , " SET " ) = = 0 & &
strcasecmp ( prev3_wd , " UPDATE " ) ! = 0 ) | |
2000-04-12 19:17:23 +02:00
strcasecmp ( prev_wd , " RESET " ) = = 0 | |
strcasecmp ( prev_wd , " SHOW " ) = = 0 )
COMPLETE_WITH_LIST ( pgsql_variables ) ;
2003-01-10 23:03:30 +01:00
/* Complete "SET TRANSACTION" */
else if ( ( strcasecmp ( prev2_wd , " SET " ) = = 0 & &
strcasecmp ( prev_wd , " TRANSACTION " ) = = 0 ) | |
( strcasecmp ( prev4_wd , " SESSION " ) = = 0 & &
strcasecmp ( prev3_wd , " CHARACTERISTICS " ) = = 0 & &
strcasecmp ( prev2_wd , " AS " ) = = 0 & &
strcasecmp ( prev_wd , " TRANSACTION " ) = = 0 ) )
{
char * my_list [ ] = { " ISOLATION " , " READ " , NULL } ;
COMPLETE_WITH_LIST ( my_list ) ;
}
2000-04-12 19:17:23 +02:00
else if ( strcasecmp ( prev3_wd , " SET " ) = = 0 & &
strcasecmp ( prev2_wd , " TRANSACTION " ) = = 0 & &
strcasecmp ( prev_wd , " ISOLATION " ) = = 0 )
COMPLETE_WITH_CONST ( " LEVEL " ) ;
2002-12-13 06:36:24 +01:00
else if ( ( strcasecmp ( prev4_wd , " SET " ) = = 0 | |
strcasecmp ( prev4_wd , " AS " ) = = 0 ) & &
2000-04-12 19:17:23 +02:00
strcasecmp ( prev3_wd , " TRANSACTION " ) = = 0 & &
strcasecmp ( prev2_wd , " ISOLATION " ) = = 0 & &
strcasecmp ( prev_wd , " LEVEL " ) = = 0 )
{
2000-05-05 10:44:27 +02:00
char * my_list [ ] = { " READ " , " SERIALIZABLE " , NULL } ;
2000-04-12 19:17:23 +02:00
COMPLETE_WITH_LIST ( my_list ) ;
}
else if ( strcasecmp ( prev4_wd , " TRANSACTION " ) = = 0 & &
strcasecmp ( prev3_wd , " ISOLATION " ) = = 0 & &
strcasecmp ( prev2_wd , " LEVEL " ) = = 0 & &
strcasecmp ( prev_wd , " READ " ) = = 0 )
COMPLETE_WITH_CONST ( " COMMITTED " ) ;
2003-01-10 23:03:30 +01:00
else if ( ( strcasecmp ( prev3_wd , " SET " ) = = 0 | |
strcasecmp ( prev3_wd , " AS " ) = = 0 ) & &
strcasecmp ( prev2_wd , " TRANSACTION " ) = = 0 & &
strcasecmp ( prev_wd , " READ " ) = = 0 )
{
char * my_list [ ] = { " ONLY " , " WRITE " , NULL } ;
COMPLETE_WITH_LIST ( my_list ) ;
}
2000-06-25 16:25:51 +02:00
/* Complete SET CONSTRAINTS <foo> with DEFERRED|IMMEDIATE */
2002-12-13 06:36:24 +01:00
else if ( strcasecmp ( prev3_wd , " SET " ) = = 0 & &
strcasecmp ( prev2_wd , " CONSTRAINTS " ) = = 0 )
2000-06-25 16:25:51 +02:00
{
2001-03-22 05:01:46 +01:00
char * constraint_list [ ] = { " DEFERRED " , " IMMEDIATE " , NULL } ;
2000-06-25 16:25:51 +02:00
COMPLETE_WITH_LIST ( constraint_list ) ;
}
2001-05-08 23:06:43 +02:00
/* Complete SET SESSION with AUTHORIZATION or CHARACTERISTICS... */
2002-12-13 06:36:24 +01:00
else if ( strcasecmp ( prev2_wd , " SET " ) = = 0 & &
strcasecmp ( prev_wd , " SESSION " ) = = 0 )
2001-05-08 23:06:43 +02:00
{
2001-10-25 07:50:21 +02:00
char * my_list [ ] = { " AUTHORIZATION " ,
2003-01-10 23:03:30 +01:00
" CHARACTERISTICS AS TRANSACTION " ,
2001-10-25 07:50:21 +02:00
NULL } ;
2001-05-08 23:06:43 +02:00
COMPLETE_WITH_LIST ( my_list ) ;
}
/* Complete SET SESSION AUTHORIZATION with username */
2001-10-25 07:50:21 +02:00
else if ( strcasecmp ( prev3_wd , " SET " ) = = 0
2001-05-08 23:06:43 +02:00
& & strcasecmp ( prev2_wd , " SESSION " ) = = 0
& & strcasecmp ( prev_wd , " AUTHORIZATION " ) = = 0 )
COMPLETE_WITH_QUERY ( Query_for_list_of_users ) ;
2000-04-12 19:17:23 +02:00
/* Complete SET <var> with "TO" */
else if ( strcasecmp ( prev2_wd , " SET " ) = = 0 & &
strcasecmp ( prev4_wd , " UPDATE " ) ! = 0 )
COMPLETE_WITH_CONST ( " TO " ) ;
/* Suggest possible variable values */
else if ( strcasecmp ( prev3_wd , " SET " ) = = 0 & &
( strcasecmp ( prev_wd , " TO " ) = = 0 | | strcmp ( prev_wd , " = " ) = = 0 ) )
{
if ( strcasecmp ( prev2_wd , " DateStyle " ) = = 0 )
{
2002-12-13 06:36:24 +01:00
char * my_list [ ] = { " 'ISO' " , " 'SQL' " , " 'Postgres' " ,
" 'European' " , " 'NonEuropean' " , " 'German' " , " DEFAULT " , NULL } ;
2000-04-12 19:17:23 +02:00
COMPLETE_WITH_LIST ( my_list ) ;
}
2002-06-16 02:09:12 +02:00
else if ( strcasecmp ( prev2_wd , " GEQO " ) = = 0 )
2000-04-12 19:17:23 +02:00
{
char * my_list [ ] = { " ON " , " OFF " , " DEFAULT " , NULL } ;
COMPLETE_WITH_LIST ( my_list ) ;
}
else
{
char * my_list [ ] = { " DEFAULT " , NULL } ;
COMPLETE_WITH_LIST ( my_list ) ;
}
}
* Includes tab completion. It's not magic, but it's very cool. At any
rate
it's better than what used to be there.
* Does proper SQL "host variable" substitution as pointed out by Andreas
Zeugwetter (thanks): select * from :foo; Also some changes in how ':'
and ';' are treated (escape with \ to send to backend). This does
_not_
affect the '::' cast operator, but perhaps others that contain : or ;
(but there are none right now).
* To show description with a <something> listing, append '?' to command
name, e.g., \df?. This seemed to be the convenient and logical
solution.
Or append a '+' to see more useless information, e.g., \df+.
* Fixed fflush()'ing bug pointed out by Jan during the regression test
discussion.
* Added LastOid variable. This ought to take care of TODO item "Add a
function to return the last inserted oid, for use in psql scripts"
(under CLIENTS)
E.g.,
insert into foo values(...);
insert into bar values(..., :LastOid);
\echo $LastOid
* \d command shows constraints, rules, and triggers defined on the table
(in addition to indices)
* Various fixes, optimizations, corrections
* Documentation update as well
Note: This now requires snprintf(), which, if necessary, is taken from
src/backend/port. This is certainly a little weird, but it should
suffice
until a source tree cleanup is done.
Enjoy.
--
Peter Eisentraut Sernanders väg 10:115
1999-11-26 05:24:17 +01:00
2000-06-25 16:25:51 +02:00
/* TRUNCATE */
2001-03-22 05:01:46 +01:00
else if ( strcasecmp ( prev_wd , " TRUNCATE " ) = = 0 )
2003-03-27 17:45:01 +01:00
COMPLETE_WITH_SCHEMA_QUERY ( Query_for_list_of_tables ) ;
2000-06-25 16:25:51 +02:00
/* UNLISTEN */
2001-03-22 05:01:46 +01:00
else if ( strcasecmp ( prev_wd , " UNLISTEN " ) = = 0 )
2002-08-10 05:56:24 +02:00
COMPLETE_WITH_QUERY ( " SELECT relname FROM pg_catalog.pg_listener WHERE substr(relname,1,%d)='%s' UNION SELECT '*'::name " ) ;
2000-06-25 16:25:51 +02:00
* Includes tab completion. It's not magic, but it's very cool. At any
rate
it's better than what used to be there.
* Does proper SQL "host variable" substitution as pointed out by Andreas
Zeugwetter (thanks): select * from :foo; Also some changes in how ':'
and ';' are treated (escape with \ to send to backend). This does
_not_
affect the '::' cast operator, but perhaps others that contain : or ;
(but there are none right now).
* To show description with a <something> listing, append '?' to command
name, e.g., \df?. This seemed to be the convenient and logical
solution.
Or append a '+' to see more useless information, e.g., \df+.
* Fixed fflush()'ing bug pointed out by Jan during the regression test
discussion.
* Added LastOid variable. This ought to take care of TODO item "Add a
function to return the last inserted oid, for use in psql scripts"
(under CLIENTS)
E.g.,
insert into foo values(...);
insert into bar values(..., :LastOid);
\echo $LastOid
* \d command shows constraints, rules, and triggers defined on the table
(in addition to indices)
* Various fixes, optimizations, corrections
* Documentation update as well
Note: This now requires snprintf(), which, if necessary, is taken from
src/backend/port. This is certainly a little weird, but it should
suffice
until a source tree cleanup is done.
Enjoy.
--
Peter Eisentraut Sernanders väg 10:115
1999-11-26 05:24:17 +01:00
/* UPDATE */
2000-04-12 19:17:23 +02:00
/* If prev. word is UPDATE suggest a list of tables */
else if ( strcasecmp ( prev_wd , " UPDATE " ) = = 0 )
2003-03-27 17:45:01 +01:00
COMPLETE_WITH_SCHEMA_QUERY ( Query_for_list_of_tables ) ;
2000-04-12 19:17:23 +02:00
/* Complete UPDATE <table> with "SET" */
else if ( strcasecmp ( prev2_wd , " UPDATE " ) = = 0 )
COMPLETE_WITH_CONST ( " SET " ) ;
/*
* If the previous word is SET ( and it wasn ' t caught above as the
* _first_ word ) the word before it was ( hopefully ) a table name and
* we ' ll now make a list of attributes .
*/
else if ( strcasecmp ( prev_wd , " SET " ) = = 0 )
COMPLETE_WITH_ATTR ( prev2_wd ) ;
* Includes tab completion. It's not magic, but it's very cool. At any
rate
it's better than what used to be there.
* Does proper SQL "host variable" substitution as pointed out by Andreas
Zeugwetter (thanks): select * from :foo; Also some changes in how ':'
and ';' are treated (escape with \ to send to backend). This does
_not_
affect the '::' cast operator, but perhaps others that contain : or ;
(but there are none right now).
* To show description with a <something> listing, append '?' to command
name, e.g., \df?. This seemed to be the convenient and logical
solution.
Or append a '+' to see more useless information, e.g., \df+.
* Fixed fflush()'ing bug pointed out by Jan during the regression test
discussion.
* Added LastOid variable. This ought to take care of TODO item "Add a
function to return the last inserted oid, for use in psql scripts"
(under CLIENTS)
E.g.,
insert into foo values(...);
insert into bar values(..., :LastOid);
\echo $LastOid
* \d command shows constraints, rules, and triggers defined on the table
(in addition to indices)
* Various fixes, optimizations, corrections
* Documentation update as well
Note: This now requires snprintf(), which, if necessary, is taken from
src/backend/port. This is certainly a little weird, but it should
suffice
until a source tree cleanup is done.
Enjoy.
--
Peter Eisentraut Sernanders väg 10:115
1999-11-26 05:24:17 +01:00
/* VACUUM */
2000-04-12 19:17:23 +02:00
else if ( strcasecmp ( prev_wd , " VACUUM " ) = = 0 )
2002-08-10 05:56:24 +02:00
COMPLETE_WITH_QUERY ( " SELECT relname FROM pg_catalog.pg_class WHERE relkind='r' and substr(relname,1,%d)='%s' and pg_catalog.pg_table_is_visible(oid) UNION SELECT 'FULL'::name UNION SELECT 'ANALYZE'::name " ) ;
2002-12-13 06:36:24 +01:00
else if ( strcasecmp ( prev2_wd , " VACUUM " ) = = 0 & &
( strcasecmp ( prev_wd , " FULL " ) = = 0 | |
strcasecmp ( prev_wd , " ANALYZE " ) = = 0 ) )
2003-03-27 17:45:01 +01:00
COMPLETE_WITH_SCHEMA_QUERY ( Query_for_list_of_tables ) ;
* Includes tab completion. It's not magic, but it's very cool. At any
rate
it's better than what used to be there.
* Does proper SQL "host variable" substitution as pointed out by Andreas
Zeugwetter (thanks): select * from :foo; Also some changes in how ':'
and ';' are treated (escape with \ to send to backend). This does
_not_
affect the '::' cast operator, but perhaps others that contain : or ;
(but there are none right now).
* To show description with a <something> listing, append '?' to command
name, e.g., \df?. This seemed to be the convenient and logical
solution.
Or append a '+' to see more useless information, e.g., \df+.
* Fixed fflush()'ing bug pointed out by Jan during the regression test
discussion.
* Added LastOid variable. This ought to take care of TODO item "Add a
function to return the last inserted oid, for use in psql scripts"
(under CLIENTS)
E.g.,
insert into foo values(...);
insert into bar values(..., :LastOid);
\echo $LastOid
* \d command shows constraints, rules, and triggers defined on the table
(in addition to indices)
* Various fixes, optimizations, corrections
* Documentation update as well
Note: This now requires snprintf(), which, if necessary, is taken from
src/backend/port. This is certainly a little weird, but it should
suffice
until a source tree cleanup is done.
Enjoy.
--
Peter Eisentraut Sernanders väg 10:115
1999-11-26 05:24:17 +01:00
2002-07-30 18:35:05 +02:00
/* WHERE */
/* Simple case of the word before the where being the table name */
2002-09-04 22:31:48 +02:00
else if ( strcasecmp ( prev_wd , " WHERE " ) = = 0 )
2002-07-30 18:35:05 +02:00
COMPLETE_WITH_ATTR ( prev2_wd ) ;
1999-12-10 04:59:30 +01:00
/* ... FROM ... */
2003-03-27 17:45:01 +01:00
/* TODO: also include SRF ? */
2000-04-12 19:17:23 +02:00
else if ( strcasecmp ( prev_wd , " FROM " ) = = 0 )
2003-03-27 17:45:01 +01:00
COMPLETE_WITH_SCHEMA_QUERY ( Query_for_list_of_tsv ) ;
1999-12-10 04:59:30 +01:00
* Includes tab completion. It's not magic, but it's very cool. At any
rate
it's better than what used to be there.
* Does proper SQL "host variable" substitution as pointed out by Andreas
Zeugwetter (thanks): select * from :foo; Also some changes in how ':'
and ';' are treated (escape with \ to send to backend). This does
_not_
affect the '::' cast operator, but perhaps others that contain : or ;
(but there are none right now).
* To show description with a <something> listing, append '?' to command
name, e.g., \df?. This seemed to be the convenient and logical
solution.
Or append a '+' to see more useless information, e.g., \df+.
* Fixed fflush()'ing bug pointed out by Jan during the regression test
discussion.
* Added LastOid variable. This ought to take care of TODO item "Add a
function to return the last inserted oid, for use in psql scripts"
(under CLIENTS)
E.g.,
insert into foo values(...);
insert into bar values(..., :LastOid);
\echo $LastOid
* \d command shows constraints, rules, and triggers defined on the table
(in addition to indices)
* Various fixes, optimizations, corrections
* Documentation update as well
Note: This now requires snprintf(), which, if necessary, is taken from
src/backend/port. This is certainly a little weird, but it should
suffice
until a source tree cleanup is done.
Enjoy.
--
Peter Eisentraut Sernanders väg 10:115
1999-11-26 05:24:17 +01:00
/* Backslash commands */
2003-03-27 17:45:01 +01:00
/* TODO: \dc \dd \dl */
2000-04-12 19:17:23 +02:00
else if ( strcmp ( prev_wd , " \\ connect " ) = = 0 | | strcmp ( prev_wd , " \\ c " ) = = 0 )
COMPLETE_WITH_QUERY ( Query_for_list_of_databases ) ;
2003-03-27 17:45:01 +01:00
else if ( strcmp ( prev_wd , " \\ d " ) = = 0 | | strcmp ( prev_wd , " \\ d+ " ) = = 0 )
COMPLETE_WITH_SCHEMA_QUERY ( Query_for_list_of_tisv ) ;
else if ( strcmp ( prev_wd , " \\ da " ) = = 0 )
COMPLETE_WITH_SCHEMA_QUERY ( Query_for_list_of_aggregates ) ;
else if ( strcmp ( prev_wd , " \\ dD " ) = = 0 )
COMPLETE_WITH_SCHEMA_QUERY ( Query_for_list_of_domains ) ;
else if ( strcmp ( prev_wd , " \\ df " ) = = 0 | | strcmp ( prev_wd , " \\ df+ " ) = = 0 )
COMPLETE_WITH_SCHEMA_QUERY ( Query_for_list_of_functions ) ;
else if ( strcmp ( prev_wd , " \\ di " ) = = 0 | | strcmp ( prev_wd , " \\ di+ " ) = = 0 )
COMPLETE_WITH_SCHEMA_QUERY ( Query_for_list_of_indexes ) ;
else if ( strcmp ( prev_wd , " \\ dn " ) = = 0 )
COMPLETE_WITH_QUERY ( Query_for_list_of_schemas ) ;
else if ( strcmp ( prev_wd , " \\ dp " ) = = 0 | | strcmp ( prev_wd , " \\ z " ) = = 0 )
COMPLETE_WITH_SCHEMA_QUERY ( Query_for_list_of_tsv ) ;
else if ( strcmp ( prev_wd , " \\ ds " ) = = 0 | | strcmp ( prev_wd , " \\ ds+ " ) = = 0 )
COMPLETE_WITH_SCHEMA_QUERY ( Query_for_list_of_sequences ) ;
else if ( strcmp ( prev_wd , " \\ dS " ) = = 0 | | strcmp ( prev_wd , " \\ dS+ " ) = = 0 )
COMPLETE_WITH_QUERY ( Query_for_list_of_system_relations ) ;
else if ( strcmp ( prev_wd , " \\ dt " ) = = 0 | | strcmp ( prev_wd , " \\ dt+ " ) = = 0 )
COMPLETE_WITH_SCHEMA_QUERY ( Query_for_list_of_tables ) ;
else if ( strcmp ( prev_wd , " \\ dT " ) = = 0 | | strcmp ( prev_wd , " \\ dT+ " ) = = 0 )
COMPLETE_WITH_SCHEMA_QUERY ( Query_for_list_of_datatypes ) ;
else if ( strcmp ( prev_wd , " \\ du " ) = = 0 )
COMPLETE_WITH_QUERY ( Query_for_list_of_users ) ;
else if ( strcmp ( prev_wd , " \\ dv " ) = = 0 | | strcmp ( prev_wd , " \\ dv+ " ) = = 0 )
COMPLETE_WITH_SCHEMA_QUERY ( Query_for_list_of_views ) ;
2003-06-12 03:38:08 +02:00
else if ( strcmp ( prev_wd , " \\ encoding " ) = = 0 )
COMPLETE_WITH_QUERY ( Query_for_list_of_encodings ) ;
2000-04-12 19:17:23 +02:00
else if ( strcmp ( prev_wd , " \\ h " ) = = 0 | | strcmp ( prev_wd , " \\ help " ) = = 0 )
COMPLETE_WITH_LIST ( sql_commands ) ;
else if ( strcmp ( prev_wd , " \\ pset " ) = = 0 )
{
2002-12-13 06:36:24 +01:00
char * my_list [ ] = { " format " , " border " , " expanded " ,
" null " , " fieldsep " , " tuples_only " , " title " , " tableattr " , " pager " ,
" recordsep " , NULL } ;
2000-04-12 19:17:23 +02:00
COMPLETE_WITH_LIST ( my_list ) ;
}
2001-05-07 21:31:33 +02:00
else if ( strcmp ( prev_wd , " \\ cd " ) = = 0 | |
2001-10-25 07:50:21 +02:00
strcmp ( prev_wd , " \\ e " ) = = 0 | | strcmp ( prev_wd , " \\ edit " ) = = 0 | |
2000-04-12 19:17:23 +02:00
strcmp ( prev_wd , " \\ g " ) = = 0 | |
strcmp ( prev_wd , " \\ i " ) = = 0 | | strcmp ( prev_wd , " \\ include " ) = = 0 | |
2001-10-25 07:50:21 +02:00
strcmp ( prev_wd , " \\ o " ) = = 0 | | strcmp ( prev_wd , " \\ out " ) = = 0 | |
2000-04-12 19:17:23 +02:00
strcmp ( prev_wd , " \\ s " ) = = 0 | |
2001-10-25 07:50:21 +02:00
strcmp ( prev_wd , " \\ w " ) = = 0 | | strcmp ( prev_wd , " \\ write " ) = = 0
2000-04-12 19:17:23 +02:00
)
matches = completion_matches ( text , filename_completion_function ) ;
/*
* Finally , we look through the list of " things " , such as TABLE , INDEX
* and check if that was the previous word . If so , execute the query
* to get a list of them .
*/
else
{
int i ;
for ( i = 0 ; words_after_create [ i ] . name ; i + + )
if ( strcasecmp ( prev_wd , words_after_create [ i ] . name ) = = 0 )
{
2003-03-27 17:45:01 +01:00
if ( words_after_create [ i ] . with_schema = = WITH_SCHEMA )
COMPLETE_WITH_SCHEMA_QUERY ( words_after_create [ i ] . query ) ;
else
COMPLETE_WITH_QUERY ( words_after_create [ i ] . query ) ;
2000-04-12 19:17:23 +02:00
break ;
}
}
/*
* If we still don ' t have anything to match we have to fabricate some
* sort of default list . If we were to just return NULL , readline
* automatically attempts filename completion , and that ' s usually no
* good .
*/
if ( matches = = NULL )
{
COMPLETE_WITH_CONST ( " " ) ;
2000-01-22 00:32:36 +01:00
# ifdef HAVE_RL_COMPLETION_APPEND_CHARACTER
2000-04-12 19:17:23 +02:00
rl_completion_append_character = ' \0 ' ;
2000-01-22 00:32:36 +01:00
# endif
2000-04-12 19:17:23 +02:00
}
* Includes tab completion. It's not magic, but it's very cool. At any
rate
it's better than what used to be there.
* Does proper SQL "host variable" substitution as pointed out by Andreas
Zeugwetter (thanks): select * from :foo; Also some changes in how ':'
and ';' are treated (escape with \ to send to backend). This does
_not_
affect the '::' cast operator, but perhaps others that contain : or ;
(but there are none right now).
* To show description with a <something> listing, append '?' to command
name, e.g., \df?. This seemed to be the convenient and logical
solution.
Or append a '+' to see more useless information, e.g., \df+.
* Fixed fflush()'ing bug pointed out by Jan during the regression test
discussion.
* Added LastOid variable. This ought to take care of TODO item "Add a
function to return the last inserted oid, for use in psql scripts"
(under CLIENTS)
E.g.,
insert into foo values(...);
insert into bar values(..., :LastOid);
\echo $LastOid
* \d command shows constraints, rules, and triggers defined on the table
(in addition to indices)
* Various fixes, optimizations, corrections
* Documentation update as well
Note: This now requires snprintf(), which, if necessary, is taken from
src/backend/port. This is certainly a little weird, but it should
suffice
until a source tree cleanup is done.
Enjoy.
--
Peter Eisentraut Sernanders väg 10:115
1999-11-26 05:24:17 +01:00
2000-04-12 19:17:23 +02:00
/* free storage */
free ( prev_wd ) ;
free ( prev2_wd ) ;
free ( prev3_wd ) ;
free ( prev4_wd ) ;
/* Return our Grand List O' Matches */
return matches ;
* Includes tab completion. It's not magic, but it's very cool. At any
rate
it's better than what used to be there.
* Does proper SQL "host variable" substitution as pointed out by Andreas
Zeugwetter (thanks): select * from :foo; Also some changes in how ':'
and ';' are treated (escape with \ to send to backend). This does
_not_
affect the '::' cast operator, but perhaps others that contain : or ;
(but there are none right now).
* To show description with a <something> listing, append '?' to command
name, e.g., \df?. This seemed to be the convenient and logical
solution.
Or append a '+' to see more useless information, e.g., \df+.
* Fixed fflush()'ing bug pointed out by Jan during the regression test
discussion.
* Added LastOid variable. This ought to take care of TODO item "Add a
function to return the last inserted oid, for use in psql scripts"
(under CLIENTS)
E.g.,
insert into foo values(...);
insert into bar values(..., :LastOid);
\echo $LastOid
* \d command shows constraints, rules, and triggers defined on the table
(in addition to indices)
* Various fixes, optimizations, corrections
* Documentation update as well
Note: This now requires snprintf(), which, if necessary, is taken from
src/backend/port. This is certainly a little weird, but it should
suffice
until a source tree cleanup is done.
Enjoy.
--
Peter Eisentraut Sernanders väg 10:115
1999-11-26 05:24:17 +01:00
}
/* GENERATOR FUNCTIONS
These functions do all the actual work of completing the input . They get
passed the text so far and the count how many times they have been called so
far with the same text .
If you read the above carefully , you ' ll see that these don ' t get called
directly but through the readline interface .
The return value is expected to be the full completion of the text , going
through a list each time , or NULL if there are no more matches . The string
will be free ( ) ' d be readline , so you must run it through strdup ( ) or
something of that sort .
*/
/* This one gives you one from a list of things you can put after CREATE or DROP
as defined above .
*/
2000-04-21 05:01:54 +02:00
static char *
2003-04-03 22:18:16 +02:00
create_command_generator ( const char * text , int state )
* Includes tab completion. It's not magic, but it's very cool. At any
rate
it's better than what used to be there.
* Does proper SQL "host variable" substitution as pointed out by Andreas
Zeugwetter (thanks): select * from :foo; Also some changes in how ':'
and ';' are treated (escape with \ to send to backend). This does
_not_
affect the '::' cast operator, but perhaps others that contain : or ;
(but there are none right now).
* To show description with a <something> listing, append '?' to command
name, e.g., \df?. This seemed to be the convenient and logical
solution.
Or append a '+' to see more useless information, e.g., \df+.
* Fixed fflush()'ing bug pointed out by Jan during the regression test
discussion.
* Added LastOid variable. This ought to take care of TODO item "Add a
function to return the last inserted oid, for use in psql scripts"
(under CLIENTS)
E.g.,
insert into foo values(...);
insert into bar values(..., :LastOid);
\echo $LastOid
* \d command shows constraints, rules, and triggers defined on the table
(in addition to indices)
* Various fixes, optimizations, corrections
* Documentation update as well
Note: This now requires snprintf(), which, if necessary, is taken from
src/backend/port. This is certainly a little weird, but it should
suffice
until a source tree cleanup is done.
Enjoy.
--
Peter Eisentraut Sernanders väg 10:115
1999-11-26 05:24:17 +01:00
{
2000-04-12 19:17:23 +02:00
static int list_index ,
string_length ;
char * name ;
/* If this is the first time for this completion, init some values */
if ( state = = 0 )
{
list_index = 0 ;
string_length = strlen ( text ) ;
}
/* find something that matches */
while ( ( name = words_after_create [ list_index + + ] . name ) )
if ( strncasecmp ( name , text , string_length ) = = 0 )
return xstrdup ( name ) ;
/* if nothing matches, return NULL */
return NULL ;
* Includes tab completion. It's not magic, but it's very cool. At any
rate
it's better than what used to be there.
* Does proper SQL "host variable" substitution as pointed out by Andreas
Zeugwetter (thanks): select * from :foo; Also some changes in how ':'
and ';' are treated (escape with \ to send to backend). This does
_not_
affect the '::' cast operator, but perhaps others that contain : or ;
(but there are none right now).
* To show description with a <something> listing, append '?' to command
name, e.g., \df?. This seemed to be the convenient and logical
solution.
Or append a '+' to see more useless information, e.g., \df+.
* Fixed fflush()'ing bug pointed out by Jan during the regression test
discussion.
* Added LastOid variable. This ought to take care of TODO item "Add a
function to return the last inserted oid, for use in psql scripts"
(under CLIENTS)
E.g.,
insert into foo values(...);
insert into bar values(..., :LastOid);
\echo $LastOid
* \d command shows constraints, rules, and triggers defined on the table
(in addition to indices)
* Various fixes, optimizations, corrections
* Documentation update as well
Note: This now requires snprintf(), which, if necessary, is taken from
src/backend/port. This is certainly a little weird, but it should
suffice
until a source tree cleanup is done.
Enjoy.
--
Peter Eisentraut Sernanders väg 10:115
1999-11-26 05:24:17 +01:00
}
2003-03-27 17:45:01 +01:00
/* The following two functions are wrappers for _complete_from_query */
static char *
2003-04-03 22:18:16 +02:00
complete_from_query ( const char * text , int state )
2003-03-27 17:45:01 +01:00
{
return _complete_from_query ( 0 , text , state ) ;
}
static char *
2003-04-03 22:18:16 +02:00
complete_from_schema_query ( const char * text , int state )
2003-03-27 17:45:01 +01:00
{
return _complete_from_query ( 1 , text , state ) ;
}
* Includes tab completion. It's not magic, but it's very cool. At any
rate
it's better than what used to be there.
* Does proper SQL "host variable" substitution as pointed out by Andreas
Zeugwetter (thanks): select * from :foo; Also some changes in how ':'
and ';' are treated (escape with \ to send to backend). This does
_not_
affect the '::' cast operator, but perhaps others that contain : or ;
(but there are none right now).
* To show description with a <something> listing, append '?' to command
name, e.g., \df?. This seemed to be the convenient and logical
solution.
Or append a '+' to see more useless information, e.g., \df+.
* Fixed fflush()'ing bug pointed out by Jan during the regression test
discussion.
* Added LastOid variable. This ought to take care of TODO item "Add a
function to return the last inserted oid, for use in psql scripts"
(under CLIENTS)
E.g.,
insert into foo values(...);
insert into bar values(..., :LastOid);
\echo $LastOid
* \d command shows constraints, rules, and triggers defined on the table
(in addition to indices)
* Various fixes, optimizations, corrections
* Documentation update as well
Note: This now requires snprintf(), which, if necessary, is taken from
src/backend/port. This is certainly a little weird, but it should
suffice
until a source tree cleanup is done.
Enjoy.
--
Peter Eisentraut Sernanders väg 10:115
1999-11-26 05:24:17 +01:00
/* This creates a list of matching things, according to a query pointed to
2003-03-27 17:45:01 +01:00
by completion_charp .
The query can be one of two kinds :
- A simple query which must contain a % d and a % s , which will be replaced
by the string length of the text and the text itself . The query may also
have another % s in it , which will be replaced by the value of
completion_info_charp .
or :
- A schema query used for completion of both schema and relation names ;
these are more complex and must contain in the following order :
% d % s % d % s % d % s % s % d % s
where % d is the string length of the text and % s the text itself .
See top of file for examples of both kinds of query .
* Includes tab completion. It's not magic, but it's very cool. At any
rate
it's better than what used to be there.
* Does proper SQL "host variable" substitution as pointed out by Andreas
Zeugwetter (thanks): select * from :foo; Also some changes in how ':'
and ';' are treated (escape with \ to send to backend). This does
_not_
affect the '::' cast operator, but perhaps others that contain : or ;
(but there are none right now).
* To show description with a <something> listing, append '?' to command
name, e.g., \df?. This seemed to be the convenient and logical
solution.
Or append a '+' to see more useless information, e.g., \df+.
* Fixed fflush()'ing bug pointed out by Jan during the regression test
discussion.
* Added LastOid variable. This ought to take care of TODO item "Add a
function to return the last inserted oid, for use in psql scripts"
(under CLIENTS)
E.g.,
insert into foo values(...);
insert into bar values(..., :LastOid);
\echo $LastOid
* \d command shows constraints, rules, and triggers defined on the table
(in addition to indices)
* Various fixes, optimizations, corrections
* Documentation update as well
Note: This now requires snprintf(), which, if necessary, is taken from
src/backend/port. This is certainly a little weird, but it should
suffice
until a source tree cleanup is done.
Enjoy.
--
Peter Eisentraut Sernanders väg 10:115
1999-11-26 05:24:17 +01:00
*/
2003-03-27 17:45:01 +01:00
2000-04-21 05:01:54 +02:00
static char *
2003-04-03 22:18:16 +02:00
_complete_from_query ( int is_schema_query , const char * text , int state )
* Includes tab completion. It's not magic, but it's very cool. At any
rate
it's better than what used to be there.
* Does proper SQL "host variable" substitution as pointed out by Andreas
Zeugwetter (thanks): select * from :foo; Also some changes in how ':'
and ';' are treated (escape with \ to send to backend). This does
_not_
affect the '::' cast operator, but perhaps others that contain : or ;
(but there are none right now).
* To show description with a <something> listing, append '?' to command
name, e.g., \df?. This seemed to be the convenient and logical
solution.
Or append a '+' to see more useless information, e.g., \df+.
* Fixed fflush()'ing bug pointed out by Jan during the regression test
discussion.
* Added LastOid variable. This ought to take care of TODO item "Add a
function to return the last inserted oid, for use in psql scripts"
(under CLIENTS)
E.g.,
insert into foo values(...);
insert into bar values(..., :LastOid);
\echo $LastOid
* \d command shows constraints, rules, and triggers defined on the table
(in addition to indices)
* Various fixes, optimizations, corrections
* Documentation update as well
Note: This now requires snprintf(), which, if necessary, is taken from
src/backend/port. This is certainly a little weird, but it should
suffice
until a source tree cleanup is done.
Enjoy.
--
Peter Eisentraut Sernanders väg 10:115
1999-11-26 05:24:17 +01:00
{
2000-04-12 19:17:23 +02:00
static int list_index ,
string_length ;
static PGresult * result = NULL ;
char query_buffer [ BUF_SIZE ] ;
const char * item ;
/*
2003-04-03 22:18:16 +02:00
* If this is the first time for this completion , we fetch a list of
2000-04-12 19:17:23 +02:00
* our " things " from the backend .
*/
if ( state = = 0 )
{
list_index = 0 ;
string_length = strlen ( text ) ;
/* Need to have a query */
if ( completion_charp = = NULL )
return NULL ;
2003-03-27 17:45:01 +01:00
if ( is_schema_query )
2000-04-12 19:17:23 +02:00
{
2003-03-27 17:45:01 +01:00
if ( snprintf ( query_buffer , BUF_SIZE , completion_charp , string_length , text , string_length , text , string_length , text , text , string_length , text , string_length , text ) = = - 1 )
{
ERROR_QUERY_TOO_LONG ;
return NULL ;
}
}
else {
if ( snprintf ( query_buffer , BUF_SIZE , completion_charp , string_length , text , completion_info_charp ) = = - 1 )
{
ERROR_QUERY_TOO_LONG ;
return NULL ;
}
2000-04-12 19:17:23 +02:00
}
result = exec_query ( query_buffer ) ;
}
/* Find something that matches */
if ( result & & PQresultStatus ( result ) = = PGRES_TUPLES_OK )
2002-12-13 06:36:24 +01:00
while ( list_index < PQntuples ( result ) & &
( item = PQgetvalue ( result , list_index + + , 0 ) ) )
2000-04-12 19:17:23 +02:00
if ( strncasecmp ( text , item , string_length ) = = 0 )
return xstrdup ( item ) ;
/* If nothing matches, free the db structure and return null */
PQclear ( result ) ;
result = NULL ;
return NULL ;
* Includes tab completion. It's not magic, but it's very cool. At any
rate
it's better than what used to be there.
* Does proper SQL "host variable" substitution as pointed out by Andreas
Zeugwetter (thanks): select * from :foo; Also some changes in how ':'
and ';' are treated (escape with \ to send to backend). This does
_not_
affect the '::' cast operator, but perhaps others that contain : or ;
(but there are none right now).
* To show description with a <something> listing, append '?' to command
name, e.g., \df?. This seemed to be the convenient and logical
solution.
Or append a '+' to see more useless information, e.g., \df+.
* Fixed fflush()'ing bug pointed out by Jan during the regression test
discussion.
* Added LastOid variable. This ought to take care of TODO item "Add a
function to return the last inserted oid, for use in psql scripts"
(under CLIENTS)
E.g.,
insert into foo values(...);
insert into bar values(..., :LastOid);
\echo $LastOid
* \d command shows constraints, rules, and triggers defined on the table
(in addition to indices)
* Various fixes, optimizations, corrections
* Documentation update as well
Note: This now requires snprintf(), which, if necessary, is taken from
src/backend/port. This is certainly a little weird, but it should
suffice
until a source tree cleanup is done.
Enjoy.
--
Peter Eisentraut Sernanders väg 10:115
1999-11-26 05:24:17 +01:00
}
/* This function returns in order one of a fixed, NULL pointer terminated list
of strings ( if matching ) . This can be used if there are only a fixed number
SQL words that can appear at certain spot .
*/
2000-04-21 05:01:54 +02:00
static char *
2003-04-03 22:18:16 +02:00
complete_from_list ( const char * text , int state )
2000-04-12 19:17:23 +02:00
{
static int string_length ,
Clean up psql:
Add simple ALTER DATABASE, ALTER TRIGGER, CHECK POINT, CREATE
CONVERSION, CREATE DOMAIN, CREATE LANGUAGE, DEALLOCATE, DROP CONVERSION,
DROP DOMAIN, DROP LANGUAGE, EXECUTE, PREPARE
Complete CAST in CREATE CAST and DROP CAST but doesn't suggest what
should follow.
Add many more SET / SHOW variables to the list. Taken from SHOW ALL
output.
Complete a case sensitive search to allow \dD, \dd, \dS, \ds, \h, \H to
complete properly. But there are no matches, then try a case
insensitive search to allow case conversion. Add all missing help
options.
\Q<tab> -> \q
\dD<tab> -> \dD
\dd<tab> -> \dd
\D<tab><tab><tab> -> \d (with listing of \d? commands)
sel<tab> -> SELECT
Rod Taylor
2002-11-15 04:07:52 +01:00
list_index ,
matches ;
static bool casesensitive ;
2000-04-12 19:17:23 +02:00
char * item ;
* Includes tab completion. It's not magic, but it's very cool. At any
rate
it's better than what used to be there.
* Does proper SQL "host variable" substitution as pointed out by Andreas
Zeugwetter (thanks): select * from :foo; Also some changes in how ':'
and ';' are treated (escape with \ to send to backend). This does
_not_
affect the '::' cast operator, but perhaps others that contain : or ;
(but there are none right now).
* To show description with a <something> listing, append '?' to command
name, e.g., \df?. This seemed to be the convenient and logical
solution.
Or append a '+' to see more useless information, e.g., \df+.
* Fixed fflush()'ing bug pointed out by Jan during the regression test
discussion.
* Added LastOid variable. This ought to take care of TODO item "Add a
function to return the last inserted oid, for use in psql scripts"
(under CLIENTS)
E.g.,
insert into foo values(...);
insert into bar values(..., :LastOid);
\echo $LastOid
* \d command shows constraints, rules, and triggers defined on the table
(in addition to indices)
* Various fixes, optimizations, corrections
* Documentation update as well
Note: This now requires snprintf(), which, if necessary, is taken from
src/backend/port. This is certainly a little weird, but it should
suffice
until a source tree cleanup is done.
Enjoy.
--
Peter Eisentraut Sernanders väg 10:115
1999-11-26 05:24:17 +01:00
2000-04-12 19:17:23 +02:00
/* need to have a list */
* Includes tab completion. It's not magic, but it's very cool. At any
rate
it's better than what used to be there.
* Does proper SQL "host variable" substitution as pointed out by Andreas
Zeugwetter (thanks): select * from :foo; Also some changes in how ':'
and ';' are treated (escape with \ to send to backend). This does
_not_
affect the '::' cast operator, but perhaps others that contain : or ;
(but there are none right now).
* To show description with a <something> listing, append '?' to command
name, e.g., \df?. This seemed to be the convenient and logical
solution.
Or append a '+' to see more useless information, e.g., \df+.
* Fixed fflush()'ing bug pointed out by Jan during the regression test
discussion.
* Added LastOid variable. This ought to take care of TODO item "Add a
function to return the last inserted oid, for use in psql scripts"
(under CLIENTS)
E.g.,
insert into foo values(...);
insert into bar values(..., :LastOid);
\echo $LastOid
* \d command shows constraints, rules, and triggers defined on the table
(in addition to indices)
* Various fixes, optimizations, corrections
* Documentation update as well
Note: This now requires snprintf(), which, if necessary, is taken from
src/backend/port. This is certainly a little weird, but it should
suffice
until a source tree cleanup is done.
Enjoy.
--
Peter Eisentraut Sernanders väg 10:115
1999-11-26 05:24:17 +01:00
# ifdef USE_ASSERT_CHECKING
2000-04-12 19:17:23 +02:00
assert ( completion_charpp ) ;
* Includes tab completion. It's not magic, but it's very cool. At any
rate
it's better than what used to be there.
* Does proper SQL "host variable" substitution as pointed out by Andreas
Zeugwetter (thanks): select * from :foo; Also some changes in how ':'
and ';' are treated (escape with \ to send to backend). This does
_not_
affect the '::' cast operator, but perhaps others that contain : or ;
(but there are none right now).
* To show description with a <something> listing, append '?' to command
name, e.g., \df?. This seemed to be the convenient and logical
solution.
Or append a '+' to see more useless information, e.g., \df+.
* Fixed fflush()'ing bug pointed out by Jan during the regression test
discussion.
* Added LastOid variable. This ought to take care of TODO item "Add a
function to return the last inserted oid, for use in psql scripts"
(under CLIENTS)
E.g.,
insert into foo values(...);
insert into bar values(..., :LastOid);
\echo $LastOid
* \d command shows constraints, rules, and triggers defined on the table
(in addition to indices)
* Various fixes, optimizations, corrections
* Documentation update as well
Note: This now requires snprintf(), which, if necessary, is taken from
src/backend/port. This is certainly a little weird, but it should
suffice
until a source tree cleanup is done.
Enjoy.
--
Peter Eisentraut Sernanders väg 10:115
1999-11-26 05:24:17 +01:00
# endif
2000-04-12 19:17:23 +02:00
/* Initialization */
if ( state = = 0 )
{
list_index = 0 ;
string_length = strlen ( text ) ;
Clean up psql:
Add simple ALTER DATABASE, ALTER TRIGGER, CHECK POINT, CREATE
CONVERSION, CREATE DOMAIN, CREATE LANGUAGE, DEALLOCATE, DROP CONVERSION,
DROP DOMAIN, DROP LANGUAGE, EXECUTE, PREPARE
Complete CAST in CREATE CAST and DROP CAST but doesn't suggest what
should follow.
Add many more SET / SHOW variables to the list. Taken from SHOW ALL
output.
Complete a case sensitive search to allow \dD, \dd, \dS, \ds, \h, \H to
complete properly. But there are no matches, then try a case
insensitive search to allow case conversion. Add all missing help
options.
\Q<tab> -> \q
\dD<tab> -> \dD
\dd<tab> -> \dd
\D<tab><tab><tab> -> \d (with listing of \d? commands)
sel<tab> -> SELECT
Rod Taylor
2002-11-15 04:07:52 +01:00
casesensitive = true ;
matches = 0 ;
2000-04-12 19:17:23 +02:00
}
* Includes tab completion. It's not magic, but it's very cool. At any
rate
it's better than what used to be there.
* Does proper SQL "host variable" substitution as pointed out by Andreas
Zeugwetter (thanks): select * from :foo; Also some changes in how ':'
and ';' are treated (escape with \ to send to backend). This does
_not_
affect the '::' cast operator, but perhaps others that contain : or ;
(but there are none right now).
* To show description with a <something> listing, append '?' to command
name, e.g., \df?. This seemed to be the convenient and logical
solution.
Or append a '+' to see more useless information, e.g., \df+.
* Fixed fflush()'ing bug pointed out by Jan during the regression test
discussion.
* Added LastOid variable. This ought to take care of TODO item "Add a
function to return the last inserted oid, for use in psql scripts"
(under CLIENTS)
E.g.,
insert into foo values(...);
insert into bar values(..., :LastOid);
\echo $LastOid
* \d command shows constraints, rules, and triggers defined on the table
(in addition to indices)
* Various fixes, optimizations, corrections
* Documentation update as well
Note: This now requires snprintf(), which, if necessary, is taken from
src/backend/port. This is certainly a little weird, but it should
suffice
until a source tree cleanup is done.
Enjoy.
--
Peter Eisentraut Sernanders väg 10:115
1999-11-26 05:24:17 +01:00
2000-04-12 19:17:23 +02:00
while ( ( item = completion_charpp [ list_index + + ] ) )
Clean up psql:
Add simple ALTER DATABASE, ALTER TRIGGER, CHECK POINT, CREATE
CONVERSION, CREATE DOMAIN, CREATE LANGUAGE, DEALLOCATE, DROP CONVERSION,
DROP DOMAIN, DROP LANGUAGE, EXECUTE, PREPARE
Complete CAST in CREATE CAST and DROP CAST but doesn't suggest what
should follow.
Add many more SET / SHOW variables to the list. Taken from SHOW ALL
output.
Complete a case sensitive search to allow \dD, \dd, \dS, \ds, \h, \H to
complete properly. But there are no matches, then try a case
insensitive search to allow case conversion. Add all missing help
options.
\Q<tab> -> \q
\dD<tab> -> \dD
\dd<tab> -> \dd
\D<tab><tab><tab> -> \d (with listing of \d? commands)
sel<tab> -> SELECT
Rod Taylor
2002-11-15 04:07:52 +01:00
{
/* First pass is case sensitive */
if ( casesensitive & & strncmp ( text , item , string_length ) = = 0 )
{
matches + + ;
return xstrdup ( item ) ;
}
/* Second pass is case insensitive, don't bother counting matches */
if ( ! casesensitive & & strncasecmp ( text , item , string_length ) = = 0 )
2000-04-12 19:17:23 +02:00
return xstrdup ( item ) ;
Clean up psql:
Add simple ALTER DATABASE, ALTER TRIGGER, CHECK POINT, CREATE
CONVERSION, CREATE DOMAIN, CREATE LANGUAGE, DEALLOCATE, DROP CONVERSION,
DROP DOMAIN, DROP LANGUAGE, EXECUTE, PREPARE
Complete CAST in CREATE CAST and DROP CAST but doesn't suggest what
should follow.
Add many more SET / SHOW variables to the list. Taken from SHOW ALL
output.
Complete a case sensitive search to allow \dD, \dd, \dS, \ds, \h, \H to
complete properly. But there are no matches, then try a case
insensitive search to allow case conversion. Add all missing help
options.
\Q<tab> -> \q
\dD<tab> -> \dD
\dd<tab> -> \dd
\D<tab><tab><tab> -> \d (with listing of \d? commands)
sel<tab> -> SELECT
Rod Taylor
2002-11-15 04:07:52 +01:00
}
/*
* No matches found . If we ' re not case insensitive already , lets switch
* to being case insensitive and try again
*/
if ( casesensitive & & matches = = 0 )
{
casesensitive = false ;
list_index = 0 ;
state + + ;
return ( complete_from_list ( text , state ) ) ;
}
* Includes tab completion. It's not magic, but it's very cool. At any
rate
it's better than what used to be there.
* Does proper SQL "host variable" substitution as pointed out by Andreas
Zeugwetter (thanks): select * from :foo; Also some changes in how ':'
and ';' are treated (escape with \ to send to backend). This does
_not_
affect the '::' cast operator, but perhaps others that contain : or ;
(but there are none right now).
* To show description with a <something> listing, append '?' to command
name, e.g., \df?. This seemed to be the convenient and logical
solution.
Or append a '+' to see more useless information, e.g., \df+.
* Fixed fflush()'ing bug pointed out by Jan during the regression test
discussion.
* Added LastOid variable. This ought to take care of TODO item "Add a
function to return the last inserted oid, for use in psql scripts"
(under CLIENTS)
E.g.,
insert into foo values(...);
insert into bar values(..., :LastOid);
\echo $LastOid
* \d command shows constraints, rules, and triggers defined on the table
(in addition to indices)
* Various fixes, optimizations, corrections
* Documentation update as well
Note: This now requires snprintf(), which, if necessary, is taken from
src/backend/port. This is certainly a little weird, but it should
suffice
until a source tree cleanup is done.
Enjoy.
--
Peter Eisentraut Sernanders väg 10:115
1999-11-26 05:24:17 +01:00
2000-04-12 19:17:23 +02:00
/* If no more matches, return null. */
return NULL ;
* Includes tab completion. It's not magic, but it's very cool. At any
rate
it's better than what used to be there.
* Does proper SQL "host variable" substitution as pointed out by Andreas
Zeugwetter (thanks): select * from :foo; Also some changes in how ':'
and ';' are treated (escape with \ to send to backend). This does
_not_
affect the '::' cast operator, but perhaps others that contain : or ;
(but there are none right now).
* To show description with a <something> listing, append '?' to command
name, e.g., \df?. This seemed to be the convenient and logical
solution.
Or append a '+' to see more useless information, e.g., \df+.
* Fixed fflush()'ing bug pointed out by Jan during the regression test
discussion.
* Added LastOid variable. This ought to take care of TODO item "Add a
function to return the last inserted oid, for use in psql scripts"
(under CLIENTS)
E.g.,
insert into foo values(...);
insert into bar values(..., :LastOid);
\echo $LastOid
* \d command shows constraints, rules, and triggers defined on the table
(in addition to indices)
* Various fixes, optimizations, corrections
* Documentation update as well
Note: This now requires snprintf(), which, if necessary, is taken from
src/backend/port. This is certainly a little weird, but it should
suffice
until a source tree cleanup is done.
Enjoy.
--
Peter Eisentraut Sernanders väg 10:115
1999-11-26 05:24:17 +01:00
}
/* This function returns one fixed string the first time even if it doesn't
match what ' s there , and nothing the second time . This should be used if there
is only one possibility that can appear at a certain spot , so misspellings
will be overwritten .
The string to be passed must be in completion_charp .
*/
2000-04-21 05:01:54 +02:00
static char *
2003-04-03 22:18:16 +02:00
complete_from_const ( const char * text , int state )
* Includes tab completion. It's not magic, but it's very cool. At any
rate
it's better than what used to be there.
* Does proper SQL "host variable" substitution as pointed out by Andreas
Zeugwetter (thanks): select * from :foo; Also some changes in how ':'
and ';' are treated (escape with \ to send to backend). This does
_not_
affect the '::' cast operator, but perhaps others that contain : or ;
(but there are none right now).
* To show description with a <something> listing, append '?' to command
name, e.g., \df?. This seemed to be the convenient and logical
solution.
Or append a '+' to see more useless information, e.g., \df+.
* Fixed fflush()'ing bug pointed out by Jan during the regression test
discussion.
* Added LastOid variable. This ought to take care of TODO item "Add a
function to return the last inserted oid, for use in psql scripts"
(under CLIENTS)
E.g.,
insert into foo values(...);
insert into bar values(..., :LastOid);
\echo $LastOid
* \d command shows constraints, rules, and triggers defined on the table
(in addition to indices)
* Various fixes, optimizations, corrections
* Documentation update as well
Note: This now requires snprintf(), which, if necessary, is taken from
src/backend/port. This is certainly a little weird, but it should
suffice
until a source tree cleanup is done.
Enjoy.
--
Peter Eisentraut Sernanders väg 10:115
1999-11-26 05:24:17 +01:00
{
2000-04-12 19:17:23 +02:00
( void ) text ; /* We don't care about what was entered
* already . */
* Includes tab completion. It's not magic, but it's very cool. At any
rate
it's better than what used to be there.
* Does proper SQL "host variable" substitution as pointed out by Andreas
Zeugwetter (thanks): select * from :foo; Also some changes in how ':'
and ';' are treated (escape with \ to send to backend). This does
_not_
affect the '::' cast operator, but perhaps others that contain : or ;
(but there are none right now).
* To show description with a <something> listing, append '?' to command
name, e.g., \df?. This seemed to be the convenient and logical
solution.
Or append a '+' to see more useless information, e.g., \df+.
* Fixed fflush()'ing bug pointed out by Jan during the regression test
discussion.
* Added LastOid variable. This ought to take care of TODO item "Add a
function to return the last inserted oid, for use in psql scripts"
(under CLIENTS)
E.g.,
insert into foo values(...);
insert into bar values(..., :LastOid);
\echo $LastOid
* \d command shows constraints, rules, and triggers defined on the table
(in addition to indices)
* Various fixes, optimizations, corrections
* Documentation update as well
Note: This now requires snprintf(), which, if necessary, is taken from
src/backend/port. This is certainly a little weird, but it should
suffice
until a source tree cleanup is done.
Enjoy.
--
Peter Eisentraut Sernanders väg 10:115
1999-11-26 05:24:17 +01:00
# ifdef USE_ASSERT_CHECKING
2000-04-12 19:17:23 +02:00
assert ( completion_charp ) ;
* Includes tab completion. It's not magic, but it's very cool. At any
rate
it's better than what used to be there.
* Does proper SQL "host variable" substitution as pointed out by Andreas
Zeugwetter (thanks): select * from :foo; Also some changes in how ':'
and ';' are treated (escape with \ to send to backend). This does
_not_
affect the '::' cast operator, but perhaps others that contain : or ;
(but there are none right now).
* To show description with a <something> listing, append '?' to command
name, e.g., \df?. This seemed to be the convenient and logical
solution.
Or append a '+' to see more useless information, e.g., \df+.
* Fixed fflush()'ing bug pointed out by Jan during the regression test
discussion.
* Added LastOid variable. This ought to take care of TODO item "Add a
function to return the last inserted oid, for use in psql scripts"
(under CLIENTS)
E.g.,
insert into foo values(...);
insert into bar values(..., :LastOid);
\echo $LastOid
* \d command shows constraints, rules, and triggers defined on the table
(in addition to indices)
* Various fixes, optimizations, corrections
* Documentation update as well
Note: This now requires snprintf(), which, if necessary, is taken from
src/backend/port. This is certainly a little weird, but it should
suffice
until a source tree cleanup is done.
Enjoy.
--
Peter Eisentraut Sernanders väg 10:115
1999-11-26 05:24:17 +01:00
# endif
2000-04-12 19:17:23 +02:00
if ( state = = 0 )
return xstrdup ( completion_charp ) ;
else
return NULL ;
* Includes tab completion. It's not magic, but it's very cool. At any
rate
it's better than what used to be there.
* Does proper SQL "host variable" substitution as pointed out by Andreas
Zeugwetter (thanks): select * from :foo; Also some changes in how ':'
and ';' are treated (escape with \ to send to backend). This does
_not_
affect the '::' cast operator, but perhaps others that contain : or ;
(but there are none right now).
* To show description with a <something> listing, append '?' to command
name, e.g., \df?. This seemed to be the convenient and logical
solution.
Or append a '+' to see more useless information, e.g., \df+.
* Fixed fflush()'ing bug pointed out by Jan during the regression test
discussion.
* Added LastOid variable. This ought to take care of TODO item "Add a
function to return the last inserted oid, for use in psql scripts"
(under CLIENTS)
E.g.,
insert into foo values(...);
insert into bar values(..., :LastOid);
\echo $LastOid
* \d command shows constraints, rules, and triggers defined on the table
(in addition to indices)
* Various fixes, optimizations, corrections
* Documentation update as well
Note: This now requires snprintf(), which, if necessary, is taken from
src/backend/port. This is certainly a little weird, but it should
suffice
until a source tree cleanup is done.
Enjoy.
--
Peter Eisentraut Sernanders väg 10:115
1999-11-26 05:24:17 +01:00
}
/* HELPER FUNCTIONS */
/* Execute a query and report any errors. This should be the preferred way of
talking to the database in this file .
Note that the query passed in here must not have a semicolon at the end
because we need to append LIMIT xxx .
*/
2000-04-21 05:01:54 +02:00
static PGresult *
2000-04-12 19:17:23 +02:00
exec_query ( char * query )
* Includes tab completion. It's not magic, but it's very cool. At any
rate
it's better than what used to be there.
* Does proper SQL "host variable" substitution as pointed out by Andreas
Zeugwetter (thanks): select * from :foo; Also some changes in how ':'
and ';' are treated (escape with \ to send to backend). This does
_not_
affect the '::' cast operator, but perhaps others that contain : or ;
(but there are none right now).
* To show description with a <something> listing, append '?' to command
name, e.g., \df?. This seemed to be the convenient and logical
solution.
Or append a '+' to see more useless information, e.g., \df+.
* Fixed fflush()'ing bug pointed out by Jan during the regression test
discussion.
* Added LastOid variable. This ought to take care of TODO item "Add a
function to return the last inserted oid, for use in psql scripts"
(under CLIENTS)
E.g.,
insert into foo values(...);
insert into bar values(..., :LastOid);
\echo $LastOid
* \d command shows constraints, rules, and triggers defined on the table
(in addition to indices)
* Various fixes, optimizations, corrections
* Documentation update as well
Note: This now requires snprintf(), which, if necessary, is taken from
src/backend/port. This is certainly a little weird, but it should
suffice
until a source tree cleanup is done.
Enjoy.
--
Peter Eisentraut Sernanders väg 10:115
1999-11-26 05:24:17 +01:00
{
2000-04-12 19:17:23 +02:00
PGresult * result ;
char query_buffer [ BUF_SIZE ] ;
* Includes tab completion. It's not magic, but it's very cool. At any
rate
it's better than what used to be there.
* Does proper SQL "host variable" substitution as pointed out by Andreas
Zeugwetter (thanks): select * from :foo; Also some changes in how ':'
and ';' are treated (escape with \ to send to backend). This does
_not_
affect the '::' cast operator, but perhaps others that contain : or ;
(but there are none right now).
* To show description with a <something> listing, append '?' to command
name, e.g., \df?. This seemed to be the convenient and logical
solution.
Or append a '+' to see more useless information, e.g., \df+.
* Fixed fflush()'ing bug pointed out by Jan during the regression test
discussion.
* Added LastOid variable. This ought to take care of TODO item "Add a
function to return the last inserted oid, for use in psql scripts"
(under CLIENTS)
E.g.,
insert into foo values(...);
insert into bar values(..., :LastOid);
\echo $LastOid
* \d command shows constraints, rules, and triggers defined on the table
(in addition to indices)
* Various fixes, optimizations, corrections
* Documentation update as well
Note: This now requires snprintf(), which, if necessary, is taken from
src/backend/port. This is certainly a little weird, but it should
suffice
until a source tree cleanup is done.
Enjoy.
--
Peter Eisentraut Sernanders väg 10:115
1999-11-26 05:24:17 +01:00
2000-04-12 19:17:23 +02:00
if ( query = = NULL | | ! pset . db | | PQstatus ( pset . db ) ! = CONNECTION_OK )
return NULL ;
* Includes tab completion. It's not magic, but it's very cool. At any
rate
it's better than what used to be there.
* Does proper SQL "host variable" substitution as pointed out by Andreas
Zeugwetter (thanks): select * from :foo; Also some changes in how ':'
and ';' are treated (escape with \ to send to backend). This does
_not_
affect the '::' cast operator, but perhaps others that contain : or ;
(but there are none right now).
* To show description with a <something> listing, append '?' to command
name, e.g., \df?. This seemed to be the convenient and logical
solution.
Or append a '+' to see more useless information, e.g., \df+.
* Fixed fflush()'ing bug pointed out by Jan during the regression test
discussion.
* Added LastOid variable. This ought to take care of TODO item "Add a
function to return the last inserted oid, for use in psql scripts"
(under CLIENTS)
E.g.,
insert into foo values(...);
insert into bar values(..., :LastOid);
\echo $LastOid
* \d command shows constraints, rules, and triggers defined on the table
(in addition to indices)
* Various fixes, optimizations, corrections
* Documentation update as well
Note: This now requires snprintf(), which, if necessary, is taken from
src/backend/port. This is certainly a little weird, but it should
suffice
until a source tree cleanup is done.
Enjoy.
--
Peter Eisentraut Sernanders väg 10:115
1999-11-26 05:24:17 +01:00
# ifdef USE_ASSERT_CHECKING
2000-04-12 19:17:23 +02:00
assert ( query [ strlen ( query ) - 1 ] ! = ' ; ' ) ;
* Includes tab completion. It's not magic, but it's very cool. At any
rate
it's better than what used to be there.
* Does proper SQL "host variable" substitution as pointed out by Andreas
Zeugwetter (thanks): select * from :foo; Also some changes in how ':'
and ';' are treated (escape with \ to send to backend). This does
_not_
affect the '::' cast operator, but perhaps others that contain : or ;
(but there are none right now).
* To show description with a <something> listing, append '?' to command
name, e.g., \df?. This seemed to be the convenient and logical
solution.
Or append a '+' to see more useless information, e.g., \df+.
* Fixed fflush()'ing bug pointed out by Jan during the regression test
discussion.
* Added LastOid variable. This ought to take care of TODO item "Add a
function to return the last inserted oid, for use in psql scripts"
(under CLIENTS)
E.g.,
insert into foo values(...);
insert into bar values(..., :LastOid);
\echo $LastOid
* \d command shows constraints, rules, and triggers defined on the table
(in addition to indices)
* Various fixes, optimizations, corrections
* Documentation update as well
Note: This now requires snprintf(), which, if necessary, is taken from
src/backend/port. This is certainly a little weird, but it should
suffice
until a source tree cleanup is done.
Enjoy.
--
Peter Eisentraut Sernanders väg 10:115
1999-11-26 05:24:17 +01:00
# endif
2000-04-12 19:17:23 +02:00
if ( snprintf ( query_buffer , BUF_SIZE , " %s LIMIT %d; " , query , completion_max_records ) = = - 1 )
{
ERROR_QUERY_TOO_LONG ;
return NULL ;
}
* Includes tab completion. It's not magic, but it's very cool. At any
rate
it's better than what used to be there.
* Does proper SQL "host variable" substitution as pointed out by Andreas
Zeugwetter (thanks): select * from :foo; Also some changes in how ':'
and ';' are treated (escape with \ to send to backend). This does
_not_
affect the '::' cast operator, but perhaps others that contain : or ;
(but there are none right now).
* To show description with a <something> listing, append '?' to command
name, e.g., \df?. This seemed to be the convenient and logical
solution.
Or append a '+' to see more useless information, e.g., \df+.
* Fixed fflush()'ing bug pointed out by Jan during the regression test
discussion.
* Added LastOid variable. This ought to take care of TODO item "Add a
function to return the last inserted oid, for use in psql scripts"
(under CLIENTS)
E.g.,
insert into foo values(...);
insert into bar values(..., :LastOid);
\echo $LastOid
* \d command shows constraints, rules, and triggers defined on the table
(in addition to indices)
* Various fixes, optimizations, corrections
* Documentation update as well
Note: This now requires snprintf(), which, if necessary, is taken from
src/backend/port. This is certainly a little weird, but it should
suffice
until a source tree cleanup is done.
Enjoy.
--
Peter Eisentraut Sernanders väg 10:115
1999-11-26 05:24:17 +01:00
2000-04-12 19:17:23 +02:00
result = PQexec ( pset . db , query ) ;
* Includes tab completion. It's not magic, but it's very cool. At any
rate
it's better than what used to be there.
* Does proper SQL "host variable" substitution as pointed out by Andreas
Zeugwetter (thanks): select * from :foo; Also some changes in how ':'
and ';' are treated (escape with \ to send to backend). This does
_not_
affect the '::' cast operator, but perhaps others that contain : or ;
(but there are none right now).
* To show description with a <something> listing, append '?' to command
name, e.g., \df?. This seemed to be the convenient and logical
solution.
Or append a '+' to see more useless information, e.g., \df+.
* Fixed fflush()'ing bug pointed out by Jan during the regression test
discussion.
* Added LastOid variable. This ought to take care of TODO item "Add a
function to return the last inserted oid, for use in psql scripts"
(under CLIENTS)
E.g.,
insert into foo values(...);
insert into bar values(..., :LastOid);
\echo $LastOid
* \d command shows constraints, rules, and triggers defined on the table
(in addition to indices)
* Various fixes, optimizations, corrections
* Documentation update as well
Note: This now requires snprintf(), which, if necessary, is taken from
src/backend/port. This is certainly a little weird, but it should
suffice
until a source tree cleanup is done.
Enjoy.
--
Peter Eisentraut Sernanders väg 10:115
1999-11-26 05:24:17 +01:00
2000-04-12 19:17:23 +02:00
if ( result ! = NULL & & PQresultStatus ( result ) ! = PGRES_TUPLES_OK )
{
2000-01-19 00:30:24 +01:00
#if 0
2000-04-12 19:17:23 +02:00
psql_error ( " tab completion: %s failed - %s \n " ,
query , PQresStatus ( PQresultStatus ( result ) ) ) ;
2000-01-12 20:36:36 +01:00
# endif
2000-04-12 19:17:23 +02:00
PQclear ( result ) ;
result = NULL ;
}
return result ;
* Includes tab completion. It's not magic, but it's very cool. At any
rate
it's better than what used to be there.
* Does proper SQL "host variable" substitution as pointed out by Andreas
Zeugwetter (thanks): select * from :foo; Also some changes in how ':'
and ';' are treated (escape with \ to send to backend). This does
_not_
affect the '::' cast operator, but perhaps others that contain : or ;
(but there are none right now).
* To show description with a <something> listing, append '?' to command
name, e.g., \df?. This seemed to be the convenient and logical
solution.
Or append a '+' to see more useless information, e.g., \df+.
* Fixed fflush()'ing bug pointed out by Jan during the regression test
discussion.
* Added LastOid variable. This ought to take care of TODO item "Add a
function to return the last inserted oid, for use in psql scripts"
(under CLIENTS)
E.g.,
insert into foo values(...);
insert into bar values(..., :LastOid);
\echo $LastOid
* \d command shows constraints, rules, and triggers defined on the table
(in addition to indices)
* Various fixes, optimizations, corrections
* Documentation update as well
Note: This now requires snprintf(), which, if necessary, is taken from
src/backend/port. This is certainly a little weird, but it should
suffice
until a source tree cleanup is done.
Enjoy.
--
Peter Eisentraut Sernanders väg 10:115
1999-11-26 05:24:17 +01:00
}
/* Return the word (space delimited) before point. Set skip > 0 to skip that
many words ; e . g . skip = 1 finds the word before the previous one .
*/
2000-04-21 05:01:54 +02:00
static char *
2000-04-12 19:17:23 +02:00
previous_word ( int point , int skip )
{
int i ,
start = 0 ,
2002-07-30 18:35:05 +02:00
end = - 1 ,
2002-09-04 22:31:48 +02:00
inquotes = 0 ;
2000-04-12 19:17:23 +02:00
char * s ;
while ( skip - - > = 0 )
{
/* first we look for a space before the current word */
for ( i = point ; i > = 0 ; i - - )
if ( rl_line_buffer [ i ] = = ' ' )
break ;
/* now find the first non-space which then constitutes the end */
for ( ; i > = 0 ; i - - )
if ( rl_line_buffer [ i ] ! = ' ' )
{
end = i ;
break ;
}
/*
* If no end found we return null , because there is no word before
* the point
*/
if ( end = = - 1 )
return NULL ;
/*
* Otherwise we now look for the start . The start is either the
* last character before any space going backwards from the end ,
* or it ' s simply character 0
*/
2002-09-04 22:31:48 +02:00
for ( start = end ; start > 0 ; start - - )
{
if ( rl_line_buffer [ start ] = = ' " ' )
inquotes = ! inquotes ;
if ( ( rl_line_buffer [ start - 1 ] = = ' ' ) & & inquotes = = 0 )
break ;
2002-07-30 18:35:05 +02:00
}
2000-04-12 19:17:23 +02:00
point = start ;
}
/* make a copy */
s = ( char * ) malloc ( end - start + 2 ) ;
if ( ! s )
{
psql_error ( " out of memory \n " ) ;
if ( ! pset . cur_cmd_interactive )
exit ( EXIT_FAILURE ) ;
else
return NULL ;
}
strncpy ( s , & rl_line_buffer [ start ] , end - start + 1 ) ;
s [ end - start + 1 ] = ' \0 ' ;
return s ;
* Includes tab completion. It's not magic, but it's very cool. At any
rate
it's better than what used to be there.
* Does proper SQL "host variable" substitution as pointed out by Andreas
Zeugwetter (thanks): select * from :foo; Also some changes in how ':'
and ';' are treated (escape with \ to send to backend). This does
_not_
affect the '::' cast operator, but perhaps others that contain : or ;
(but there are none right now).
* To show description with a <something> listing, append '?' to command
name, e.g., \df?. This seemed to be the convenient and logical
solution.
Or append a '+' to see more useless information, e.g., \df+.
* Fixed fflush()'ing bug pointed out by Jan during the regression test
discussion.
* Added LastOid variable. This ought to take care of TODO item "Add a
function to return the last inserted oid, for use in psql scripts"
(under CLIENTS)
E.g.,
insert into foo values(...);
insert into bar values(..., :LastOid);
\echo $LastOid
* \d command shows constraints, rules, and triggers defined on the table
(in addition to indices)
* Various fixes, optimizations, corrections
* Documentation update as well
Note: This now requires snprintf(), which, if necessary, is taken from
src/backend/port. This is certainly a little weird, but it should
suffice
until a source tree cleanup is done.
Enjoy.
--
Peter Eisentraut Sernanders väg 10:115
1999-11-26 05:24:17 +01:00
}
2000-01-12 20:36:36 +01:00
2000-01-19 00:30:24 +01:00
#if 0
2000-01-12 20:36:36 +01:00
2000-01-19 00:30:24 +01:00
/*
* Surround a string with single quotes . This works for both SQL and
* psql internal . Currently disable because it is reported not to
* cooperate with certain versions of readline .
*/
2000-04-12 19:17:23 +02:00
char *
quote_file_name ( char * text , int match_type , char * quote_pointer )
* Includes tab completion. It's not magic, but it's very cool. At any
rate
it's better than what used to be there.
* Does proper SQL "host variable" substitution as pointed out by Andreas
Zeugwetter (thanks): select * from :foo; Also some changes in how ':'
and ';' are treated (escape with \ to send to backend). This does
_not_
affect the '::' cast operator, but perhaps others that contain : or ;
(but there are none right now).
* To show description with a <something> listing, append '?' to command
name, e.g., \df?. This seemed to be the convenient and logical
solution.
Or append a '+' to see more useless information, e.g., \df+.
* Fixed fflush()'ing bug pointed out by Jan during the regression test
discussion.
* Added LastOid variable. This ought to take care of TODO item "Add a
function to return the last inserted oid, for use in psql scripts"
(under CLIENTS)
E.g.,
insert into foo values(...);
insert into bar values(..., :LastOid);
\echo $LastOid
* \d command shows constraints, rules, and triggers defined on the table
(in addition to indices)
* Various fixes, optimizations, corrections
* Documentation update as well
Note: This now requires snprintf(), which, if necessary, is taken from
src/backend/port. This is certainly a little weird, but it should
suffice
until a source tree cleanup is done.
Enjoy.
--
Peter Eisentraut Sernanders väg 10:115
1999-11-26 05:24:17 +01:00
{
2000-04-12 19:17:23 +02:00
char * s ;
size_t length ;
( void ) quote_pointer ; /* not used */
length = strlen ( text ) + ( match_type = = SINGLE_MATCH ? 3 : 2 ) ;
s = malloc ( length ) ;
s [ 0 ] = ' \' ' ;
strcpy ( s + 1 , text ) ;
if ( match_type = = SINGLE_MATCH )
s [ length - 2 ] = ' \' ' ;
s [ length - 1 ] = ' \0 ' ;
return s ;
* Includes tab completion. It's not magic, but it's very cool. At any
rate
it's better than what used to be there.
* Does proper SQL "host variable" substitution as pointed out by Andreas
Zeugwetter (thanks): select * from :foo; Also some changes in how ':'
and ';' are treated (escape with \ to send to backend). This does
_not_
affect the '::' cast operator, but perhaps others that contain : or ;
(but there are none right now).
* To show description with a <something> listing, append '?' to command
name, e.g., \df?. This seemed to be the convenient and logical
solution.
Or append a '+' to see more useless information, e.g., \df+.
* Fixed fflush()'ing bug pointed out by Jan during the regression test
discussion.
* Added LastOid variable. This ought to take care of TODO item "Add a
function to return the last inserted oid, for use in psql scripts"
(under CLIENTS)
E.g.,
insert into foo values(...);
insert into bar values(..., :LastOid);
\echo $LastOid
* \d command shows constraints, rules, and triggers defined on the table
(in addition to indices)
* Various fixes, optimizations, corrections
* Documentation update as well
Note: This now requires snprintf(), which, if necessary, is taken from
src/backend/port. This is certainly a little weird, but it should
suffice
until a source tree cleanup is done.
Enjoy.
--
Peter Eisentraut Sernanders väg 10:115
1999-11-26 05:24:17 +01:00
}
2000-01-12 20:36:36 +01:00
2000-04-12 19:17:23 +02:00
static char *
dequote_file_name ( char * text , char quote_char )
* Includes tab completion. It's not magic, but it's very cool. At any
rate
it's better than what used to be there.
* Does proper SQL "host variable" substitution as pointed out by Andreas
Zeugwetter (thanks): select * from :foo; Also some changes in how ':'
and ';' are treated (escape with \ to send to backend). This does
_not_
affect the '::' cast operator, but perhaps others that contain : or ;
(but there are none right now).
* To show description with a <something> listing, append '?' to command
name, e.g., \df?. This seemed to be the convenient and logical
solution.
Or append a '+' to see more useless information, e.g., \df+.
* Fixed fflush()'ing bug pointed out by Jan during the regression test
discussion.
* Added LastOid variable. This ought to take care of TODO item "Add a
function to return the last inserted oid, for use in psql scripts"
(under CLIENTS)
E.g.,
insert into foo values(...);
insert into bar values(..., :LastOid);
\echo $LastOid
* \d command shows constraints, rules, and triggers defined on the table
(in addition to indices)
* Various fixes, optimizations, corrections
* Documentation update as well
Note: This now requires snprintf(), which, if necessary, is taken from
src/backend/port. This is certainly a little weird, but it should
suffice
until a source tree cleanup is done.
Enjoy.
--
Peter Eisentraut Sernanders väg 10:115
1999-11-26 05:24:17 +01:00
{
2000-04-12 19:17:23 +02:00
char * s ;
size_t length ;
* Includes tab completion. It's not magic, but it's very cool. At any
rate
it's better than what used to be there.
* Does proper SQL "host variable" substitution as pointed out by Andreas
Zeugwetter (thanks): select * from :foo; Also some changes in how ':'
and ';' are treated (escape with \ to send to backend). This does
_not_
affect the '::' cast operator, but perhaps others that contain : or ;
(but there are none right now).
* To show description with a <something> listing, append '?' to command
name, e.g., \df?. This seemed to be the convenient and logical
solution.
Or append a '+' to see more useless information, e.g., \df+.
* Fixed fflush()'ing bug pointed out by Jan during the regression test
discussion.
* Added LastOid variable. This ought to take care of TODO item "Add a
function to return the last inserted oid, for use in psql scripts"
(under CLIENTS)
E.g.,
insert into foo values(...);
insert into bar values(..., :LastOid);
\echo $LastOid
* \d command shows constraints, rules, and triggers defined on the table
(in addition to indices)
* Various fixes, optimizations, corrections
* Documentation update as well
Note: This now requires snprintf(), which, if necessary, is taken from
src/backend/port. This is certainly a little weird, but it should
suffice
until a source tree cleanup is done.
Enjoy.
--
Peter Eisentraut Sernanders väg 10:115
1999-11-26 05:24:17 +01:00
2000-04-12 19:17:23 +02:00
if ( ! quote_char )
return xstrdup ( text ) ;
* Includes tab completion. It's not magic, but it's very cool. At any
rate
it's better than what used to be there.
* Does proper SQL "host variable" substitution as pointed out by Andreas
Zeugwetter (thanks): select * from :foo; Also some changes in how ':'
and ';' are treated (escape with \ to send to backend). This does
_not_
affect the '::' cast operator, but perhaps others that contain : or ;
(but there are none right now).
* To show description with a <something> listing, append '?' to command
name, e.g., \df?. This seemed to be the convenient and logical
solution.
Or append a '+' to see more useless information, e.g., \df+.
* Fixed fflush()'ing bug pointed out by Jan during the regression test
discussion.
* Added LastOid variable. This ought to take care of TODO item "Add a
function to return the last inserted oid, for use in psql scripts"
(under CLIENTS)
E.g.,
insert into foo values(...);
insert into bar values(..., :LastOid);
\echo $LastOid
* \d command shows constraints, rules, and triggers defined on the table
(in addition to indices)
* Various fixes, optimizations, corrections
* Documentation update as well
Note: This now requires snprintf(), which, if necessary, is taken from
src/backend/port. This is certainly a little weird, but it should
suffice
until a source tree cleanup is done.
Enjoy.
--
Peter Eisentraut Sernanders väg 10:115
1999-11-26 05:24:17 +01:00
2000-04-12 19:17:23 +02:00
length = strlen ( text ) ;
s = malloc ( length - 2 + 1 ) ;
strncpy ( s , text + 1 , length - 2 ) ;
s [ length ] = ' \0 ' ;
* Includes tab completion. It's not magic, but it's very cool. At any
rate
it's better than what used to be there.
* Does proper SQL "host variable" substitution as pointed out by Andreas
Zeugwetter (thanks): select * from :foo; Also some changes in how ':'
and ';' are treated (escape with \ to send to backend). This does
_not_
affect the '::' cast operator, but perhaps others that contain : or ;
(but there are none right now).
* To show description with a <something> listing, append '?' to command
name, e.g., \df?. This seemed to be the convenient and logical
solution.
Or append a '+' to see more useless information, e.g., \df+.
* Fixed fflush()'ing bug pointed out by Jan during the regression test
discussion.
* Added LastOid variable. This ought to take care of TODO item "Add a
function to return the last inserted oid, for use in psql scripts"
(under CLIENTS)
E.g.,
insert into foo values(...);
insert into bar values(..., :LastOid);
\echo $LastOid
* \d command shows constraints, rules, and triggers defined on the table
(in addition to indices)
* Various fixes, optimizations, corrections
* Documentation update as well
Note: This now requires snprintf(), which, if necessary, is taken from
src/backend/port. This is certainly a little weird, but it should
suffice
until a source tree cleanup is done.
Enjoy.
--
Peter Eisentraut Sernanders väg 10:115
1999-11-26 05:24:17 +01:00
2000-04-12 19:17:23 +02:00
return s ;
* Includes tab completion. It's not magic, but it's very cool. At any
rate
it's better than what used to be there.
* Does proper SQL "host variable" substitution as pointed out by Andreas
Zeugwetter (thanks): select * from :foo; Also some changes in how ':'
and ';' are treated (escape with \ to send to backend). This does
_not_
affect the '::' cast operator, but perhaps others that contain : or ;
(but there are none right now).
* To show description with a <something> listing, append '?' to command
name, e.g., \df?. This seemed to be the convenient and logical
solution.
Or append a '+' to see more useless information, e.g., \df+.
* Fixed fflush()'ing bug pointed out by Jan during the regression test
discussion.
* Added LastOid variable. This ought to take care of TODO item "Add a
function to return the last inserted oid, for use in psql scripts"
(under CLIENTS)
E.g.,
insert into foo values(...);
insert into bar values(..., :LastOid);
\echo $LastOid
* \d command shows constraints, rules, and triggers defined on the table
(in addition to indices)
* Various fixes, optimizations, corrections
* Documentation update as well
Note: This now requires snprintf(), which, if necessary, is taken from
src/backend/port. This is certainly a little weird, but it should
suffice
until a source tree cleanup is done.
Enjoy.
--
Peter Eisentraut Sernanders väg 10:115
1999-11-26 05:24:17 +01:00
}
2001-11-05 18:46:40 +01:00
# endif /* 0 */
2001-10-28 07:26:15 +01:00
2001-11-05 18:46:40 +01:00
# endif /* USE_READLINE */