/* * GUC array: mix of PGC_USERSET, PGC_POSTMASTER, PGC_SUSET * return ArrayType contains non-PGC_USERSET */ void test__GUCArrayReset__mix_guc(void **state) { ArrayType *in; ArrayType *out; Datum d; List *guc_list; int elems; build_guc_variables(); will_return(superuser, false); /* construct text array */ elems = 4; guc_list = list_make4("password_encryption=on", "log_error_verbosity=verbose", "application_name=mixtest", "allow_system_table_mods=dml"); in = create_guc_array(guc_list, elems); out = GUCArrayReset(in); assert_not_null(out); assert_int_equal(ARR_DIMS(out)[0], 1); d = PointerGetDatum(ARR_DATA_PTR(out)); assert_int_equal(strlen("log_error_verbosity=verbose"), VARLEN(d)); assert_memory_equal(VARDATA(d), "log_error_verbosity=verbose", VARLEN(d)); list_free(guc_list); pfree(in); pfree(out); }
/* * GUC array: 2-dim array * return NULL */ void test__GUCArrayReset__md_array(void **state) { ArrayType *in; List *guc_list; int elems; int ndims; build_guc_variables(); will_return(superuser, false); /* construct 2-dimension text array */ elems = 2; ndims = 2; guc_list = list_make4("gp_log_format=text", "allow_system_table_mods=ddl", "password_encryption=on", "log_error_verbosity=verbose"); in = create_md_guc_array(guc_list, elems, ndims); assert_null(GUCArrayReset(in)); list_free(guc_list); pfree(in); }
/* * SetRangeTblExtraData adds additional data to a RTE, overwriting previous * values, if present. * * The data is stored as RTE_FUNCTION type RTE of a special * citus_extradata_container function, with the extra data serialized into the * function arguments. That works, because these RTEs aren't used by Postgres * to any significant degree, and Citus' variant of ruleutils.c knows how to * deal with these extended RTEs. Note that rte->eref needs to be set prior * to calling SetRangeTblExtraData to ensure the funccolcount can be set * correctly. * * NB: If used for postgres defined RTEKinds, fields specific to that RTEKind * will not be handled by out/readfuncs.c. For the current uses that's ok. */ void SetRangeTblExtraData(RangeTblEntry *rte, CitusRTEKind rteKind, char *fragmentSchemaName, char *fragmentTableName, List *tableIdList) { RangeTblFunction *fauxFunction = NULL; FuncExpr *fauxFuncExpr = NULL; Const *rteKindData = NULL; Const *fragmentSchemaData = NULL; Const *fragmentTableData = NULL; Const *tableIdListData = NULL; Assert(rte->eref); /* store RTE kind as a plain int4 */ rteKindData = makeNode(Const); rteKindData->consttype = INT4OID; rteKindData->constlen = 4; rteKindData->constvalue = Int32GetDatum(rteKind); rteKindData->constbyval = true; rteKindData->constisnull = false; rteKindData->location = -1; /* store the fragment schema as a cstring */ fragmentSchemaData = makeNode(Const); fragmentSchemaData->consttype = CSTRINGOID; fragmentSchemaData->constlen = -2; fragmentSchemaData->constvalue = CStringGetDatum(fragmentSchemaName); fragmentSchemaData->constbyval = false; fragmentSchemaData->constisnull = fragmentSchemaName == NULL; fragmentSchemaData->location = -1; /* store the fragment name as a cstring */ fragmentTableData = makeNode(Const); fragmentTableData->consttype = CSTRINGOID; fragmentTableData->constlen = -2; fragmentTableData->constvalue = CStringGetDatum(fragmentTableName); fragmentTableData->constbyval = false; fragmentTableData->constisnull = fragmentTableName == NULL; fragmentTableData->location = -1; /* store the table id list as an array of integers: FIXME */ tableIdListData = makeNode(Const); tableIdListData->consttype = CSTRINGOID; tableIdListData->constbyval = false; tableIdListData->constlen = -2; tableIdListData->location = -1; /* serialize tableIdList to a string, seems simplest that way */ if (tableIdList != NIL) { char *serializedList = nodeToString(tableIdList); tableIdListData->constisnull = false; tableIdListData->constvalue = CStringGetDatum(serializedList); } else { tableIdListData->constisnull = true; } /* create function expression to store our faux arguments in */ fauxFuncExpr = makeNode(FuncExpr); fauxFuncExpr->funcid = CitusExtraDataContainerFuncId(); fauxFuncExpr->funcretset = true; fauxFuncExpr->location = -1; fauxFuncExpr->args = list_make4(rteKindData, fragmentSchemaData, fragmentTableData, tableIdListData); fauxFunction = makeNode(RangeTblFunction); fauxFunction->funcexpr = (Node *) fauxFuncExpr; /* set the column count to pass ruleutils checks, not used elsewhere */ fauxFunction->funccolcount = list_length(rte->eref->colnames); rte->rtekind = RTE_FUNCTION; rte->functions = list_make1(fauxFunction); }