@ -62,8 +62,8 @@ static bool do_edit(const char *filename_arg, PQExpBuffer query_buf,
static bool do_connect ( char * dbname , char * user , char * host , char * port ) ;
static bool do_connect ( char * dbname , char * user , char * host , char * port ) ;
static bool do_shell ( const char * command ) ;
static bool do_shell ( const char * command ) ;
static bool do_watch ( PQExpBuffer query_buf , long sleep ) ;
static bool do_watch ( PQExpBuffer query_buf , long sleep ) ;
static bool lookup_function_oid ( PGconn * conn , const char * desc , Oid * foid ) ;
static bool lookup_function_oid ( const char * desc , Oid * foid ) ;
static bool get_create_function_cmd ( PGconn * conn , Oid oid , PQExpBuffer buf ) ;
static bool get_create_function_cmd ( Oid oid , PQExpBuffer buf ) ;
static int strip_lineno_from_funcdesc ( char * func ) ;
static int strip_lineno_from_funcdesc ( char * func ) ;
static void minimal_error_message ( PGresult * res ) ;
static void minimal_error_message ( PGresult * res ) ;
@ -611,12 +611,12 @@ exec_command(const char *cmd,
" AS $function$ \n "
" AS $function$ \n "
" \n $function$ \n " ) ;
" \n $function$ \n " ) ;
}
}
else if ( ! lookup_function_oid ( pset . db , func , & foid ) )
else if ( ! lookup_function_oid ( func , & foid ) )
{
{
/* error already reported */
/* error already reported */
status = PSQL_CMD_ERROR ;
status = PSQL_CMD_ERROR ;
}
}
else if ( ! get_create_function_cmd ( pset . db , foid , query_buf ) )
else if ( ! get_create_function_cmd ( foid , query_buf ) )
{
{
/* error already reported */
/* error already reported */
status = PSQL_CMD_ERROR ;
status = PSQL_CMD_ERROR ;
@ -1215,12 +1215,12 @@ exec_command(const char *cmd,
psql_error ( " function name is required \n " ) ;
psql_error ( " function name is required \n " ) ;
status = PSQL_CMD_ERROR ;
status = PSQL_CMD_ERROR ;
}
}
else if ( ! lookup_function_oid ( pset . db , func , & foid ) )
else if ( ! lookup_function_oid ( func , & foid ) )
{
{
/* error already reported */
/* error already reported */
status = PSQL_CMD_ERROR ;
status = PSQL_CMD_ERROR ;
}
}
else if ( ! get_create_function_cmd ( pset . db , foid , func_buf ) )
else if ( ! get_create_function_cmd ( foid , func_buf ) )
{
{
/* error already reported */
/* error already reported */
status = PSQL_CMD_ERROR ;
status = PSQL_CMD_ERROR ;
@ -2934,7 +2934,7 @@ do_watch(PQExpBuffer query_buf, long sleep)
* unfortunately it can be hard to tell the difference .
* unfortunately it can be hard to tell the difference .
*/
*/
static bool
static bool
lookup_function_oid ( PGconn * conn , const char * desc , Oid * foid )
lookup_function_oid ( const char * desc , Oid * foid )
{
{
bool result = true ;
bool result = true ;
PQExpBuffer query ;
PQExpBuffer query ;
@ -2942,11 +2942,11 @@ lookup_function_oid(PGconn *conn, const char *desc, Oid *foid)
query = createPQExpBuffer ( ) ;
query = createPQExpBuffer ( ) ;
appendPQExpBufferStr ( query , " SELECT " ) ;
appendPQExpBufferStr ( query , " SELECT " ) ;
appendStringLiteralConn ( query , desc , conn ) ;
appendStringLiteralConn ( query , desc , pset . db ) ;
appendPQExpBuffer ( query , " ::pg_catalog.%s::pg_catalog.oid " ,
appendPQExpBuffer ( query , " ::pg_catalog.%s::pg_catalog.oid " ,
strchr ( desc , ' ( ' ) ? " regprocedure " : " regproc " ) ;
strchr ( desc , ' ( ' ) ? " regprocedure " : " regproc " ) ;
res = PQexec ( conn , query - > data ) ;
res = PS QL exec ( query - > data ) ;
if ( PQresultStatus ( res ) = = PGRES_TUPLES_OK & & PQntuples ( res ) = = 1 )
if ( PQresultStatus ( res ) = = PGRES_TUPLES_OK & & PQntuples ( res ) = = 1 )
* foid = atooid ( PQgetvalue ( res , 0 , 0 ) ) ;
* foid = atooid ( PQgetvalue ( res , 0 , 0 ) ) ;
else
else
@ -2966,7 +2966,7 @@ lookup_function_oid(PGconn *conn, const char *desc, Oid *foid)
* function with the given OID . If successful , the result is stored in buf .
* function with the given OID . If successful , the result is stored in buf .
*/
*/
static bool
static bool
get_create_function_cmd ( PGconn * conn , Oid oid , PQExpBuffer buf )
get_create_function_cmd ( Oid oid , PQExpBuffer buf )
{
{
bool result = true ;
bool result = true ;
PQExpBuffer query ;
PQExpBuffer query ;
@ -2975,7 +2975,7 @@ get_create_function_cmd(PGconn *conn, Oid oid, PQExpBuffer buf)
query = createPQExpBuffer ( ) ;
query = createPQExpBuffer ( ) ;
printfPQExpBuffer ( query , " SELECT pg_catalog.pg_get_functiondef(%u) " , oid ) ;
printfPQExpBuffer ( query , " SELECT pg_catalog.pg_get_functiondef(%u) " , oid ) ;
res = PQexec ( conn , query - > data ) ;
res = PS QL exec ( query - > data ) ;
if ( PQresultStatus ( res ) = = PGRES_TUPLES_OK & & PQntuples ( res ) = = 1 )
if ( PQresultStatus ( res ) = = PGRES_TUPLES_OK & & PQntuples ( res ) = = 1 )
{
{
resetPQExpBuffer ( buf ) ;
resetPQExpBuffer ( buf ) ;