Project

General

Profile

« Previous | Next » 

Revision 11011

schemas/util.sql: added mk_subset_by_row_num_func(regclass), which uses a sort_col instead of a row_num column

View differences:

schemas/util.sql
1389 1389

  
1390 1390

  
1391 1391
--
1392
-- Name: mk_subset_by_row_num_func(regclass); Type: FUNCTION; Schema: util; Owner: -
1393
--
1394

  
1395
CREATE FUNCTION mk_subset_by_row_num_func(view_ regclass) RETURNS void
1396
    LANGUAGE plpgsql STRICT
1397
    AS $_$
1398
DECLARE
1399
	view_qual_name text = util.qual_name(view_);
1400
BEGIN
1401
	EXECUTE $$
1402
CREATE OR REPLACE FUNCTION $$||view_||$$(limit_ integer DEFAULT NULL::integer, offset_ integer DEFAULT NULL)
1403
  RETURNS SETOF $$||view_||$$ AS
1404
$BODY1$
1405
SELECT * FROM $$||view_qual_name||$$
1406
ORDER BY sort_col
1407
LIMIT $1 OFFSET $2
1408
$BODY1$
1409
  LANGUAGE sql STABLE
1410
  COST 100
1411
  ROWS 1000
1412
$$;
1413
	
1414
	PERFORM util.mk_subset_by_row_num_no_sort_func(view_);
1415
END;
1416
$_$;
1417

  
1418

  
1419
--
1392 1420
-- Name: mk_subset_by_row_num_func(regclass, text); Type: FUNCTION; Schema: util; Owner: -
1393 1421
--
1394 1422

  

Also available in: Unified diff