From c4b2b2960aad6fc292dfaec330ebe41fead8ab30 Mon Sep 17 00:00:00 2001
From: Teodor Sigaev <teodor@sigaev.ru>
Date: Tue, 11 Sep 2007 08:51:22 +0000
Subject: [PATCH] Fix ts_debug function to prevent unneeded calls of
 ts_lexize(). It will be mush better to reimplement ts_debug in C (instead of
 SQL as now), but it's planned for the future.

---
 src/backend/catalog/system_views.sql | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

diff --git a/src/backend/catalog/system_views.sql b/src/backend/catalog/system_views.sql
index 7540c7e7a55..e4ae0f39d4e 100644
--- a/src/backend/catalog/system_views.sql
+++ b/src/backend/catalog/system_views.sql
@@ -3,7 +3,7 @@
  *
  * Copyright (c) 1996-2007, PostgreSQL Global Development Group
  *
- * $PostgreSQL: pgsql/src/backend/catalog/system_views.sql,v 1.43 2007/09/11 03:28:05 tgl Exp $
+ * $PostgreSQL: pgsql/src/backend/catalog/system_views.sql,v 1.44 2007/09/11 08:51:22 teodor Exp $
  */
 
 CREATE VIEW pg_roles AS 
@@ -415,8 +415,7 @@ SELECT
             ( SELECT mapdict, pg_catalog.ts_lexize(mapdict, parse.token) AS lex
               FROM pg_catalog.pg_ts_config_map AS m
               WHERE m.mapcfg = $1 AND m.maptokentype = parse.tokid
-              ORDER BY m.mapseqno ) dl
-        WHERE dl.lex IS NOT NULL
+              ORDER BY pg_catalog.ts_lexize(mapdict, parse.token) IS NULL, m.mapseqno ) dl
         LIMIT 1
     ) AS "Lexized token"
 FROM pg_catalog.ts_parse(
-- 
GitLab