~ubuntu-branches/ubuntu/trusty/postgresql-9.3/trusty-proposed

« back to all changes in this revision

Viewing changes to src/backend/parser/parse_func.c

  • Committer: Package Import Robot
  • Author(s): Martin Pitt
  • Date: 2014-07-24 16:13:59 UTC
  • mfrom: (1.1.8)
  • Revision ID: package-import@ubuntu.com-20140724161359-uk325qfv03euxuuh
Tags: 9.3.5-0ubuntu0.14.04.1
* New upstream bug fix release: (LP: #1348176)
  - pg_upgrade: Users who upgraded to version 9.3 using pg_upgrade may have
    an issue with transaction information which causes VACUUM to eventually
    fail. These users should run the script provided in the release notes to
    determine if their installation is affected, and then take the remedy
    steps outlined there.
  - Various data integrity and other bug fixes.
  - Secure Unix-domain sockets of temporary postmasters started during make
    check.
    Any local user able to access the socket file could connect as the
    server's bootstrap superuser, then proceed to execute arbitrary code as
    the operating-system user running the test, as we previously noted in
    CVE-2014-0067. This change defends against that risk by placing the
    server's socket in a temporary, mode 0700 subdirectory of /tmp.
  - See release notes for details:
    http://www.postgresql.org/about/news/1534/
* Remove pg_regress patches to support --host=/path, obsolete with above
  upstream changes and not applicable any more.
* Drop tcl8.6 patch, applied upstream.
* Add missing logrotate test dependency.

Show diffs side-by-side

added added

removed removed

Lines of Context:
83
83
 
84
84
        /*
85
85
         * Most of the rest of the parser just assumes that functions do not have
86
 
         * more than FUNC_MAX_ARGS parameters.  We have to test here to protect
 
86
         * more than FUNC_MAX_ARGS parameters.  We have to test here to protect
87
87
         * against array overruns, etc.  Of course, this may not be a function,
88
88
         * but the test doesn't hurt.
89
89
         */
100
100
         * Extract arg type info in preparation for function lookup.
101
101
         *
102
102
         * If any arguments are Param markers of type VOID, we discard them from
103
 
         * the parameter list.  This is a hack to allow the JDBC driver to not
 
103
         * the parameter list.  This is a hack to allow the JDBC driver to not
104
104
         * have to distinguish "input" and "output" parameter symbols while
105
105
         * parsing function-call constructs.  We can't use foreach() because we
106
106
         * may modify the list ...
310
310
         * If there are default arguments, we have to include their types in
311
311
         * actual_arg_types for the purpose of checking generic type consistency.
312
312
         * However, we do NOT put them into the generated parse node, because
313
 
         * their actual values might change before the query gets run.  The
 
313
         * their actual values might change before the query gets run.  The
314
314
         * planner has to insert the up-to-date values at plan time.
315
315
         */
316
316
        nargsplusdefs = nargs;
374
374
                newa->location = exprLocation((Node *) vargs);
375
375
 
376
376
                fargs = lappend(fargs, newa);
 
377
 
 
378
                /* We could not have had VARIADIC marking before ... */
 
379
                Assert(!func_variadic);
 
380
                /* ... but now, it's a VARIADIC call */
 
381
                func_variadic = true;
377
382
        }
378
383
 
379
384
        /* build the appropriate output structure */
407
412
 
408
413
                /*
409
414
                 * Reject attempt to call a parameterless aggregate without (*)
410
 
                 * syntax.      This is mere pedantry but some folks insisted ...
 
415
                 * syntax.  This is mere pedantry but some folks insisted ...
411
416
                 */
412
417
                if (fargs == NIL && !agg_star)
