fastpath code neglected to check whether user has privileges to call the
authorTom Lane <[email protected]>
Wed, 1 Jan 2003 21:57:18 +0000 (21:57 +0000)
committerTom Lane <[email protected]>
Wed, 1 Jan 2003 21:57:18 +0000 (21:57 +0000)
target function.  Also, move SetQuerySnapshot() call to avoid assert
failure when a fastpath call is attempted in an aborted transaction.

src/backend/tcop/fastpath.c
src/backend/tcop/postgres.c

index b058672a0dc13d12828221680e7e950206ddd07e..758961b17e6c704bfecfc76acf1cca37e89dfa86 100644 (file)
 #include "libpq/libpq.h"
 #include "libpq/pqformat.h"
 #include "tcop/fastpath.h"
+#include "utils/acl.h"
 #include "utils/lsyscache.h"
 #include "utils/syscache.h"
+#include "utils/tqual.h"
 
 
 /* ----------------
@@ -221,6 +223,7 @@ HandleFunctionRequest(void)
        int                     argsize;
        int                     nargs;
        int                     tmp;
+       AclResult       aclresult;
        FunctionCallInfoData fcinfo;
        Datum           retval;
        int                     i;
@@ -337,6 +340,18 @@ HandleFunctionRequest(void)
                elog(ERROR, "current transaction is aborted, "
                         "queries ignored until end of transaction block");
 
+       /* Check permission to call function */
+       aclresult = pg_proc_aclcheck(fid, GetUserId(), ACL_EXECUTE);
+       if (aclresult != ACLCHECK_OK)
+               aclcheck_error(aclresult, get_func_name(fid));
+
+       /*
+        * Set up a query snapshot in case function needs one.  (It is not safe
+        * to do this if we are in transaction-abort state, so we have to postpone
+        * it till now.  Ugh.)
+        */
+       SetQuerySnapshot();
+
 #ifdef NO_FASTPATH
        /* force a NULL return */
        retval = (Datum) 0;
index ffdad848b508434eefa2dc19dc23b752edd882cb..88dbdf4f9f13d166a8d771c81f85a8e54ed223a7 100644 (file)
@@ -1781,7 +1781,7 @@ PostgresMain(int argc, char *argv[], const char *username)
        if (!IsUnderPostmaster)
        {
                puts("\nPOSTGRES backend interactive interface ");
-               puts("$Revision: 1.307 $ $Date: 2002/10/31 21:34:16 $\n");
+               puts("$Revision: 1.307.2.1 $ $Date: 2003/01/01 21:57:18 $\n");
        }
 
        /*
@@ -1965,9 +1965,6 @@ PostgresMain(int argc, char *argv[], const char *username)
                                /* start an xact for this function invocation */
                                start_xact_command();
 
-                               /* assume it may need a snapshot */
-                               SetQuerySnapshot();
-
                                if (HandleFunctionRequest() == EOF)
                                {
                                        /* lost frontend connection during F message input */