@@ -83,21 +83,14 @@ def test_order_by(self):
8383 """Tests SELECT constructions to 'pglist' base"""
8484 try :
8585 self .init_pglist_data (self .node )
86- indexes = self .node .execute (
87- "pglist" ,
88- "SELECT count(*) FROM pg_class c "
89- " JOIN pg_index i ON i.indexrelid = c.oid"
90- " JOIN pg_class c2 ON i.indrelid = c2.oid"
91- " WHERE c.relkind = 'i' AND c2.relname = 'pglist' AND "
92- " c.relname = 'rumidx_orderby_sent'" )
93- if indexes [0 ][0 ] == 0 :
94- print ("Creating index 'rumidx_orderby_sent'" )
9586
96- self .node .safe_psql (
97- "pglist" ,
98- "CREATE INDEX rumidx_orderby_sent ON pglist USING rum ("
99- " fts rum_tsvector_timestamp_ops, sent) "
100- " WITH (attach=sent, to=fts, order_by_attach=t)" )
87+ print ("Creating index 'rumidx_orderby_sent'" )
88+
89+ self .node .safe_psql (
90+ "pglist" ,
91+ "CREATE INDEX rumidx_orderby_sent ON pglist USING rum ("
92+ " fts rum_tsvector_timestamp_ops, sent) "
93+ " WITH (attach=sent, to=fts, order_by_attach=t)" )
10194
10295 print ("Running tests" )
10396
@@ -121,6 +114,29 @@ def test_order_by(self):
121114 ),
122115 b'222813\n '
123116 )
117+
118+ self .node .safe_psql ("pglist" , "DROP INDEX rumidx_orderby_sent" );
119+
120+ print ("Creating index 'pglist_rum_idx'" )
121+
122+ self .node .safe_psql (
123+ "pglist" ,
124+ "CREATE INDEX pglist_rum_idx ON pglist USING rum ("
125+ " fts rum_tsvector_ops)" )
126+
127+ print ("Running tests" )
128+
129+ self .assertEqual (
130+ self .node .execute (
131+ "pglist" ,
132+ "SELECT id FROM pglist "
133+ "WHERE fts @@ to_tsquery('english', 'postgres:*') "
134+ "ORDER BY fts <=> to_tsquery('english', 'postgres:*') "
135+ "LIMIT 9"
136+ )[0 ][0 ],
137+ 816114
138+ )
139+
124140 except Exception as e :
125141 self .printlog (os .path .join (self .node .logs_dir , "postgresql.log" ))
126142 raise e
0 commit comments