Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error in example of using new shutdown modes in FB 2 [DOC32] #41

Closed
firebird-automations opened this issue Aug 13, 2008 · 3 comments
Closed

Comments

@firebird-automations
Copy link

Submitted by: Konstantin Dombrugov (abracadabra)

Release Notes FB 2.* -> Changes to the Firebird API and ODS -> API (Application Programming Interface) -> 'Accommodation of New Shutdown <state> Parameters' -> Example of Use in C/C++

char dpb_buffer[256], *dpb, *p;
ISC_STATUS status_vector[ISC_STATUS_LENGTH];
isc_db_handle handle = NULL;
dpb = dpb_buffer;
*dpb++ = isc_dpb_version1;
const char* user_name = "SYSDBA";
const int user_name_length = strlen(user_name);
*dpb++ = isc_dpb_user_name;
*dpb++ = user_name_length;
memcpy(dpb, user_name, user_name_length);
dpb += user_name_length;
const char* user_password = "masterkey";
const int user_password_length = strlen(user_password);
*dpb++ = isc_dpb_password;
*dpb++ = user_password_length;
memcpy(dpb, user_password, user_password_length);
dpb += user_password_length;
// Force an immediate full database shutdown
*dpb++ = isc_dpb_shutdown;

//THERE IT IS!! it's a length of the following value__________________________________________________
*dpb++ = 1;
//

*dpb++ = isc_dpb_shut_force | isc_dpb_shut_full;
const int dpb_length = dpb - dpb_buffer;
isc_attach_database(status_vector,
0, "employee.db",
&handle,
dpb_length, dpb_buffer);
if (status_vector[0] == 1 && status_vector[1])
{
isc_print_status(status_vector);
}
else
{
isc_detach_database(status_vector, &handle);
}

I wasn't familiar with ClumpetWriter, but I am now :( I just wanted to improve delphi component using this example .. 2 hours of 'WTF?!'s till I explored FB source code.

@firebird-automations
Copy link
Author

Modified by: @paulvink

assignee: Paul Vinkenoog [ paulvink ] => Helen Borrie [ helebor ]

@firebird-automations
Copy link
Author

Commented by: @helebor

Would the OP like to explain what the bug is, please?

@firebird-automations
Copy link
Author

Commented by: Konstantin Dombrugov (abracadabra)

sorry, I were nervous
there is a mistake in example of using new shutdown modes in release notes to FB 2.*

was:
*dpb++ = isc_dpb_shutdown;
*dpb++ = isc_dpb_shut_force | isc_dpb_shut_full;

must be:
*dpb++ = isc_dpb_shutdown;
*dpb++ = 1;
*dpb++ = isc_dpb_shut_force | isc_dpb_shut_full;

why:
after command (isc_dpb_shutdown) if it has argument (isc_dpb_shut_force | isc_dpb_shut_full) a length of this argument (1 byte) must be placed in buffer before argument.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants