コード例 #1
0
ファイル: logtape.c プロジェクト: BenjaminYu/gpdb
/*
 * Creates a LogicalTapeSet with a given name.
 *
 * Note: Requires the pgsql_tmp/ directory to be part of the prefix
 */
static LogicalTapeSet *
LogicalTapeSetCreate_Named(const char *set_prefix, int ntapes, bool del_on_close)
{
	LogicalTapeSet *lts = LogicalTapeSetCreate_Internal(ntapes);
	lts->pfile = ExecWorkFile_Create(set_prefix, BUFFILE, del_on_close, 0 /* compressType */);
	return lts;
}
コード例 #2
0
ファイル: execWorkfile_test.c プロジェクト: AnLingm/gpdb
/*
 * Test that the ExecWorkFile struct is allocated in TopMemoryContext
 */
void
test__ExecWorkFile_Create__InTopMemContext(void **state)
{
	char *test_filename = "foo";

	will_return(WorkfileQueryspace_AddWorkfile, true);

	expect_value(BufFileCreateFile, fileName, test_filename);
	expect_value(BufFileCreateFile, delOnClose, true);
	expect_value(BufFileCreateFile, interXact, false);
	will_return(BufFileCreateFile, NULL);

	expect_value(BufFileSetWorkfile, buffile, NULL);
	will_be_called(BufFileSetWorkfile);
	/*
	 * Create a new memory context, so that we can distinguish it from
	 * TopMemoryContext.
	 */
	CurrentMemoryContext =
	  AllocSetContextCreate(TopMemoryContext,
				"mock test context",
				ALLOCSET_DEFAULT_MINSIZE,
				ALLOCSET_DEFAULT_INITSIZE,
				ALLOCSET_DEFAULT_MAXSIZE);

	/*
	 * ExecWorkFile_Create will call our mocked palloc0 function execWorkfile__palloc0_mock
	 * and our mocked pstrdup function execWorkfile_pstrdup_mock.
	 * These functions will assert that the allocation of the result happens
	 * in the TopMemoryContext.
	 */
	ExecWorkFile *ewf = ExecWorkFile_Create(test_filename, BUFFILE, true /* delOnClose */, 0 /* compressType */);

}
コード例 #3
0
/*
 * ExecWorkFile_CreateUnique
 *   create a new work file with specified name, type and compression
 *   In addition, it adds a unique suffix
 */
ExecWorkFile *
ExecWorkFile_CreateUnique(const char *filename,
		ExecWorkFileType fileType,
		bool delOnClose,
		int compressType)
{

	StringInfo uniquename = ExecWorkFile_AddUniqueSuffix(filename);
	ExecWorkFile *ewf = ExecWorkFile_Create(uniquename->data, fileType, delOnClose, compressType);
	pfree(uniquename->data);
	pfree(uniquename);

	return ewf;
}
コード例 #4
0
/*
 * Creates a new numbered workfile in a given set
 *
 *  The given file_no is used to generate the file name
 */
ExecWorkFile *
workfile_mgr_create_fileno(workfile_set *work_set, uint32 file_no)
{
	Assert(NULL != work_set);

	char file_name[MAXPGPATH];
	retrieve_file_no(work_set, file_no, file_name, sizeof(file_name));
	bool del_on_close = !work_set->can_be_reused;

	ExecWorkFile *ewfile = ExecWorkFile_Create(file_name,
			work_set->metadata.type,
			del_on_close,
			work_set->metadata.bfz_compress_type);

	ExecWorkfile_SetWorkset(ewfile, work_set);

	return ewfile;
}
コード例 #5
0
ファイル: workfile_file.c プロジェクト: CraigHarris/gpdb
/*
 * Creates a new numbered workfile in a given set
 *
 *  The given file_no is used to generate the file name
 */
ExecWorkFile *
workfile_mgr_create_fileno(workfile_set *work_set, uint32 file_no)
{
	Assert(NULL != work_set);

	char file_name[MAXPGPATH];
	retrieve_file_no(work_set, file_no, file_name, sizeof(file_name));

	ExecWorkFile *ewfile = ExecWorkFile_Create(file_name,
			work_set->metadata.type,
			true /* del_on_close */,
			work_set->metadata.bfz_compress_type);

	SIMPLE_FAULT_INJECTOR(WorkfileCreationFail);

	ExecWorkfile_SetWorkset(ewfile, work_set);

	return ewfile;
}