diff --git a/contrib/dolphin/plugin_protocol/handler.cpp b/contrib/dolphin/plugin_protocol/handler.cpp index db0b57f3205039c383f476f9c09b79d8f8bea4d6..e0e1febf38f332036b357f4828c200487b4f0713 100644 --- a/contrib/dolphin/plugin_protocol/handler.cpp +++ b/contrib/dolphin/plugin_protocol/handler.cpp @@ -400,8 +400,7 @@ int execute_com_stmt_prepare(const char *client_sql) rc = SPI_execute(sql->data, false, 0); PreparedStatement *pstmt = FetchPreparedStatement(stmt_name, true, true); - Query *query = (Query *)linitial(pstmt->plansource->query_list); - int column_count = list_length(query->targetList); + int column_count = pstmt->plansource->resultDesc == NULL ? 0 : pstmt->plansource->resultDesc->natts; int param_count = pstmt->plansource->num_params; StringInfo buf = makeStringInfo(); @@ -422,7 +421,7 @@ int execute_com_stmt_prepare(const char *client_sql) dolphin_column_definition* column_field = make_dolphin_column_definition(""); send_column_definition41_packet(buf, column_field); } - if (!(GetSessionContext()->Conn_Mysql_Info->client_capabilities & CLIENT_DEPRECATE_EOF)) { + if (column_count != 0 && !(GetSessionContext()->Conn_Mysql_Info->client_capabilities & CLIENT_DEPRECATE_EOF)) { send_network_eof_packet(buf); } diff --git a/contrib/dolphin/plugin_utils/adt/ri_triggers.cpp b/contrib/dolphin/plugin_utils/adt/ri_triggers.cpp index fcf998b72ca0fba8bc39fb5daf2470042586d5bf..08005ab2215109e65fd0da2d5da8c7db1691cbf1 100644 --- a/contrib/dolphin/plugin_utils/adt/ri_triggers.cpp +++ b/contrib/dolphin/plugin_utils/adt/ri_triggers.cpp @@ -246,6 +246,12 @@ static Datum RI_FKey_check(PG_FUNCTION_ARGS) SPIPlanPtr qplan; int i; +#ifdef DOLPHIN + if (!u_sess->attr.attr_common.foreign_key_checks) { + return PointerGetDatum(NULL); + } +#endif + #ifdef PGXC /* * Referential integrity is not supported on Coordinator as it has no data, so @@ -2861,6 +2867,12 @@ static bool ri_PerformCheck(RI_QueryKey* qkey, SPIPlanPtr qplan, Relation fk_rel Datum vals[RI_MAX_NUMKEYS * 2]; char nulls[RI_MAX_NUMKEYS * 2]; +#ifdef DOLPHIN + if (!u_sess->attr.attr_common.foreign_key_checks) { + return true; + } +#endif + /* * The query is always run against the FK table except when this is an * update/insert trigger on the FK table itself - either @@ -2937,14 +2949,13 @@ static bool ri_PerformCheck(RI_QueryKey* qkey, SPIPlanPtr qplan, Relation fk_rel if (spi_result < 0) ereport(ERROR, (errcode(ERRCODE_SPI_EXECUTE_FAILURE), errmsg("SPI_execute_snapshot returned %d", spi_result))); - if (expect_OK >= 0 && spi_result != expect_OK && u_sess->attr.attr_common.foreign_key_checks) + if (expect_OK >= 0 && spi_result != expect_OK) ri_ReportViolation( qkey, constrname ? constrname : "", pk_rel, fk_rel, new_tuple ? new_tuple : old_tuple, NULL, true); /* XXX wouldn't it be clearer to do this part at the caller? */ if (constrname != NULL && expect_OK == SPI_OK_SELECT && - (SPI_processed == 0) == (qkey->constr_queryno == RI_PLAN_CHECK_LOOKUPPK) && - u_sess->attr.attr_common.foreign_key_checks) + (SPI_processed == 0) == (qkey->constr_queryno == RI_PLAN_CHECK_LOOKUPPK)) ri_ReportViolation(qkey, constrname, pk_rel, fk_rel, new_tuple ? new_tuple : old_tuple, NULL, false); return SPI_processed != 0;