MCPcopy Create free account
hub / github.com/FirebirdSQL/firebird / API_ROUTINE isc_create_database

Function API_ROUTINE isc_create_database

src/yvalve/why.cpp:1968–2011  ·  view source on GitHub ↗

Create a nice, squeaky clean database, uncorrupted by user data.

Source from the content-addressed store, hash-verified

1966
1967// Create a nice, squeaky clean database, uncorrupted by user data.
1968ISC_STATUS API_ROUTINE isc_create_database(ISC_STATUS* userStatus, USHORT fileLength,
1969 const TEXT* filename, isc_db_handle* publicHandle, USHORT dpbLength, const SCHAR* dpb,
1970 USHORT /*db_type*/)
1971{
1972 StatusVector status(userStatus);
1973 CheckStatusWrapper statusWrapper(&status);
1974
1975 try
1976 {
1977 nullCheck(publicHandle, isc_bad_db_handle);
1978
1979 if (!filename)
1980 status_exception::raise(Arg::Gds(isc_bad_db_format) << Arg::Str(""));
1981
1982 PathName pathName(filename, fileLength ? fileLength : fb_strlen(filename));
1983
1984 RefPtr<Dispatcher> dispatcher(FB_NEW Dispatcher);
1985
1986 dispatcher->setDbCryptCallback(&statusWrapper, TLS_GET(legacyCryptCallback));
1987 if (status.getState() & IStatus::STATE_ERRORS)
1988 return status[1];
1989
1990 ClumpletWriter newDpb(ClumpletReader::dpbList, MAX_DPB_SIZE, reinterpret_cast<const UCHAR*>(dpb), dpbLength);
1991 if (!newDpb.find(isc_dpb_sql_dialect))
1992 {
1993 newDpb.insertInt(isc_dpb_sql_dialect, 1); // legacy behavior in legacy interface
1994 dpb = reinterpret_cast<const SCHAR*>(newDpb.getBuffer());
1995 dpbLength = newDpb.getBufferLength();
1996 }
1997
1998 YAttachment* attachment = dispatcher->createDatabase(&statusWrapper, pathName.c_str(),
1999 dpbLength, reinterpret_cast<const UCHAR*>(dpb));
2000 if (status.getState() & IStatus::STATE_ERRORS)
2001 return status[1];
2002
2003 *publicHandle = attachment->getHandle();
2004 }
2005 catch (const Exception& e)
2006 {
2007 e.stuffException(&statusWrapper);
2008 }
2009
2010 return status[1];
2011}
2012
2013
2014// Register an attachment specific cleanup handler.

Callers

nothing calls this directly

Calls 15

nullCheckFunction · 0.85
raiseFunction · 0.85
GdsClass · 0.85
StrClass · 0.85
fb_strlenFunction · 0.85
setDbCryptCallbackMethod · 0.45
getStateMethod · 0.45
findMethod · 0.45
insertIntMethod · 0.45
getBufferMethod · 0.45
getBufferLengthMethod · 0.45
createDatabaseMethod · 0.45

Tested by

no test coverage detected