当前位置: 首页>>代码示例>>C++>>正文


C++ PG_CATCH函数代码示例

本文整理汇总了C++中PG_CATCH函数的典型用法代码示例。如果您正苦于以下问题:C++ PG_CATCH函数的具体用法?C++ PG_CATCH怎么用?C++ PG_CATCH使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了PG_CATCH函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: pgss_ExecutorRun

/*
 * ExecutorRun hook: all we need do is track nesting depth
 */
static void
pgss_ExecutorRun(QueryDesc *queryDesc, ScanDirection direction, long count)
{
	nested_level++;
	PG_TRY();
	{
		if (prev_ExecutorRun)
			prev_ExecutorRun(queryDesc, direction, count);
		else
			standard_ExecutorRun(queryDesc, direction, count);
		nested_level--;
	}
	PG_CATCH();
	{
		nested_level--;
		PG_RE_THROW();
	}
	PG_END_TRY();
}
开发者ID:LittleForker,项目名称:postgres,代码行数:22,代码来源:pg_stat_statements.c

示例2: pgss_ExecutorFinish

/*
 * ExecutorFinish hook: all we need do is track nesting depth
 */
static void
pgss_ExecutorFinish(QueryDesc *queryDesc)
{
	nested_level++;
	PG_TRY();
	{
		if (prev_ExecutorFinish)
			prev_ExecutorFinish(queryDesc);
		else
			standard_ExecutorFinish(queryDesc);
		nested_level--;
	}
	PG_CATCH();
	{
		nested_level--;
		PG_RE_THROW();
	}
	PG_END_TRY();
}
开发者ID:LittleForker,项目名称:postgres,代码行数:22,代码来源:pg_stat_statements.c

示例3: histogram_ExecutorRun

/*
 * ExecutorRun hook: all we need do is track nesting depth
 */
static void
histogram_ExecutorRun(QueryDesc *queryDesc, ScanDirection direction, uint64 count)
{
	nesting_level++;
	PG_TRY();
	{
		if (prev_ExecutorRun)
			prev_ExecutorRun(queryDesc, direction, count);
		else
			standard_ExecutorRun(queryDesc, direction, count);
		nesting_level--;
	}
	PG_CATCH();
	{
		nesting_level--;
		PG_RE_THROW();
	}
	PG_END_TRY();
}
开发者ID:tvondra,项目名称:query_histogram,代码行数:22,代码来源:queryhist.c

示例4: run_pg_parse_json

/*
 * run_pg_parse_json:
 *
 * Wrap pg_parse_json in order to restore InterruptHoldoffCount when parse
 * error occured.
 *
 * Returns true when parse completed. False for unexpected end of string.
 */
bool
run_pg_parse_json(JsonLexContext *lex, JsonSemAction *sem)
{
	MemoryContext ccxt = CurrentMemoryContext;
	uint32 saved_IntrHoldoffCount;

	/*
	 * "ereport(ERROR.." occurs on error in pg_parse_json resets
	 * InterruptHoldoffCount to zero, so we must save the value before calling
	 * json parser to restore it on parse error. See errfinish().
	 */
	saved_IntrHoldoffCount = InterruptHoldoffCount;

	PG_TRY();
	{
		pg_parse_json(lex, sem);
	}
	PG_CATCH();
	{
		ErrorData *errdata;
		MemoryContext ecxt;

		InterruptHoldoffCount = saved_IntrHoldoffCount;

		ecxt = MemoryContextSwitchTo(ccxt);
		errdata = CopyErrorData();
		
		if (errdata->sqlerrcode == ERRCODE_INVALID_TEXT_REPRESENTATION)
		{
			FlushErrorState();
			return false;
		}
		else
		{
			MemoryContextSwitchTo(ecxt);
			PG_RE_THROW();
		}
	}
	PG_END_TRY();

	return true;
}
开发者ID:oknj,项目名称:postgresql-9.5-pg-store-plans,代码行数:50,代码来源:pgsp_json.c

示例5: explain_ExecutorRun

/*
 * ExecutorRun hook: all we need do is track nesting depth
 */
static void
explain_ExecutorRun(QueryDesc *queryDesc, ScanDirection direction,
					uint64 count, bool execute_once)
{
	nesting_level++;
	PG_TRY();
	{
		if (prev_ExecutorRun)
			prev_ExecutorRun(queryDesc, direction, count, execute_once);
		else
			standard_ExecutorRun(queryDesc, direction, count, execute_once);
		nesting_level--;
	}
	PG_CATCH();
	{
		nesting_level--;
		PG_RE_THROW();
	}
	PG_END_TRY();
}
开发者ID:Brar,项目名称:postgres,代码行数:23,代码来源:auto_explain.c

