X-Git-Url: http://sigaev.ru/git/gitweb.cgi?p=smlar.git;a=blobdiff_plain;f=smlar_stat.c;h=9a563aaca3d473ee83a2482ca91cf7b5c885efd8;hp=1007de88d2dc1ef24dc561bd0fe7d869f8e8edeb;hb=8d02df18c0bbfd6ccba94a9582499ec8746047e5;hpb=0bc52593d34ce24b38cbd4fb6225d97601c5b871 diff --git a/smlar_stat.c b/smlar_stat.c index 1007de8..9a563aa 100644 --- a/smlar_stat.c +++ b/smlar_stat.c @@ -41,7 +41,7 @@ initStatCache(MemoryContext ctx) if (PersistentDocStat && GetSmlarUsePersistent()) return PersistentDocStat; else { - int stat; + int stat; char buf[1024]; const char *tbl = GetSmlarTable(); StatCache *cache = NULL; @@ -49,7 +49,7 @@ initStatCache(MemoryContext ctx) if ( tbl == NULL || *tbl == '\0' ) elog(ERROR,"smlar.stattable is not defined"); - sprintf(buf,"SELECT * FROM \"%s\" ORDER BY 1;", tbl); + sprintf(buf,"SELECT * FROM \"%s\" ORDER BY 1;", tbl); SPI_connect(); stat = SPI_execute(buf, true, 0); @@ -62,7 +62,7 @@ initStatCache(MemoryContext ctx) } else { - int i; + int i; double totaldocs = 0.0; Oid ndocType = SPI_gettypeid(SPI_tuptable->tupdesc, 2); @@ -81,7 +81,7 @@ initStatCache(MemoryContext ctx) for(i=0; ivals[i], SPI_tuptable->tupdesc, 1, &isnullvalue); + Datum datum = SPI_getbinval(SPI_tuptable->vals[i], SPI_tuptable->tupdesc, 1, &isnullvalue); int64 ndoc; if (ndocType == INT4OID) @@ -115,7 +115,7 @@ initStatCache(MemoryContext ctx) else { size_t size = datumGetSize(datum, false, cache->info->typlen); - + cache->elems[i].datum = PointerGetDatum(cacheAlloc(ctx, size)); memcpy(DatumGetPointer(cache->elems[i].datum), DatumGetPointer(datum), size); } @@ -127,7 +127,7 @@ initStatCache(MemoryContext ctx) if ( totaldocs <= 0) elog(ERROR,"Total number of document is unknown"); cache->nelems = SPI_processed - 1; - + for(i=0;inelems;i++) { if ( totaldocs < cache->elems[i].idf )