mirror of
https://github.com/HypoPG/hypopg
synced 2026-05-24 09:38:21 +00:00
Compile and use on Windows (#36)
* 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
This commit is contained in:
parent
8424300cb9
commit
4a5dc56169
7 changed files with 35 additions and 34 deletions
8
hypopg.c
8
hypopg.c
|
|
@ -60,10 +60,10 @@ static List *pending_invals = NIL; /* List of interesting OID for which we
|
|||
|
||||
/*--- 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);
|
||||
|
||||
|
|
@ -719,7 +719,7 @@ hypo_set_rel_pathlist_hook(PlannerInfo *root,
|
|||
/*
|
||||
* Reset all stored entries.
|
||||
*/
|
||||
Datum
|
||||
PGDLLEXPORT Datum
|
||||
hypopg_reset(PG_FUNCTION_ARGS)
|
||||
{
|
||||
hypo_index_reset();
|
||||
|
|
|
|||
|
|
@ -317,10 +317,9 @@ static void hypo_do_analyze_partition(Relation onerel, Relation pgstats,
|
|||
fraction);
|
||||
|
||||
/* And make sure we don't overflow the compute_stats function */
|
||||
if (SPI_processed >= INT32_MAX)
|
||||
if (SPI_processed >= PG_INT32_MAX)
|
||||
elog(ERROR, "hypopg: the %f fraction of rows to analyze is too high."
|
||||
" At most %d rows must be computed.",
|
||||
fraction, INT32_MAX);
|
||||
" At most %d rows must be computed.", fraction, PG_INT32_MAX);
|
||||
|
||||
numrows = (int) SPI_processed;
|
||||
/*
|
||||
|
|
@ -337,7 +336,7 @@ static void hypo_do_analyze_partition(Relation onerel, Relation pgstats,
|
|||
* responsible to make sure that whatever they store into the VacAttrStats
|
||||
* structure is allocated in anl_context.
|
||||
*/
|
||||
if (numrows >= 100 && numrows < INT32_MAX)
|
||||
if (numrows >= 100 && numrows < PG_INT32_MAX)
|
||||
{
|
||||
MemoryContext col_context,
|
||||
old_context;
|
||||
|
|
|
|||
|
|
@ -1846,8 +1846,7 @@ hypo_estimate_index(hypoIndex *entry, RelOptInfo *rel, PlannerInfo *root)
|
|||
- (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
|
||||
|
|
@ -1929,7 +1928,7 @@ hypo_estimate_index(hypoIndex *entry, RelOptInfo *rel, PlannerInfo *root)
|
|||
sizeof_SignType * bloomLength;
|
||||
|
||||
entry->pages = 1; /* meta page */
|
||||
entry->pages += ceil(
|
||||
entry->pages += (BlockNumber) ceil(
|
||||
((double) entry->tuples * line_size) / usable_page_size);
|
||||
}
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -1190,20 +1190,24 @@ hypo_generate_partkey(CreateStmt *stmt, Oid parentid, hypoTable *entry)
|
|||
opclassform->opcintype,
|
||||
opclassform->opcintype,
|
||||
procnum);
|
||||
if (!OidIsValid(funcid))
|
||||
if (!OidIsValid(funcid))
|
||||
#if PG_VERSION_NUM >= 110000
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_INVALID_OBJECT_DEFINITION),
|
||||
errmsg("operator class \"%s\" of access method %s is missing support function %d for type %s",
|
||||
NameStr(opclassform->opcname),
|
||||
#if PG_VERSION_NUM >= 110000
|
||||
(key->strategy == PARTITION_STRATEGY_HASH) ?
|
||||
"hash" : "btree",
|
||||
#else
|
||||
"btree",
|
||||
#endif
|
||||
(key->strategy == PARTITION_STRATEGY_HASH) ? "hash" : "btree",
|
||||
procnum,
|
||||
format_type_be(opclassform->opcintype))));
|
||||
|
||||
#else
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_INVALID_OBJECT_DEFINITION),
|
||||
errmsg("operator class \"%s\" of access method %s is missing support function %d for type %s",
|
||||
NameStr(opclassform->opcname),
|
||||
"btree",
|
||||
procnum,
|
||||
format_type_be(opclassform->opcintype))));
|
||||
#endif
|
||||
fmgr_info(funcid, &key->partsupfunc[i]);
|
||||
|
||||
/* Collation */
|
||||
|
|
|
|||
|
|
@ -43,11 +43,10 @@ Selectivity hypo_clauselist_selectivity(PlannerInfo *root, RelOptInfo *rel,
|
|||
List *clauses, Oid table_relid, Oid parent_oid);
|
||||
|
||||
/*--- Functions --- */
|
||||
|
||||
Datum hypopg_analyze(PG_FUNCTION_ARGS);
|
||||
Datum hypopg_statistic(PG_FUNCTION_ARGS);
|
||||
PGDLLEXPORT Datum hypopg_analyze(PG_FUNCTION_ARGS);
|
||||
PGDLLEXPORT Datum hypopg_statistic(PG_FUNCTION_ARGS);
|
||||
#if PG_VERSION_NUM >= 100000
|
||||
void hypo_stat_remove(Oid tableid);
|
||||
PGDLLEXPORT void hypo_stat_remove(Oid tableid);
|
||||
#endif
|
||||
|
||||
#endif /* _HYPOPG_ANALYZE_H_ */
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
|
|
|
|||
|
|
@ -75,11 +75,11 @@ extern HTAB *hypoTables;
|
|||
|
||||
void hypo_table_reset(void);
|
||||
|
||||
Datum hypopg_table(PG_FUNCTION_ARGS);
|
||||
Datum hypopg_add_partition(PG_FUNCTION_ARGS);
|
||||
Datum hypopg_drop_table(PG_FUNCTION_ARGS);
|
||||
Datum hypopg_partition_table(PG_FUNCTION_ARGS);
|
||||
Datum hypopg_reset_table(PG_FUNCTION_ARGS);
|
||||
PGDLLEXPORT Datum hypopg_table(PG_FUNCTION_ARGS);
|
||||
PGDLLEXPORT Datum hypopg_add_partition(PG_FUNCTION_ARGS);
|
||||
PGDLLEXPORT Datum hypopg_drop_table(PG_FUNCTION_ARGS);
|
||||
PGDLLEXPORT Datum hypopg_partition_table(PG_FUNCTION_ARGS);
|
||||
PGDLLEXPORT Datum hypopg_reset_table(PG_FUNCTION_ARGS);
|
||||
|
||||
#if PG_VERSION_NUM >= 100000
|
||||
hypoTable *hypo_find_table(Oid tableid, bool missing_ok);
|
||||
|
|
|
|||
Loading…
Reference in a new issue