示例6: Java_org_postgresql_pljava_internal_Backend__1log

/*
 * Class:     org_postgresql_pljava_internal_Backend
 * Method:    _log
 * Signature: (ILjava/lang/String;)V
 */
JNIEXPORT void JNICALL
JNICALL Java_org_postgresql_pljava_internal_Backend__1log(JNIEnv* env, jclass cls, jint logLevel, jstring jstr)
{
	BEGIN_NATIVE_NO_ERRCHECK
	char* str = String_createNTS(jstr);
	if(str != 0)
	{
		PG_TRY();
		{
			elog(logLevel, "%s", str);
			pfree(str);
		}
		PG_CATCH();
		{
			Exception_throw_ERROR("ereport");
		}
		PG_END_TRY();
	}
	END_NATIVE
}
开发者ID:greenplum-db,项目名称:pljava,代码行数:25,代码来源:Backend.c

示例7: get_row

static Datum
get_row(FunctionCallInfo fcinfo, PlxResult *plx_result, int nrow)
{
    StringInfoData  buf;
    PlxFn          *plx_fn = plx_result->plx_fn;
    PGresult       *pg_result = plx_result->pg_result;
    Datum           ret;

    if (PQgetisnull(pg_result, nrow, 0))
    {
        fcinfo->isnull = true;
        return (Datum)NULL;
    }

    setFixedStringInfo(&buf,
                       PQgetvalue(pg_result, nrow, 0),
                       PQgetlength(pg_result, nrow, 0));

    PG_TRY();
    {
        if (plx_fn->is_binary)
            ret = ReceiveFunctionCall(&plx_fn->ret_type->receive_fn,
                                      &buf,
                                      plx_fn->ret_type->receive_io_params,
                                      plx_fn->ret_type_mod);
        else
            ret = InputFunctionCall(&plx_fn->ret_type->input_fn,
                                    buf.data,
                                    plx_fn->ret_type->receive_io_params,
                                    plx_fn->ret_type_mod);
    }
    PG_CATCH();
    {
        plx_result_cache_delete(fcinfo);
        PQclear(pg_result);
        pfree(plx_result);
        PG_RE_THROW();
    }
    PG_END_TRY();
    return ret;
}
开发者ID:comagic,项目名称:plexor,代码行数:41,代码来源:result.c

示例8: test__getSpillFile__Initialize_wfile_exception

/*
 * Test that the spill_file->file_info->wfile field is initialized to NULL
 * when creating a workfile throws an exception.
 */
void
test__getSpillFile__Initialize_wfile_exception(void **state)
{
	int alloc_size = 0;
	int file_no = 0;
	int branching_factor = 32;
	ExecWorkFile *ewfile = (ExecWorkFile *) palloc0(sizeof(ExecWorkFile));
	workfile_set *work_set = (workfile_set *) palloc0(sizeof(workfile_set));
	SpillSet *spill_set = (SpillSet *) palloc0(sizeof(SpillSet) + (branching_factor-1) * sizeof (SpillFile));

	volatile SpillFile *spill_file = &spill_set->spill_files[0];
	spill_file->file_info = NULL;

	/* Make workfile_mgr_create_file throw an exception, using the side effect function */
	expect_value(workfile_mgr_create_file, work_set, work_set);
	will_return_with_sideeffect(workfile_mgr_create_file, ewfile, &throw_exception_side_effect, NULL);

	PG_TRY();
	{
		/* This function will throw an exception, and we'll catch it below */
		getSpillFile(work_set, spill_set, file_no, &alloc_size);
	}
	PG_CATCH();
	{
		assert_true(spill_file->file_info != NULL);
		assert_int_equal(spill_file->file_info->total_bytes, 0);
		assert_int_equal(spill_file->file_info->ntuples, 0);
		assert_int_equal(alloc_size, 0);

		/*
		 * This is the main test: We must initialize this pointer to NULL, even
		 * if an exception is thrown
		 */
		assert_true(spill_file->file_info->wfile == NULL);
		return;
	}
	PG_END_TRY();

	/* We shouldn't get here, the getSpillFile should throw an exception */
	assert_true(false);
}
开发者ID:LJoNe,项目名称:gpdb,代码行数:45,代码来源:execHHashagg_test.c

示例9: PLy_spi_execute_query

