Datum dbms_assert_noop(PG_FUNCTION_ARGS) { text *str = PG_GETARG_TEXT_P(0); PG_RETURN_TEXT_P(TextPCopy(str)); }
static void set_c_subst(text *sc) { MemoryContext oldctx; if (c_subst) pfree(c_subst); oldctx = MemoryContextSwitchTo(TopMemoryContext); c_subst = sc ? TextPCopy(sc) : cstring_to_text(C_SUBST); MemoryContextSwitchTo(oldctx); }
Datum plvstr_swap(PG_FUNCTION_ARGS) { text *string_in; text *replace_in; int start_in = 1; int oldlen_in; int v_len; if (PG_ARGISNULL(0)) PG_RETURN_NULL(); else string_in = PG_GETARG_TEXT_P(0); if (PG_ARGISNULL(1)) PG_RETURN_NULL(); else replace_in = PG_GETARG_TEXT_P(1); if (!PG_ARGISNULL(2)) start_in = PG_GETARG_INT32(2); if (PG_ARGISNULL(3)) oldlen_in = ora_mb_strlen1(replace_in); else oldlen_in = PG_GETARG_INT32(3); v_len = ora_mb_strlen1(string_in); start_in = start_in > 0 ? start_in : v_len + start_in + 1; if (start_in == 0 || start_in > v_len) PG_RETURN_TEXT_P(TextPCopy(string_in)); else if (start_in == 1) PG_RETURN_TEXT_P(ora_concat2( replace_in, ora_substr_text(string_in, oldlen_in+1, -1))); else PG_RETURN_TEXT_P(ora_concat3( ora_substr_text(string_in, 1, start_in - 1), replace_in, ora_substr_text(string_in, start_in + oldlen_in, -1))); }
Datum plvstr_rpart (PG_FUNCTION_ARGS) { text *str = PG_GETARG_TEXT_P(0); text *div = PG_GETARG_TEXT_P(1); int start = PG_GETARG_INT32(2); int nth = PG_GETARG_INT32(3); bool all_if_notfound = PG_GETARG_BOOL(4); int loc; loc = ora_instr(str, div, start, nth); if (loc == 0) { if (all_if_notfound) PG_RETURN_TEXT_P(TextPCopy(str)); else PG_RETURN_NULL(); } else PG_RETURN_TEXT_P(ora_substr_text(str, loc+1, -1)); }
Datum plvsubst_subst(PG_FUNCTION_ARGS) { init_c_subst(); PG_RETURN_TEXT_P(TextPCopy(c_subst)); }