Fixed segmentation fault with COUNT - fixes #9

This commit is contained in:
Andrew Kane
2021-06-09 03:13:22 -07:00
parent b713cbc3b6
commit 57e6a01214
5 changed files with 28 additions and 0 deletions

View File

@@ -1,3 +1,7 @@
## 0.1.6 (unreleased)
- Fixed segmentation fault with `COUNT`
## 0.1.5 (2021-05-25)
- Reduced memory usage during index creation

View File

@@ -51,6 +51,19 @@ ivfflatcostestimate(PlannerInfo *root, IndexPath *path, double loop_count,
qinfos = deconstruct_indexquals(path);
#endif
/* Never use index without order */
if (path->indexorderbys == NULL)
{
*indexStartupCost = 1.0e10;
*indexTotalCost = 1.0e10;
*indexSelectivity = 0;
*indexCorrelation = 0;
#if PG_VERSION_NUM >= 100000
*indexPages = 0;
#endif
return;
}
MemSet(&costs, 0, sizeof(costs));
#if PG_VERSION_NUM >= 120000

View File

@@ -251,6 +251,10 @@ ivfflatgettuple(IndexScanDesc scan, ScanDirection dir)
{
Datum value;
/* Safety check */
if (scan->orderByData == NULL)
elog(ERROR, "cannot scan ivfflat index without order");
/* No items will match if null */
if (scan->orderByData->sk_flags & SK_ISNULL)
return false;

View File

@@ -19,4 +19,10 @@ SELECT * FROM t ORDER BY val <-> (SELECT NULL::vector);
-----
(0 rows)
SELECT COUNT(*) FROM t;
count
-------
5
(1 row)
DROP TABLE t;

View File

@@ -10,5 +10,6 @@ INSERT INTO t (val) VALUES ('[1,2,4]');
SELECT * FROM t ORDER BY val <-> '[3,3,3]';
SELECT * FROM t ORDER BY val <-> (SELECT NULL::vector);
SELECT COUNT(*) FROM t;
DROP TABLE t;