static PyObject *
PLy_spi_execute_query(char *query, long limit)
{
	int			rv;
	volatile MemoryContext oldcontext;
	volatile ResourceOwner oldowner;
	PyObject   *ret = NULL;

	oldcontext = CurrentMemoryContext;
	oldowner = CurrentResourceOwner;

	PLy_spi_subtransaction_begin(oldcontext, oldowner);

	PG_TRY();
	{
		PLyExecutionContext	*exec_ctx = PLy_current_execution_context();

		pg_verifymbstr(query, strlen(query), false);
		rv = SPI_execute(query, exec_ctx->curr_proc->fn_readonly, limit);
		ret = PLy_spi_execute_fetch_result(SPI_tuptable, SPI_processed, rv);

		PLy_spi_subtransaction_commit(oldcontext, oldowner);
	}
	PG_CATCH();
	{
		PLy_spi_subtransaction_abort(oldcontext, oldowner);
		return NULL;
	}
	PG_END_TRY();

	if (rv < 0)
	{
		Py_XDECREF(ret);
		PLy_exception_set(PLy_exc_spi_error,
						  "SPI_execute failed: %s",
						  SPI_result_code_string(rv));
		return NULL;
	}

	return ret;
}
开发者ID:linusyang,项目名称:postgres,代码行数:41,代码来源:plpy_spi.c

示例10: pgfdw_report_error

/*
 * Report an error we got from the remote server.
 *
 * elevel: error level to use (typically ERROR, but might be less)
 * res: PGresult containing the error
 * clear: if true, PQclear the result (otherwise caller will handle it)
 * sql: NULL, or text of remote command we tried to execute
 *
 * Note: callers that choose not to throw ERROR for a remote error are
 * responsible for making sure that the associated ConnCacheEntry gets
 * marked with have_error = true.
 */
void
pgfdw_report_error(int elevel, PGresult *res, bool clear, const char *sql)
{
	/* If requested, PGresult must be released before leaving this function. */
	PG_TRY();
	{
		char	   *diag_sqlstate = PQresultErrorField(res, PG_DIAG_SQLSTATE);
		char	   *message_primary = PQresultErrorField(res, PG_DIAG_MESSAGE_PRIMARY);
		char	   *message_detail = PQresultErrorField(res, PG_DIAG_MESSAGE_DETAIL);
		char	   *message_hint = PQresultErrorField(res, PG_DIAG_MESSAGE_HINT);
		char	   *message_context = PQresultErrorField(res, PG_DIAG_CONTEXT);
		int			sqlstate;

		if (diag_sqlstate)
			sqlstate = MAKE_SQLSTATE(diag_sqlstate[0],
									 diag_sqlstate[1],
									 diag_sqlstate[2],
									 diag_sqlstate[3],
									 diag_sqlstate[4]);
		else
			sqlstate = ERRCODE_CONNECTION_FAILURE;

		ereport(elevel,
				(errcode(sqlstate),
				 message_primary ? errmsg_internal("%s", message_primary) :
				 errmsg("unknown error"),
			   message_detail ? errdetail_internal("%s", message_detail) : 0,
				 message_hint ? errhint("%s", message_hint) : 0,
				 message_context ? errcontext("%s", message_context) : 0,
				 sql ? errcontext("Remote SQL command: %s", sql) : 0));
	}
	PG_CATCH();
	{
		if (clear)
			PQclear(res);
		PG_RE_THROW();
	}
	PG_END_TRY();
	if (clear)
		PQclear(res);
}
开发者ID:42penguins,项目名称:postgres,代码行数:53,代码来源:connection.c

示例11: PLyNumber_ToJsonbValue

/*
 * PLyNumber_ToJsonbValue(PyObject *obj)
 *
 * Transform python number to JsonbValue.
 */
static JsonbValue *
PLyNumber_ToJsonbValue(PyObject *obj, JsonbValue *jbvNum)
{
	Numeric		num;
	char	   *str = PLyObject_AsString(obj);

	PG_TRY();
	{
		Datum		numd;

		numd = DirectFunctionCall3(numeric_in,
								   CStringGetDatum(str),
								   ObjectIdGetDatum(InvalidOid),
								   Int32GetDatum(-1));
		num = DatumGetNumeric(numd);
	}
	PG_CATCH();
	{
		ereport(ERROR,
				(errcode(ERRCODE_DATATYPE_MISMATCH),
				 (errmsg("could not convert value \"%s\" to jsonb", str))));
	}
	PG_END_TRY();

	pfree(str);

	/*
	 * jsonb doesn't allow NaN (per JSON specification), so we have to prevent
	 * it here explicitly.  (Infinity is also not allowed in jsonb, but
	 * numeric_in above already catches that.)
	 */
	if (numeric_is_nan(num))
		ereport(ERROR,
				(errcode(ERRCODE_NUMERIC_VALUE_OUT_OF_RANGE),
				 (errmsg("cannot convert NaN to jsonb"))));

	jbvNum->type = jbvNumeric;
	jbvNum->val.numeric = num;

	return jbvNum;
}
开发者ID:angelos93,项目名称:postgres,代码行数:46,代码来源:jsonb_plpython.c

示例12: CdbSetGucOnAllGangs

/*
 * Special for sending SET commands that change GUC variables, so they go to all
 * gangs, both reader and writer
 */
void
CdbSetGucOnAllGangs(const char *strCommand,
					bool cancelOnError, bool needTwoPhase)
{
	volatile CdbDispatcherState ds = { NULL, NULL };
	const bool	withSnapshot = true;

	elog((Debug_print_full_dtm ? LOG : DEBUG5),
		 "CdbSetGucOnAllGangs for command = '%s', needTwoPhase = %s",
		 strCommand, (needTwoPhase ? "true" : "false"));

	dtmPreCommand("CdbSetGucOnAllGangs", strCommand, NULL, needTwoPhase,
				  withSnapshot, false /* inCursor */ );

	PG_TRY();
	{
		cdbdisp_dispatchSetCommandToAllGangs(strCommand, NULL, 0, NULL, 0,
											 cancelOnError, needTwoPhase,
											 (struct CdbDispatcherState *)
											 &ds);

		/*
		 * Wait for all QEs to finish. If not all of our QEs were successful,
		 * report the error and throw up.
		 */
		cdbdisp_finishCommand((struct CdbDispatcherState *) &ds, NULL, NULL);
	}
	PG_CATCH();
	{
		/*
		 * Something happend, clean up after ourselves
		 */
		CdbCheckDispatchResult((struct CdbDispatcherState *) &ds,
							   DISPATCH_WAIT_CANCEL);

		cdbdisp_destroyDispatcherState((struct CdbDispatcherState *) &ds);

		PG_RE_THROW();
	}
	PG_END_TRY();
}
开发者ID:funnyxj,项目名称:gpdb,代码行数:45,代码来源:cdbdisp_query.c

示例13: mdver_glob_mdvsn_nuke

/*
 * Clears the contents of the entire Global MDVSN specified.
 *
 * Pinned entries are not deleted, but they are marked for removal as soon
 * as the last user releases them. Entries marked for deletion are not returned
 * as valid results during look-ups either.
 */
void
mdver_glob_mdvsn_nuke(void)
{
	Assert(NULL != mdver_glob_mdvsn);

	LWLockAcquire(MDVerWriteLock, LW_EXCLUSIVE);

	PG_TRY();
	{
		int32 num_deleted = Cache_Clear(mdver_glob_mdvsn);
		elog(gp_mdversioning_loglevel, "Nuke at Global MDVSN deleted %d entries", num_deleted);
	}
	PG_CATCH();
	{
		LWLockRelease(MDVerWriteLock);
		PG_RE_THROW();
	}
	PG_END_TRY();

	LWLockRelease(MDVerWriteLock);
}
开发者ID:PivotalBigData,项目名称:incubator-hawq,代码行数:28,代码来源:mdver_global_mdvsn.c

示例14: InstallHelper_groundwork

void InstallHelper_groundwork()
{
	Invocation ctx;
	Invocation_pushInvocation(&ctx, false);
	ctx.function = Function_INIT_WRITER;
	PG_TRY();
	{
		jstring pljlp = String_createJavaStringFromNTS(pljavaLoadPath);
		JNI_callStaticVoidMethod(
			s_InstallHelper_class, s_InstallHelper_groundwork, pljlp,
			pljavaLoadingAsExtension ? JNI_TRUE : JNI_FALSE,
			extensionExNihilo ? JNI_TRUE : JNI_FALSE);
		Invocation_popInvocation(false);
	}
	PG_CATCH();
	{
		Invocation_popInvocation(true);
		PG_RE_THROW();
	}
	PG_END_TRY();
}
开发者ID:jcflack,项目名称:pljava,代码行数:21,代码来源:InstallHelper.c

示例15: Java_org_postgresql_pljava_internal_Relation__1getName

/*
 * Class:     org_postgresql_pljava_internal_Relation
 * Method:    _getName
 * Signature: (J)Ljava/lang/String;
 */
JNIEXPORT jstring JNICALL
Java_org_postgresql_pljava_internal_Relation__1getName(JNIEnv* env, jclass clazz, jlong _this)
{
	jstring result = 0;
	Relation self = Invocation_getWrappedPointer(_this);
	if(self != 0)
	{
		BEGIN_NATIVE
		PG_TRY();
		{
			char* relName = SPI_getrelname(self);
			result = String_createJavaStringFromNTS(relName);
			pfree(relName);
		}
		PG_CATCH();
		{
			Exception_throw_ERROR("SPI_getrelname");
		}
		PG_END_TRY();
		END_NATIVE
	}
开发者ID:AnLingm,项目名称:gpdb,代码行数:26,代码来源:Relation.c


注:本文中的PG_CATCH函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。