postgresql/contrib/tablefunc/tablefunc.sql.in
Bruce Momjian 45e2544584 As discussed on several occasions previously, the new anonymous
composite type capability makes it possible to create a system view
based on a table function in a way that is hopefully palatable to
everyone. The attached patch takes advantage of this, moving
show_all_settings() from contrib/tablefunc into the backend (renamed
all_settings(). It is defined as a builtin returning type RECORD. During
initdb a system view is created to expose the same information presently
available through SHOW ALL. For example:

test=# select * from pg_settings where name like '%debug%';
          name          | setting
-----------------------+---------
  debug_assertions      | on
  debug_pretty_print    | off
  debug_print_parse     | off
  debug_print_plan      | off
  debug_print_query     | off
  debug_print_rewritten | off
  wal_debug             | 0
(7 rows)


Additionally during initdb two rules are created which make it possible
to change settings by updating the system view -- a "virtual table" as
Tom put it. Here's an example:

Joe Conway
2002-08-15 02:51:27 +00:00

40 lines
1.2 KiB
MySQL

CREATE OR REPLACE FUNCTION normal_rand(int4, float8, float8, int4)
RETURNS setof float8
AS 'MODULE_PATHNAME','normal_rand' LANGUAGE 'c' VOLATILE STRICT;
CREATE VIEW tablefunc_crosstab_2 AS
SELECT
''::TEXT AS row_name,
''::TEXT AS category_1,
''::TEXT AS category_2;
CREATE VIEW tablefunc_crosstab_3 AS
SELECT
''::TEXT AS row_name,
''::TEXT AS category_1,
''::TEXT AS category_2,
''::TEXT AS category_3;
CREATE VIEW tablefunc_crosstab_4 AS
SELECT
''::TEXT AS row_name,
''::TEXT AS category_1,
''::TEXT AS category_2,
''::TEXT AS category_3,
''::TEXT AS category_4;
CREATE OR REPLACE FUNCTION crosstab2(text)
RETURNS setof tablefunc_crosstab_2
AS 'MODULE_PATHNAME','crosstab' LANGUAGE 'c' STABLE STRICT;
CREATE OR REPLACE FUNCTION crosstab3(text)
RETURNS setof tablefunc_crosstab_3
AS 'MODULE_PATHNAME','crosstab' LANGUAGE 'c' STABLE STRICT;
CREATE OR REPLACE FUNCTION crosstab4(text)
RETURNS setof tablefunc_crosstab_4
AS 'MODULE_PATHNAME','crosstab' LANGUAGE 'c' STABLE STRICT;
CREATE OR REPLACE FUNCTION crosstab(text,int)
RETURNS setof record
AS 'MODULE_PATHNAME','crosstab' LANGUAGE 'c' STABLE STRICT;