413
418
                        ereport(ERROR,
473
478
 
474
479
                /*
475
480
                 * Reject attempt to call a parameterless aggregate without (*)
476
 
                 * syntax.      This is mere pedantry but some folks insisted ...
 
481
                 * syntax.  This is mere pedantry but some folks insisted ...
477
482
                 */
478
483
                if (wfunc->winagg && fargs == NIL && !agg_star)
479
484
                        ereport(ERROR,
642
647
         * matches" in the exact-match heuristic; it also makes it possible to do
643
648
         * something useful with the type-category heuristics. Note that this
644
649
         * makes it difficult, but not impossible, to use functions declared to
645
 
         * take a domain as an input datatype.  Such a function will be selected
 
650
         * take a domain as an input datatype.  Such a function will be selected
646
651
         * over the base-type function only if it is an exact match at all
647
652
         * argument positions, and so was already chosen by our caller.
648
653
         *
766
771
 
767
772
        /*
768
773
         * The next step examines each unknown argument position to see if we can
769
 
         * determine a "type category" for it.  If any candidate has an input
 
774
         * determine a "type category" for it.  If any candidate has an input
770
775
         * datatype of STRING category, use STRING category (this bias towards
771
776
         * STRING is appropriate since unknown-type literals look like strings).
772
777
         * Otherwise, if all the candidates agree on the type category of this
777
782
         * the candidates takes a preferred datatype within the category.
778
783
         *
779
784
         * Having completed this examination, remove candidates that accept the
780
 
         * wrong category at any unknown position.      Also, if at least one
 
785
         * wrong category at any unknown position.  Also, if at least one
781
786
         * candidate accepted a preferred type at a position, remove candidates
782
787
         * that accept non-preferred types.  If just one candidate remains, return
783
788
         * that one.  However, if this rule turns out to reject all candidates,
906
911
         * type, and see if that gives us a unique match.  If so, use that match.
907
912
         *
908
913
         * NOTE: for a binary operator with one unknown and one non-unknown input,
909
 
         * we already tried this heuristic in binary_oper_exact().      However, that
 
914
         * we already tried this heuristic in binary_oper_exact().  However, that
910
915
         * code only finds exact matches, whereas here we will handle matches that
911
916
         * involve coercion, polymorphic type resolution, etc.
912
917
         */
1072
1077
                 *
1073
1078
                 * NB: it's important that this code does not exceed what coerce_type
1074
1079
                 * can do, because the caller will try to apply coerce_type if we
1075
 
                 * return FUNCDETAIL_COERCION.  If we return that result for something
 
1080
                 * return FUNCDETAIL_COERCION.  If we return that result for something
1076
1081
                 * coerce_type can't handle, we'll cause infinite recursion between
1077
1082
                 * this module and coerce_type!
1078
1083
                 */
1248
1253
                        {
1249
1254
                                /*
1250
1255
                                 * This is a bit tricky in named notation, since the supplied
1251
 
                                 * arguments could replace any subset of the defaults.  We
 
1256
                                 * arguments could replace any subset of the defaults.  We
1252
1257
                                 * work by making a bitmapset of the argnumbers of defaulted
1253
1258
                                 * arguments, then scanning the defaults list and selecting
1254
1259
                                 * the needed items.  (This assumes that defaulted arguments
1398
1403
 * ParseComplexProjection -
1399
1404
 *        handles function calls with a single argument that is of complex type.
1400
1405
 *        If the function call is actually a column projection, return a suitably
1401
 
 *        transformed expression tree.  If not, return NULL.
 
1406
 *        transformed expression tree.  If not, return NULL.
1402
1407
 */
1403
1408
static Node *
1404
1409
ParseComplexProjection(ParseState *pstate, char *funcname, Node *first_arg,
1472
1477
 *              The result is something like "foo(integer)".
1473
1478
 *
1474
1479
 * If argnames isn't NIL, it is a list of C strings representing the actual
1475
 
 * arg names for the last N arguments.  This must be considered part of the
 
1480
 * arg names for the last N arguments.  This must be considered part of the
1476
1481
 * function signature too, when dealing with named-notation function calls.
1477
1482
 *
1478
1483
 * This is typically used in the construction of function-not-found error