/* Cast int4 -> bool */ datum_t int4_bool(PG_FUNC_ARGS) { if (ARG_INT32(0) == 0) RET_BOOL(false); else RET_BOOL(true); }
/* * The GiST Consistent method for polygons */ datum_t gist_poly_consistent(PG_FUNC_ARGS) { struct gist_entry *entry = (struct gist_entry *)ARG_POINTER(0); POLYGON *query = ARG_POLYGON_P(1); strat_nr_t strategy = (strat_nr_t) ARG_UINT16(2); /* oid_t subtype = ARG_OID(3); */ bool *recheck = (bool*) ARG_POINTER(4); bool result; /* All cases served by this function are inexact */ *recheck = true; if (D_TO_BOX_P(entry->key) == NULL || query == NULL) RET_BOOL(FALSE); /* * Since the operators require recheck anyway, we can just use * rtree_internal_consistent even at leaf nodes. (This works in part * because the index entries are bounding boxes not polygons.) */ result = rtree_internal_consistent(D_TO_BOX_P(entry->key), &(query->boundbox), strategy); /* Avoid memory leak if supplied poly is toasted */ PG_FREE_IF_COPY(query, 1); RET_BOOL(result); }
/* * The GiST Consistent method for circles */ datum_t gist_circle_consistent(PG_FUNC_ARGS) { struct gist_entry *entry = (struct gist_entry *)ARG_POINTER(0); CIRCLE *query = ARG_CIRCLE_P(1); strat_nr_t strategy = (strat_nr_t) ARG_UINT16(2); /* oid_t subtype = ARG_OID(3); */ bool *recheck = (bool *) ARG_POINTER(4); BOX bbox; bool result; /* All cases served by this function are inexact */ *recheck = true; if (D_TO_BOX_P(entry->key) == NULL || query == NULL) RET_BOOL(FALSE); /* * Since the operators require recheck anyway, we can just use * rtree_internal_consistent even at leaf nodes. (This works in part * because the index entries are bounding boxes not circles.) */ bbox.high.x = query->center.x + query->radius; bbox.low.x = query->center.x - query->radius; bbox.high.y = query->center.y + query->radius; bbox.low.y = query->center.y - query->radius; result = rtree_internal_consistent(D_TO_BOX_P(entry->key), &bbox, strategy); RET_BOOL(result); }
/* * We don't have a complete set of int2_vector_s support routines, * but we need int2vectoreq for catcache indexing. */ datum_t int2vectoreq(PG_FUNC_ARGS) { int2_vector_s *a = (int2_vector_s*) ARG_POINTER(0); int2_vector_s *b = (int2_vector_s*) ARG_POINTER(1); if (a->dim1 != b->dim1) RET_BOOL(false); RET_BOOL(memcmp(a->values, b->values, a->dim1 * sizeof(int2)) == 0); }
datum_t tsq_mcontains(PG_FUNC_ARGS) { TSQuery query = ARG_TSQUERY(0); TSQuery ex = ARG_TSQUERY(1); TSQuerySign sq, se; int i, j; QueryItem *iq, *ie; if (query->size < ex->size) { PG_FREE_IF_COPY(query, 0); PG_FREE_IF_COPY(ex, 1); RET_BOOL(false); } sq = makeTSQuerySign(query); se = makeTSQuerySign(ex); if ((sq & se) != se) { PG_FREE_IF_COPY(query, 0); PG_FREE_IF_COPY(ex, 1); RET_BOOL(false); } iq = GETQUERY(query); ie = GETQUERY(ex); for (i = 0; i < ex->size; i++) { if (ie[i].type != QI_VAL) continue; for (j = 0; j < query->size; j++) { if (iq[j].type == QI_VAL && ie[i].qoperand.valcrc == iq[j].qoperand.valcrc) break; } if (j >= query->size) { PG_FREE_IF_COPY(query, 0); PG_FREE_IF_COPY(ex, 1); RET_BOOL(false); } } PG_FREE_IF_COPY(query, 0); PG_FREE_IF_COPY(ex, 1); RET_BOOL(true); }
datum_t int2le(PG_FUNC_ARGS) { int16 arg1 = ARG_INT16(0); int16 arg2 = ARG_INT16(1); RET_BOOL(arg1 <= arg2); }
datum_t int4le(PG_FUNC_ARGS) { int32 arg1 = ARG_INT32(0); int32 arg2 = ARG_INT32(1); RET_BOOL(arg1 <= arg2); }
datum_t gin_tsquery_consistent(PG_FUNC_ARGS) { bool *check = (bool *) ARG_POINTER(0); /* strat_nr_t strategy = ARG_UINT16(1); */ TSQuery query = ARG_TSQUERY(2); /* int32 nkeys = ARG_INT32(3); */ pointer_p *extra_data = (pointer_p *) ARG_POINTER(4); bool *recheck = (bool *) ARG_POINTER(5); bool res = FALSE; /* The query requires recheck only if it involves weights */ *recheck = false; if (query->size > 0) { QueryItem *item; GinChkVal gcv; /* * check-parameter array has one entry for each value (operand) in the * query. */ gcv.first_item = item = GETQUERY(query); gcv.check = check; gcv.map_item_operand = (int *)(extra_data[0]); gcv.need_recheck = recheck; res = TS_execute(GETQUERY(query), &gcv, true, checkcondition_gin); } RET_BOOL(res); }
datum_t pg_reload_conf(PG_FUNC_ARGS) { if (!superuser()) ereport(ERROR, ( errcode(E_INSUFFICIENT_PRIVILEGE), errmsg("must be superuser to signal the postmaster"))); if (kill(postmaster_pid, SIGHUP)) { ereport(WARNING, ( errmsg("failed to send signal to postmaster: %m"))); RET_BOOL(false); } RET_BOOL(true); }
int LuaAura_SetPositive(lua_State * L, Aura * aura) { TEST_AURA_RET(); uint32 positivery = luaL_optint(L, 1, 1); aura->SetPositive(positivery); RET_BOOL(true); }
datum_t int42ge(PG_FUNC_ARGS) { int32 arg1 = ARG_INT32(0); int16 arg2 = ARG_INT16(1); RET_BOOL(arg1 >= arg2); }
datum_t int24gt(PG_FUNC_ARGS) { int16 arg1 = ARG_INT16(0); int32 arg2 = ARG_INT32(1); RET_BOOL(arg1 > arg2); }
datum_t uuid_ne(PG_FUNC_ARGS) { pg_uuid_t *arg1 = ARG_UUID_P(0); pg_uuid_t *arg2 = ARG_UUID_P(1); RET_BOOL(__uuid_cmp(arg1, arg2) != 0); }
/* * Rotate log file */ datum_t pg_rotate_logfile(PG_FUNC_ARGS) { if (!superuser()) ereport(ERROR, ( errcode(E_INSUFFICIENT_PRIVILEGE), errmsg("must be superuser to rotate log files"))); if (!log_collector) { ereport(WARNING, ( errmsg("rotation not possible because log collection not active"))); RET_BOOL(false); } send_pmsignal(PMSIGNAL_ROTATE_LOGFILE); RET_BOOL(true); }
int LuaSpell_ResetVar(lua_State * L, Spell * sp) { if (sp == NULL) RET_BOOL(false); const char* var = luaL_checkstring(L,1); if (var == NULL) RET_BOOL(false); int subindex = luaL_optint(L,2,0); if (subindex < 0) RET_BOOL(false); SpellEntry * proto = sp->GetSpellProto(); if (proto == NULL) RET_NIL(false); LuaSpellEntry l = GetLuaSpellEntryByName(var); if (!l.name) RET_BOOL(false); switch (l.typeId) //0: int, 1: char*, 2: bool, 3: float { case 0: GET_SPELLVAR_INT(proto, l.offset,subindex) = GET_SPELLVAR_INT(sp->m_spellInfo,l.offset,subindex); lua_pushboolean(L, 1); break; case 1: GET_SPELLVAR_CHAR(proto, l.offset,subindex) = GET_SPELLVAR_CHAR(sp->m_spellInfo,l.offset,subindex); lua_pushboolean(L, 1); break; case 2: GET_SPELLVAR_BOOL(proto, l.offset,subindex) = GET_SPELLVAR_BOOL(sp->m_spellInfo,l.offset,subindex); lua_pushboolean(L, 1); break; case 3: GET_SPELLVAR_FLOAT(proto, l.offset,subindex) = GET_SPELLVAR_FLOAT(sp->m_spellInfo,l.offset,subindex); lua_pushboolean(L, 1); break; default: RET_BOOL(false); break; } return 1; }
int LuaGlobalFunctions_IsSanctuaryArea(lua_State * L) { uint32 areaid = CHECK_ULONG(L,1); if (!areaid) RET_BOOL(false); lua_pushboolean(L, sWorld.IsSanctuaryArea(areaid) ? 1 : 0); return 1; }
int LuaAura_SetVar(lua_State * L, Aura * aura) { TEST_AURA_RET(); const char* var = luaL_checkstring(L,1); int subindex = 0; if (lua_gettop(L) == 3) subindex = luaL_optint(L,2,0); if (!var || subindex < 0) RET_BOOL(false); int valindex = 2; if(subindex) valindex++; SpellEntry * proto = aura->m_spellProto; if(proto == NULL) RET_NIL(true); LuaSpellEntry l = GetLuaSpellEntryByName(var); if (!l.name) RET_BOOL(false); switch (l.typeId) //0: int, 1: char*, 2: bool, 3: float { case 0: GET_SPELLVAR_INT(proto,l.offset,subindex) = luaL_checkinteger(L, valindex); lua_pushboolean(L, 1); break; case 1: strcpy(GET_SPELLVAR_CHAR(proto,l.offset,subindex), luaL_checkstring(L, valindex)); lua_pushboolean(L, 1); break; case 2: GET_SPELLVAR_BOOL(proto,l.offset,subindex) = CHECK_BOOL(L, valindex); lua_pushboolean(L, 1); break; case 3: GET_SPELLVAR_FLOAT(proto,l.offset,subindex) = (float)luaL_checknumber(L, valindex); lua_pushboolean(L, 1); break; } return 1; }
datum_t uuid_lt(PG_FUNC_ARGS) { pg_uuid_t *arg1; pg_uuid_t *arg2; arg1 = ARG_UUID_P(0); arg2 = ARG_UUID_P(1); RET_BOOL(__uuid_cmp(arg1, arg2) < 0); }
datum_t nameicregexne(PG_FUNC_ARGS) { struct name* n = ARG_NAME(0); text *p = ARG_TEXT_PP(1); RET_BOOL(!RE_compile_and_execute(p, NAME_TO_STR(*n), strlen(NAME_TO_STR(*n)), REG_ADVANCED | REG_ICASE, PG_COLLATION(), 0, NULL)); }
datum_t texticregexne(PG_FUNC_ARGS) { text *s = ARG_TEXT_PP(0); text *p = ARG_TEXT_PP(1); RET_BOOL(!RE_compile_and_execute(p, VLA_DATA_ANY(s), VLA_SZ_ANY_EXHDR(s), REG_ADVANCED | REG_ICASE, PG_COLLATION(), 0, NULL)); }
int LuaGlobalFunctions_SetDBCSpellVar(lua_State * L) { uint32 entry = luaL_checkinteger(L,1); const char* var = luaL_checkstring(L,2); int subindex = 0; if (lua_gettop(L) == 4) subindex = luaL_optint(L,3,0); int valindex = 3; if (subindex) valindex++; SpellEntry * proto = dbcSpell.LookupEntryForced(entry); if (!entry || !var || subindex < 0 || !proto) RET_BOOL(false); LuaSpellEntry l = GetLuaSpellEntryByName(var); if (!l.name) RET_BOOL(false); switch (l.typeId) //0: int, 1: char*, 2: bool, 3: float { case 0: GET_SPELLVAR_INT(proto,l.offset,subindex) = luaL_checkinteger(L, valindex); lua_pushboolean(L, 1); break; case 1: strcpy(GET_SPELLVAR_CHAR(proto,l.offset,subindex), luaL_checkstring(L, valindex)); lua_pushboolean(L, 1); break; case 2: GET_SPELLVAR_BOOL(proto,l.offset,subindex) = CHECK_BOOL(L, valindex); lua_pushboolean(L, 1); break; case 3: GET_SPELLVAR_FLOAT(proto,l.offset,subindex) = (float)luaL_checknumber(L, valindex); lua_pushboolean(L, 1); break; } return 1; }
IMPLEMENT_FUNCTION(VLevel, TraceLine) { P_GET_PTR(TVec, HitNormal); P_GET_PTR(TVec, HitPoint); P_GET_VEC(End); P_GET_VEC(Start); P_GET_SELF; linetrace_t Trace; bool Ret = Self->TraceLine(Trace, Start, End, SPF_NOBLOCKING); *HitPoint = Trace.LineEnd; *HitNormal = Trace.HitPlaneNormal; RET_BOOL(Ret); }
IMPLEMENT_FUNCTION(VLevelInfo, ChangeSwitchTexture) { P_GET_PTR(vuint8, pQuest); P_GET_NAME(DefaultSound); P_GET_BOOL(useAgain); P_GET_INT(SideNum); P_GET_SELF; bool Quest; bool Ret = Self->ChangeSwitchTexture(SideNum, useAgain, DefaultSound, Quest); *pQuest = Quest; RET_BOOL(Ret); }
/* * The GiST Consistent method for boxes * * Should return false if for all data items x below entry, * the predicate x op query must be FALSE, where op is the oper * corresponding to strategy in the pg_amop table. */ datum_t gist_box_consistent(PG_FUNC_ARGS) { struct gist_entry* entry = (struct gist_entry *)ARG_POINTER(0); BOX* query = ARG_BOX_P(1); strat_nr_t strategy = (strat_nr_t) ARG_UINT16(2); /* oid_t subtype = ARG_OID(3); */ bool* recheck = (bool*) ARG_POINTER(4); /* All cases served by this function are exact */ *recheck = false; if (D_TO_BOX_P(entry->key) == NULL || query == NULL) RET_BOOL(FALSE); /* * if entry is not leaf, use rtree_internal_consistent, else use * gist_box_leaf_consistent */ if (GIST_LEAF(entry)) RET_BOOL(gist_box_leaf_consistent(D_TO_BOX_P(entry->key), query, strategy)); else RET_BOOL(rtree_internal_consistent(D_TO_BOX_P(entry->key), query, strategy)); }
int LuaSpell_SetVar(lua_State * L, Spell * sp) { if(sp == NULL) RET_BOOL(false); const char* var = luaL_checkstring(L,1); if (var == NULL) RET_BOOL(false); int subindex = 0; if (lua_gettop(L) == 3) { subindex = luaL_optint(L,2,0); } if (subindex < 0) RET_BOOL(false); int valindex = 2; if (subindex) valindex++; // sp->InitProtoOverride(); SpellEntry * proto = sp->GetSpellProto(); if(proto == NULL) RET_BOOL(false); LuaSpellEntry l = GetLuaSpellEntryByName(var); if (!l.name) RET_BOOL(false); switch (l.typeId) //0: int, 1: char*, 2: bool, 3: float { case 0: GET_SPELLVAR_INT(proto,l.offset,subindex) = luaL_checkinteger(L, valindex); lua_pushboolean(L, 1); break; case 1: strcpy(GET_SPELLVAR_CHAR(proto,l.offset,subindex), luaL_checkstring(L, valindex)); lua_pushboolean(L, 1); break; case 2: GET_SPELLVAR_BOOL(proto,l.offset,subindex) = CHECK_BOOL(L, valindex); lua_pushboolean(L, 1); break; case 3: GET_SPELLVAR_FLOAT(proto,l.offset,subindex) = (float)luaL_checknumber(L, valindex); lua_pushboolean(L, 1); break; default: RET_BOOL(false); break; } return 1; }
datum_t gbt_cash_consistent(PG_FUNC_ARGS) { struct gist_entry *entry = (struct gist_entry *) ARG_POINTER(0); Cash query = ARG_CASH(1); strat_nr_t strategy = (strat_nr_t) ARG_UINT16(2); /* oid_t subtype = ARG_OID(3); */ bool *recheck = (bool *) ARG_POINTER(4); cashKEY *kkk = (cashKEY *) D_TO_PTR(entry->key); GBT_NUMKEY_R key; /* All cases served by this function are exact */ *recheck = false; key.lower = (GBT_NUMKEY *) &kkk->lower; key.upper = (GBT_NUMKEY *) &kkk->upper; RET_BOOL( gbt_num_consistent(&key, (void *) &query, &strategy, GIST_LEAF(entry), &tinfo) ); }
datum_t ginint4_consistent(PG_FUNC_ARGS) { bool *check = (bool *) ARG_POINTER(0); strat_nr_t strategy = ARG_UINT16(1); int32 nkeys = ARG_INT32(3); /* pointer_p *extra_data = (pointer_p *) ARG_POINTER(4); */ bool *recheck = (bool *) ARG_POINTER(5); bool res = FALSE; int32 i; switch (strategy) { case RTOverlapStrategyNumber: /* result is not lossy */ *recheck = false; /* at least one element in check[] is true, so result = true */ res = TRUE; break; case RTContainedByStrategyNumber: case RTOldContainedByStrategyNumber: /* we will need recheck */ *recheck = true; /* at least one element in check[] is true, so result = true */ res = TRUE; break; case RTSameStrategyNumber: /* we will need recheck */ *recheck = true; /* Must have all elements in check[] true */ res = TRUE; for (i = 0; i < nkeys; i++) { if (!check[i]) { res = FALSE; break; } } break; case RTContainsStrategyNumber: case RTOldContainsStrategyNumber: /* result is not lossy */ *recheck = false; /* Must have all elements in check[] true */ res = TRUE; for (i = 0; i < nkeys; i++) { if (!check[i]) { res = FALSE; break; } } break; case BooleanSearchStrategy: { QUERYTYPE *query = ARG_QUERYTYPE_P(2); /* result is not lossy */ *recheck = false; res = gin_bool_consistent(query, check); } break; default: elog(ERROR, "ginint4_consistent: unknown strategy number: %d", strategy); } RET_BOOL(res); }
datum_t ssl_is_used(PG_FUNC_ARGS) { RET_BOOL(proc_port->ssl != NULL); }
datum_t ssl_client_cert_present(PG_FUNC_ARGS) { RET_BOOL(proc_port->peer != NULL); }
datum_t gist_point_consistent(PG_FUNC_ARGS) { struct gist_entry *entry = (struct gist_entry*) ARG_POINTER(0); strat_nr_t strategy = (strat_nr_t) ARG_UINT16(2); bool *recheck = (bool*) ARG_POINTER(4); bool result; strat_nr_t strategyGroup = strategy / GeoStrategyNumberOffset; switch (strategyGroup) { case PointStrategyNumberGroup: result = gist_point_consistent_internal( strategy % GeoStrategyNumberOffset, GIST_LEAF(entry), D_TO_BOX_P(entry->key), ARG_POINT_P(1)); *recheck = false; break; case BoxStrategyNumberGroup: result = D_TO_BOOL(DIRECT_FC5( gist_box_consistent, PTR_TO_D(entry), ARG_DATUM(1), INT16_TO_D(RTOverlapStrategyNumber), 0, PTR_TO_D(recheck))); break; case PolygonStrategyNumberGroup: { POLYGON *query = ARG_POLYGON_P(1); result = D_TO_BOOL(DIRECT_FC5( gist_poly_consistent, PTR_TO_D(entry), POLYGON_P_TO_D(query), INT16_TO_D(RTOverlapStrategyNumber), 0, PTR_TO_D(recheck))); if (GIST_LEAF(entry) && result) { /* * We are on leaf page and quick check shows overlapping * of polygon's bounding box and point */ BOX *box; box = D_TO_BOX_P(entry->key); ASSERT(box->high.x == box->low.x && box->high.y == box->low.y); result = D_TO_BOOL(DIRECT_FC2( poly_contain_pt, POLYGON_P_TO_D(query), POINT_P_TO_D(&box->high))); *recheck = false; } } break; case CircleStrategyNumberGroup: { CIRCLE *query = ARG_CIRCLE_P(1); result = D_TO_BOOL(DIRECT_FC5( gist_circle_consistent, PTR_TO_D(entry), CIRCLE_P_TO_D(query), INT16_TO_D(RTOverlapStrategyNumber), 0, PTR_TO_D(recheck))); if (GIST_LEAF(entry) && result) { /* * We are on leaf page and quick check shows overlapping * of polygon's bounding box and point */ BOX *box; box = D_TO_BOX_P(entry->key); ASSERT(box->high.x == box->low.x && box->high.y == box->low.y); result = D_TO_BOOL(DIRECT_FC2( circle_contain_pt, CIRCLE_P_TO_D(query), POINT_P_TO_D(&box->high))); *recheck = false; } } break; default: elog(ERROR, "unknown strategy number: %d", strategy); result = false; /* keep compiler quiet */ } RET_BOOL(result); }