Skip to content

Commit 2116826

Browse files
committed
Simplify implementation of ts_debug() function --- use a join instead
of redundant sub-selects. initdb not forced, since this is just a cosmetic change, but the new code won't show up till you do one.
1 parent e4a52ec commit 2116826

File tree

1 file changed

+18
-30
lines changed

1 file changed

+18
-30
lines changed

src/backend/catalog/system_views.sql

Lines changed: 18 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
*
44
* Copyright (c) 1996-2007, PostgreSQL Global Development Group
55
*
6-
* $PostgreSQL: pgsql/src/backend/catalog/system_views.sql,v 1.40 2007/08/21 01:11:13 tgl Exp $
6+
* $PostgreSQL: pgsql/src/backend/catalog/system_views.sql,v 1.41 2007/08/25 17:47:44 tgl Exp $
77
*/
88

99
CREATE VIEW pg_roles AS
@@ -394,37 +394,19 @@ CREATE TYPE ts_debug AS (
394394
"Lexized token" text
395395
);
396396

397-
COMMENT ON TYPE ts_debug IS 'returned type from ts_debug() function';
397+
COMMENT ON TYPE ts_debug IS 'type returned from ts_debug() function';
398398

399399
CREATE FUNCTION ts_debug(regconfig, text)
400400
RETURNS SETOF ts_debug AS
401401
$$
402402
SELECT
403-
(
404-
SELECT
405-
tt.alias
406-
FROM
407-
pg_catalog.ts_token_type(
408-
(SELECT cfgparser FROM pg_catalog.pg_ts_config WHERE oid = $1 )
409-
) AS tt
410-
WHERE
411-
tt.tokid = parse.tokid
412-
) AS "Alias",
413-
(
414-
SELECT
415-
tt.description
416-
FROM
417-
pg_catalog.ts_token_type(
418-
(SELECT cfgparser FROM pg_catalog.pg_ts_config WHERE oid = $1 )
419-
) AS tt
420-
WHERE
421-
tt.tokid = parse.tokid
422-
) AS "Description",
403+
tt.alias AS "Alias",
404+
tt.description AS "Description",
423405
parse.token AS "Token",
424406
ARRAY ( SELECT m.mapdict::pg_catalog.regdictionary
425407
FROM pg_catalog.pg_ts_config_map AS m
426408
WHERE m.mapcfg = $1 AND m.maptokentype = parse.tokid
427-
ORDER BY m.mapcfg, m.maptokentype, m.mapseqno )
409+
ORDER BY m.mapseqno )
428410
AS "Dictionaries",
429411
(
430412
SELECT
@@ -433,23 +415,29 @@ SELECT
433415
( SELECT mapdict, pg_catalog.ts_lexize(mapdict, parse.token) AS lex
434416
FROM pg_catalog.pg_ts_config_map AS m
435417
WHERE m.mapcfg = $1 AND m.maptokentype = parse.tokid
436-
ORDER BY m.mapcfg, m.maptokentype, m.mapseqno ) dl
418+
ORDER BY m.mapseqno ) dl
437419
WHERE dl.lex IS NOT NULL
438420
LIMIT 1
439421
) AS "Lexized token"
440422
FROM pg_catalog.ts_parse(
441423
(SELECT cfgparser FROM pg_catalog.pg_ts_config WHERE oid = $1 ), $2
442-
) AS parse;
424+
) AS parse,
425+
pg_catalog.ts_token_type(
426+
(SELECT cfgparser FROM pg_catalog.pg_ts_config WHERE oid = $1 )
427+
) AS tt
428+
WHERE tt.tokid = parse.tokid
443429
$$
444-
LANGUAGE SQL RETURNS NULL ON NULL INPUT;
430+
LANGUAGE SQL STRICT STABLE;
445431

446-
COMMENT ON FUNCTION ts_debug(regconfig,text) IS 'debug function for text search configuration';
432+
COMMENT ON FUNCTION ts_debug(regconfig,text) IS
433+
'debug function for text search configuration';
447434

448435
CREATE FUNCTION ts_debug(text)
449436
RETURNS SETOF ts_debug AS
450437
$$
451-
SELECT * FROM pg_catalog.ts_debug( pg_catalog.get_current_ts_config(), $1 );
438+
SELECT * FROM pg_catalog.ts_debug( pg_catalog.get_current_ts_config(), $1);
452439
$$
453-
LANGUAGE SQL RETURNS NULL ON NULL INPUT;
440+
LANGUAGE SQL STRICT STABLE;
454441

455-
COMMENT ON FUNCTION ts_debug(text) IS 'debug function for current text search configuration';
442+
COMMENT ON FUNCTION ts_debug(text) IS
443+
'debug function for current text search configuration';

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy