Skip to content

Commit

Permalink
Compile and use on Windows (#36)
Browse files Browse the repository at this point in the history
* Add PGDLLEXPORT to functions called externally

* Make it compile with Visual Studio (it doesn't support #ifdef in macros)

* Add explicit type-cast so silence compiler warnings.

* Replace {INT_MAX | INT32_MAX } with PG_INT32_MAX

(cherry picked from commit 4a5dc56)
  • Loading branch information
Godwottery authored and rjuju committed Jun 16, 2019
1 parent 7a79114 commit 3f89878
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 13 deletions.
8 changes: 4 additions & 4 deletions hypopg.c
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,10 @@ MemoryContext HypoMemoryContext;

/*--- Functions --- */

void _PG_init(void);
void _PG_fini(void);
PGDLLEXPORT void _PG_init(void);
PGDLLEXPORT void _PG_fini(void);

Datum hypopg_reset(PG_FUNCTION_ARGS);
PGDLLEXPORT Datum hypopg_reset(PG_FUNCTION_ARGS);

PG_FUNCTION_INFO_V1(hypopg_reset);

Expand Down Expand Up @@ -334,7 +334,7 @@ hypo_get_relation_info_hook(PlannerInfo *root,
/*
* Reset statistics.
*/
Datum
PGDLLEXPORT Datum
hypopg_reset(PG_FUNCTION_ARGS)
{
hypo_index_reset();
Expand Down
5 changes: 2 additions & 3 deletions hypopg_index.c
Original file line number Diff line number Diff line change
Expand Up @@ -1668,8 +1668,7 @@ hypo_estimate_index(hypoIndex *entry, RelOptInfo *rel)
- (fillfactor == 0 ? BTREE_DEFAULT_FILLFACTOR : fillfactor)
+ additional_bloat) / 100;

entry->pages =
entry->tuples * line_size * bloat_factor / usable_page_size;
entry->pages = (BlockNumber) (entry->tuples * line_size * bloat_factor / usable_page_size);
#if PG_VERSION_NUM >= 90300
entry->tree_height = -1; /* TODO */
#endif
Expand Down Expand Up @@ -1751,7 +1750,7 @@ hypo_estimate_index(hypoIndex *entry, RelOptInfo *rel)
sizeof_SignType * bloomLength;

entry->pages = 1; /* meta page */
entry->pages += ceil(
entry->pages += (BlockNumber) ceil(
((double) entry->tuples * line_size) / usable_page_size);
}
#endif
Expand Down
12 changes: 6 additions & 6 deletions include/hypopg_index.h
Original file line number Diff line number Diff line change
Expand Up @@ -111,12 +111,12 @@ extern List *hypoIndexes;

void hypo_index_reset(void);

Datum hypopg(PG_FUNCTION_ARGS);
Datum hypopg_create_index(PG_FUNCTION_ARGS);
Datum hypopg_drop_index(PG_FUNCTION_ARGS);
Datum hypopg_relation_size(PG_FUNCTION_ARGS);
Datum hypopg_get_indexdef(PG_FUNCTION_ARGS);
Datum hypopg_reset_index(PG_FUNCTION_ARGS);
PGDLLEXPORT Datum hypopg(PG_FUNCTION_ARGS);
PGDLLEXPORT Datum hypopg_create_index(PG_FUNCTION_ARGS);
PGDLLEXPORT Datum hypopg_drop_index(PG_FUNCTION_ARGS);
PGDLLEXPORT Datum hypopg_relation_size(PG_FUNCTION_ARGS);
PGDLLEXPORT Datum hypopg_get_indexdef(PG_FUNCTION_ARGS);
PGDLLEXPORT Datum hypopg_reset_index(PG_FUNCTION_ARGS);

extern explain_get_index_name_hook_type prev_explain_get_index_name_hook;
const char *hypo_explain_get_index_name_hook(Oid indexId);
Expand Down

0 comments on commit 3f89878

Please sign in to comment.