📄 isql.e
字号:
if (FDIM.RDB$DIMENSION > 0) { ISQL_printf (Out, ", "); } sprintf (Print_buffer, "%ld:%ld", FDIM.RDB$LOWER_BOUND, FDIM.RDB$UPPER_BOUND); ISQL_printf (Out, Print_buffer);END_FOR ON_ERROR ISQL_errmsg (isc_status); return; END_ERROR;ISQL_printf (Out, "] ");}SCHAR *ISQL_blankterm ( TEXT *str){/************************************** * * I S Q L _ b l a n k t e r m * ************************************** * * Functional description * Trim any trailing spaces off a string; * eg: find the last non blank in the string and insert * a null byte after that. * * SQL delimited identifier may have blank as part of the name * * Parameters: str - the string to terminate * Returns: str * **************************************/TEXT *p, *q;/* Scan to the end-of-string, record position of last non-blank seen */q = str-1;for (p = str; *p; p++) { if (*p != BLANK) q = p; }*(q+1) = '\0';return str;}BOOLEAN ISQL_dbcheck (void){/************************************** * * I S Q L _ d b c h e c k * ************************************** * * Functional description * Check to see if we are connected to a database. * Return TRUE if connected, FALSE otherwise * **************************************/TEXT errbuf [MSG_LENGTH];if (!Db_name[0]) { if (!Quiet) { gds__msg_format (NULL_PTR, ISQL_MSG_FAC, NO_DB, sizeof (errbuf), errbuf, NULL_PTR, NULL_PTR, NULL_PTR, NULL_PTR, NULL_PTR); STDERROUT (errbuf, 1);#ifdef GUI_TOOLS /* * This will force an extra carriage return line feed for better * formatting of errors when executing a script through windows ISQL. * The Merge_stderr flag is only set when scripts are running. */ if (Merge_stderr) ISQL_printf(Out, NEWLINE);#endif } else Exit_value = FINI_ERROR; return FALSE; }else return TRUE;}void ISQL_prompt ( TEXT *string){/************************************** * * I S Q L _ p r o m p t * ************************************** * * Functional description * Print a prompt string for interactive user * Not for Windows, otherwise flush the string **************************************/#ifndef GUI_TOOLSib_fprintf (ib_stdout, string);ib_fflush (ib_stdout);#endif}#ifdef GUI_TOOLSint ISQL_commit_work ( int response, IB_FILE *ipf, IB_FILE *opf, IB_FILE *sf){/************************************** * * I S Q L _ c o m m i t _ w o r k * ************************************** * * Functional description * If response = WISQL_RESPONSE_YES then commit work. * If response = WISQL_RESPONSE_NO rollback. * **************************************/ISC_STATUS ret_code;Out = opf;Ifp = ipf;Diag = Out;Help = Out;ret_code = 0;/* * Commit transaction that was started on behalf of the request * Don't worry about the error if one occurs it will be network * related and caught later. */if (gds__trans) isc_rollback_transaction (isc_status, &gds__trans);if (response == WISQL_RESPONSE_NO) { /* add command to command history file */ ib_fprintf (sf, "%s%s%s", "Rollback", Term, NEWLINE); ib_fflush (sf); if (D__trans) if (ret_code = isc_rollback_transaction (isc_status, &D__trans)) ISQL_errmsg (isc_status); if (M__trans && !ret_code) if (ret_code = isc_rollback_transaction (isc_status, &M__trans)) ISQL_errmsg (isc_status); if (!D__trans && !M__trans && !ret_code) { ISQL_printf (Out, "Work Rolled Back"); ISQL_printf (Out, NEWLINE); } }else { /* add command to command history file */ ib_fprintf (sf, "%s%s%s", "Commit", Term, NEWLINE); ib_fflush (sf); if (D__trans) if (ret_code = isc_commit_transaction (isc_status, &D__trans)) ISQL_errmsg (isc_status); if (M__trans && !ret_code) if (ret_code = isc_commit_transaction (isc_status, &M__trans)) ISQL_errmsg (isc_status); if (!D__trans && !M__trans && !ret_code) { ISQL_printf (Out, "Work Committed"); ISQL_printf (Out, NEWLINE); } }return ((int) ret_code);}#endifvoid ISQL_copy_SQL_id ( TEXT *in_str, TEXT *output_str, TEXT escape_char){/************************************** * * I S Q L _ c o p y _ S Q L _ i d * ************************************** * * Functional description * * Copy/rebuild the SQL identifier by adding escape double quote if * double quote is part of the SQL identifier and wraps around the * SQL identifier with delimited double quotes * **************************************/TEXT *p1, *q1;/* CVC: Try to detect if we can get rid of double quotes asrequested by Ann. Notice empty names need double quotes.Assume the caller invoked previously ISQL_blankterm() that'sjust another function like DYN_terminate, MET_exact_name, etc. */if (escape_char == DBL_QUOTE){ /* Cannot rely on ANSI functions that may be localized. */ BOOLEAN need_quotes = *in_str < 'A' || *in_str > 'Z'; q1 = output_str; for (p1 = in_str; *p1 && !need_quotes; ++p1, ++q1) { if ((*p1 < 'A' || *p1 > 'Z') && (*p1 < '0' || *p1 > '9') && *p1 != '_' && *p1 != '$') need_quotes = TRUE; *q1 = *p1; } if (!need_quotes) { CONST TOK_NAME *tok_ptr = tokens; while (tok_ptr -> tok_string && !need_quotes) { if (!strcmp(tok_ptr -> tok_string, in_str)) need_quotes = TRUE; ++tok_ptr; } if (!need_quotes) { *q1 = '\0'; return; } }}q1 = output_str;*q1++ = escape_char;for (p1 = in_str; *p1; p1++){ *q1++ = *p1; if (*p1 == escape_char) *q1++ = escape_char;}*q1++ = escape_char;*q1 = '\0';}void ISQL_errmsg ( STATUS *status){/************************************** * * I S Q L _ e r r m s g * ************************************** * * Functional description * Report error conditions * Simulate isc_print_status exactly, to control ib_stderr * Shortcut for the next function, using global line = zero. **************************************/ ISQL_errmsg2 (status, 0);}void ISQL_errmsg2 ( STATUS *status, ULONG gcount){/************************************** * * I S Q L _ e r r m s g 2 * ************************************** * * Functional description * Report error conditions * Simulate isc_print_status exactly, to control ib_stderr * The gcount parameter gives the global line in a script. **************************************/TEXT errbuf [MSG_LENGTH];TEXT script_msg [BUFFER_LENGTH80] = "";STATUS *vec;#if defined (WIN95) && !defined (GUI_TOOLS)#define TRANSLATE_CP if (!fAnsiCP) AnsiToOem(errbuf, errbuf)#else#define TRANSLATE_CP#endifvec = status;if (Quiet) Exit_value = FINI_ERROR;else { if (vec[0] != gds_arg_gds || (vec[0] == gds_arg_gds && vec[1] == 0 && vec[2] != gds_arg_warning) || (vec[0] == gds_arg_gds && vec[1] == 0 && vec[2] == gds_arg_warning && !Warnings)) return; gds__msg_format (NULL_PTR, ISQL_MSG_FAC, 0, sizeof (errbuf), errbuf, (TEXT*) isc_sqlcode (status), NULL_PTR, NULL_PTR, NULL_PTR, NULL_PTR);#ifndef GUI_TOOLS TRANSLATE_CP; STDERROUT (errbuf, 1);#else buffer_error_msg (errbuf, WISQL_SHORTMSG);#endif isc_interprete (errbuf, &vec);#ifndef GUI_TOOLS TRANSLATE_CP; STDERROUT (errbuf, 1);#else buffer_error_msg (errbuf, WISQL_DETAILEDMSG); buffer_error_msg (NEWLINE, WISQL_DETAILEDMSG);#endif /* Continuation of error */ errbuf [0] = '-'; while (isc_interprete (errbuf + 1, &vec)) {#ifndef GUI_TOOLS TRANSLATE_CP; STDERROUT (errbuf, 1); if (!*script_msg) compute_script_position (errbuf, gcount, FALSE, script_msg);#else buffer_error_msg (errbuf, WISQL_DETAILEDMSG); buffer_error_msg (NEWLINE, WISQL_DETAILEDMSG);#endif }#ifdef GUI_TOOLS /* * This will force an extra carriage return line feed for better * formatting of errors when executing a script through windows * ISQL. The Merge_stderr flag is only set when scripts are * running. */ if (Merge_stderr) ISQL_printf(Out, NEWLINE); /* Show the error dialog */ wisqlerr ();#else if (*script_msg) { STDERROUT (script_msg, 1); } else { compute_script_position ("", gcount, TRUE, script_msg); STDERROUT (script_msg, 1); }#endif }}void ISQL_warning ( STATUS *status){/************************************** * * I S Q L _ w a r n i n g * ************************************** * * Functional desription * Report warning * Simulate isc_print_status exactly, to control ib_stderr * Shortcut for the next function, using global line = zero. **************************************/ ISQL_warning (status, 0);}void ISQL_warning2 ( STATUS *status, ULONG gcount){/************************************** * * I S Q L _ w a r n i n g 2 * ************************************** * * Functional desription * Report warning * Simulate isc_print_status exactly, to control ib_stderr * The gcount parameter gives the global line in a script. **************************************/TEXT errbuf [MSG_LENGTH];TEXT script_msg [BUFFER_LENGTH80] = "";STATUS *vec;#if !defined (TRANSLATE_CP)#if defined (WIN95) && !defined (GUI_TOOLS)#define TRANSLATE_CP if (!fAnsiCP) AnsiToOem(errbuf, errbuf)#else#define TRANSLATE_CP#endif#endifvec = status;assert (vec[1] == 0); /* shouldn't be any errors */if (!Quiet) { if (vec[0] != gds_arg_gds || vec[2] != gds_arg_warning || (vec[2] == gds_arg_warning && !Warnings)) return; isc_interprete (errbuf, &vec);#ifndef GUI_TOOLS TRANSLATE_CP; STDERROUT (errbuf, 1);#else buffer_error_msg (errbuf, WISQL_DETAILEDMSG); buffer_error_msg (NEWLINE, WISQL_DETAILEDMSG);#endif /* Continuation of warning */ errbuf [0] = '-'; while (isc_interprete (errbuf + 1, &vec)) {#ifndef GUI_TOOLS TRANSLATE_CP; STDERROUT (errbuf, 1); if (!*script_msg) compute_script_position (errbuf, gcount, FALSE, script_msg);#else buffer_error_msg (errbuf, WISQL_DETAILEDMSG); buffer_error_msg (NEWLINE, WISQL_DETAILEDMSG);#endif }#ifdef GUI_TOOLS /* * This will force an extra carriage return line feed for better * formatting of errors when executing a script through windows * ISQL. The Merge_stderr flag is only set when scripts are * running. */ if (Merge_stderr) ISQL_printf(Out, NEWLINE); /* Show the error dialog */ wisqlerr ();#else if (*script_msg) { STDERROUT (script_msg, 1); } else { compute_script_position ("", gcount, TRUE, script_msg); STDERROUT (script_msg, 1); }#endif }status[2] = gds_arg_end;}#ifdef GUI_TOOLSvoid ISQL_exit_db (void){/************************************** * * I S Q L _ e x i t _ d b * ************************************** * * Functional description * Detach from the database. * **************************************/if (D__trans) isc_rollback_transaction (isc_status, &D__trans);if (M__trans) isc_rollback_transaction (isc_status, &M__trans);if (gds__trans) isc_rollback_transaction (isc_status, &gds__trans);if (Stmt) isc_dsql_free_statement (isc_status, &Stmt, DSQL_drop);if (DB) isc_detach_database (isc_status, &DB);DB = NULL;Db_name[0] = '\0';D__trans = NULL;M__trans = NULL;gds__trans = NULL;Stmt = NULL;if (sqlda) ISQL_FREE (sqlda);}#endif#ifdef GUI_TOOLSint ISQL_frontend_command ( TEXT *string, IB_FILE *ipf, IB_FILE *opf, IB_FILE *sf){/************************************** * * I S Q L _ f r o n t e n d _ c o m m a n d * ************************************** * * Functional description * Process a frontend command for Windows ISQL. This sets up * the input and output files, and executes the statement. * **************************************/SSHORT ret;SCHAR *endpassword, savechar;int length;SSHORT connect_stmt;Out = opf;Ifp = ipf;Diag = Out;Help = Out;connect_stmt = FALSE;if (strncmp (string, WISQL_CONNECT_LITERAL, strlen(WISQL_CONNECT_LITERAL))) { /* add command to command history file */ ib_fprintf (sf, "%s%s%s", string, Term, NEWLINE); ib_fflush (sf); if (strcmp (string, WISQL_DROP_DATABASE_LITERAL)) { /* Echo string to Output */ ISQL_printf (Out, string);
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -