@ -50,15 +50,17 @@
# include "settings.h"
# include "stringutils.h"
# ifdef HAVE_RL_FILENAME_COMPLETION_FUNCTION
# define filename_completion_function rl_filename_completion_function
# else
/* missing in some header files */
extern char * filename_completion_function ( ) ;
/*
* Ancient versions of libedit provide filename_completion_function ( )
* instead of rl_filename_completion_function ( ) . Likewise for
* [ rl_ ] completion_matches ( ) .
*/
# ifndef HAVE_RL_FILENAME_COMPLETION_FUNCTION
# define rl_filename_completion_function filename_completion_function
# endif
# ifdef HAVE_RL_COMPLETION_MATCHES
# define completion_matches rl_ completion_matches
# ifn def HAVE_RL_COMPLETION_MATCHES
# define rl_ completion_matches completion_matches
# endif
/* word break characters */
@ -182,27 +184,27 @@ static bool completion_case_sensitive; /* completion is case sensitive */
# define COMPLETE_WITH_QUERY(query) \
do { \
completion_charp = query ; \
matches = completion_matches ( text , complete_from_query ) ; \
matches = rl_ completion_matches( text , complete_from_query ) ; \
} while ( 0 )
# define COMPLETE_WITH_VERSIONED_QUERY(query) \
do { \
completion_vquery = query ; \
matches = completion_matches ( text , complete_from_versioned_query ) ; \
matches = rl_ completion_matches( text , complete_from_versioned_query ) ; \
} while ( 0 )
# define COMPLETE_WITH_SCHEMA_QUERY(query, addon) \
do { \
completion_squery = & ( query ) ; \
completion_charp = addon ; \
matches = completion_matches ( text , complete_from_schema_query ) ; \
matches = rl_ completion_matches( text , complete_from_schema_query ) ; \
} while ( 0 )
# define COMPLETE_WITH_VERSIONED_SCHEMA_QUERY(query, addon) \
do { \
completion_squery = query ; \
completion_vquery = addon ; \
matches = completion_matches ( text , complete_from_versioned_schema_query ) ; \
matches = rl_ completion_matches( text , complete_from_versioned_schema_query ) ; \
} while ( 0 )
/*
@ -213,14 +215,14 @@ do { \
do { \
completion_case_sensitive = ( cs ) ; \
completion_charp = ( con ) ; \
matches = completion_matches ( text , complete_from_const ) ; \
matches = rl_ completion_matches( text , complete_from_const ) ; \
} while ( 0 )
# define COMPLETE_WITH_LIST_INT(cs, list) \
do { \
completion_case_sensitive = ( cs ) ; \
completion_charpp = ( list ) ; \
matches = completion_matches ( text , complete_from_list ) ; \
matches = rl_ completion_matches( text , complete_from_list ) ; \
} while ( 0 )
# define COMPLETE_WITH_LIST(list) COMPLETE_WITH_LIST_INT(false, list)
@ -260,7 +262,7 @@ do { \
completion_info_charp = _completion_table ; \
completion_info_charp2 = _completion_schema ; \
} \
matches = completion_matches ( text , complete_from_query ) ; \
matches = rl_ completion_matches( text , complete_from_query ) ; \
} while ( 0 )
# define COMPLETE_WITH_ENUM_VALUE(type) \
@ -285,7 +287,7 @@ do { \
completion_info_charp = _completion_type ; \
completion_info_charp2 = _completion_schema ; \
} \
matches = completion_matches ( text , complete_from_query ) ; \
matches = rl_ completion_matches( text , complete_from_query ) ; \
} while ( 0 )
# define COMPLETE_WITH_FUNCTION_ARG(function) \
@ -310,7 +312,7 @@ do { \
completion_info_charp = _completion_function ; \
completion_info_charp2 = _completion_schema ; \
} \
matches = completion_matches ( text , complete_from_query ) ; \
matches = rl_ completion_matches( text , complete_from_query ) ; \
} while ( 0 )
/*
@ -1335,7 +1337,7 @@ ends_with(const char *s, char c)
* According to readline spec this gets passed the text entered so far and its
* start and end positions in the readline buffer . The return value is some
* partially obscure list format that can be generated by readline ' s
* completion_matches ( ) function , so we don ' t have to worry about it .
* rl_ completion_matches( ) function , so we don ' t have to worry about it .
*/
static char * *
psql_completion ( const char * text , int start , int end )
@ -1488,7 +1490,7 @@ psql_completion(const char *text, int start, int end)
/* CREATE */
/* complete with something you can create */
else if ( TailMatches ( " CREATE " ) )
matches = completion_matches ( text , create_command_generator ) ;
matches = rl_ completion_matches( text , create_command_generator ) ;
/* complete with something you can create or replace */
else if ( TailMatches ( " CREATE " , " OR " , " REPLACE " ) )
@ -1498,7 +1500,7 @@ psql_completion(const char *text, int start, int end)
/* DROP, but not DROP embedded in other commands */
/* complete with something you can drop */
else if ( Matches ( " DROP " ) )
matches = completion_matches ( text , drop_command_generator ) ;
matches = rl_ completion_matches( text , drop_command_generator ) ;
/* ALTER */
@ -1509,7 +1511,7 @@ psql_completion(const char *text, int start, int end)
/* ALTER something */
else if ( Matches ( " ALTER " ) )
matches = completion_matches ( text , alter_command_generator ) ;
matches = rl_ completion_matches( text , alter_command_generator ) ;
/* ALTER TABLE,INDEX,MATERIALIZED VIEW ALL IN TABLESPACE xxx */
else if ( TailMatches ( " ALL " , " IN " , " TABLESPACE " , MatchAny ) )
COMPLETE_WITH ( " SET TABLESPACE " , " OWNED BY " ) ;
@ -2261,7 +2263,7 @@ psql_completion(const char *text, int start, int end)
Matches ( " COPY " , " BINARY " , MatchAny , " FROM|TO " ) )
{
completion_charp = " " ;
matches = completion_matches ( text , complete_from_files ) ;
matches = rl_ completion_matches( text , complete_from_files ) ;
}
/* Handle COPY [BINARY] <sth> FROM|TO filename */
@ -2483,7 +2485,11 @@ psql_completion(const char *text, int start, int end)
else if ( Matches ( " CREATE " , " RULE " , MatchAny , " AS " ) | |
Matches ( " CREATE " , " OR " , " REPLACE " , " RULE " , MatchAny , " AS " ) )
COMPLETE_WITH ( " ON " ) ;
/* Complete "CREATE [ OR REPLACE ] RULE <sth> AS ON" with SELECT|UPDATE|INSERT|DELETE */
/*
* Complete " CREATE [ OR REPLACE ] RULE <sth> AS ON " with
* SELECT | UPDATE | INSERT | DELETE
*/
else if ( Matches ( " CREATE " , " RULE " , MatchAny , " AS " , " ON " ) | |
Matches ( " CREATE " , " OR " , " REPLACE " , " RULE " , MatchAny , " AS " , " ON " ) )
COMPLETE_WITH ( " SELECT " , " UPDATE " , " INSERT " , " DELETE " ) ;
@ -3708,9 +3714,9 @@ psql_completion(const char *text, int start, int end)
else if ( TailMatchesCS ( " \\ h| \\ help " , MatchAny ) )
{
if ( TailMatches ( " DROP " ) )
matches = completion_matches ( text , drop_command_generator ) ;
matches = rl_ completion_matches( text , drop_command_generator ) ;
else if ( TailMatches ( " ALTER " ) )
matches = completion_matches ( text , alter_command_generator ) ;
matches = rl_ completion_matches( text , alter_command_generator ) ;
/*
* CREATE is recognized by tail match elsewhere , so doesn ' t need to be
@ -3809,7 +3815,7 @@ psql_completion(const char *text, int start, int end)
" \\ s| \\ w| \\ write| \\ lo_import " ) )
{
completion_charp = " \\ " ;
matches = completion_matches ( text , complete_from_files ) ;
matches = rl_ completion_matches( text , complete_from_files ) ;
}
/*
@ -4395,7 +4401,7 @@ complete_from_files(const char *text, int state)
}
}
unquoted_match = filename_completion_function ( unquoted_text , state ) ;
unquoted_match = rl_ filename_completion_function( unquoted_text , state ) ;
if ( unquoted_match )
{
/*