Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit0c04c8b

Browse files
author
Artur Zakirov
committed
Issue#13. Fix result array size.
1 parent85566a7 commit0c04c8b

File tree

2 files changed

+38
-17
lines changed

2 files changed

+38
-17
lines changed

‎src/rum_ts_utils.c

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1519,13 +1519,13 @@ rum_ts_join_pos(PG_FUNCTION_ARGS)
15191519
bytea*result;
15201520
intcount1=count_pos(in1,VARSIZE_ANY_EXHDR(addInfo1)),
15211521
count2=count_pos(in2,VARSIZE_ANY_EXHDR(addInfo2)),
1522-
countRes=0,
1523-
i1=0,i2=0,size;
1522+
countRes=0;
1523+
inti1=0,i2=0;
1524+
Sizesize;
15241525
WordEntryPospos1=0,
15251526
pos2=0,
15261527
*pos;
15271528

1528-
result=palloc(VARHDRSZ+sizeof(WordEntryPos)* (count1+count2));
15291529
pos=palloc(sizeof(WordEntryPos)* (count1+count2));
15301530

15311531
Assert(count1>0&&count2>0);
@@ -1577,6 +1577,11 @@ rum_ts_join_pos(PG_FUNCTION_ARGS)
15771577
i2++;
15781578
}
15791579

1580+
Assert(countRes <= (count1+count2));
1581+
1582+
size=VARHDRSZ+2*sizeof(WordEntryPos)*countRes;
1583+
result=palloc(size);
1584+
15801585
size=compress_pos(result->vl_dat,pos,countRes)+VARHDRSZ;
15811586
SET_VARSIZE(result,size);
15821587

‎tests/pglist_tests.py

Lines changed: 30 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -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-
ifindexes[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
exceptExceptionase:
125141
self.printlog(os.path.join(self.node.logs_dir,"postgresql.log"))
126142
raisee

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp