Project

General

Profile

« Previous | Next » 

Revision 7288

schemas/functions.sql: _max(), _min(): Use PostgreSQL built-in functions GREATEST, LEAST instead of a query with aggregating functions

View differences:

schemas/functions.sql
170 170
CREATE FUNCTION _max("0" anyelement DEFAULT NULL::unknown, "1" anyelement DEFAULT NULL::unknown, "2" anyelement DEFAULT NULL::unknown, "3" anyelement DEFAULT NULL::unknown, "4" anyelement DEFAULT NULL::unknown, "5" anyelement DEFAULT NULL::unknown, "6" anyelement DEFAULT NULL::unknown, "7" anyelement DEFAULT NULL::unknown, "8" anyelement DEFAULT NULL::unknown, "9" anyelement DEFAULT NULL::unknown) RETURNS anyelement
171 171
    LANGUAGE sql IMMUTABLE
172 172
    AS $_$
173
SELECT max(value)
174
FROM
175
(VALUES
176
      ($1)
177
    , ($2)
178
    , ($3)
179
    , ($4)
180
    , ($5)
181
    , ($6)
182
    , ($7)
183
    , ($8)
184
    , ($9)
185
    , ($10)
173
SELECT GREATEST(
174
      $1
175
    , $2
176
    , $3
177
    , $4
178
    , $5
179
    , $6
180
    , $7
181
    , $8
182
    , $9
183
    , $10
186 184
)
187
AS v (value)
188 185
$_$;
189 186

  
190 187

  
......
284 281
CREATE FUNCTION _min("0" anyelement DEFAULT NULL::unknown, "1" anyelement DEFAULT NULL::unknown, "2" anyelement DEFAULT NULL::unknown, "3" anyelement DEFAULT NULL::unknown, "4" anyelement DEFAULT NULL::unknown, "5" anyelement DEFAULT NULL::unknown, "6" anyelement DEFAULT NULL::unknown, "7" anyelement DEFAULT NULL::unknown, "8" anyelement DEFAULT NULL::unknown, "9" anyelement DEFAULT NULL::unknown) RETURNS anyelement
285 282
    LANGUAGE sql IMMUTABLE
286 283
    AS $_$
287
SELECT min(value)
288
FROM
289
(VALUES
290
      ($1)
291
    , ($2)
292
    , ($3)
293
    , ($4)
294
    , ($5)
295
    , ($6)
296
    , ($7)
297
    , ($8)
298
    , ($9)
299
    , ($10)
284
SELECT LEAST(
285
      $1
286
    , $2
287
    , $3
288
    , $4
289
    , $5
290
    , $6
291
    , $7
292
    , $8
293
    , $9
294
    , $10
300 295
)
301
AS v (value)
302 296
$_$;
303 297

  
304 298

  

Also available in: Unified diff