// *************************************************************** // * Obtain all the MV descriptor text and MV attributes // * for a specific MV UID in a specific catalog. // * // * A static SQL query is used to obtain the MV descriptor // * text rows for a specific CATALOG, system schema VERSION // * and MV UID from the system metadata. // *************************************************************** NAString* QRQueriesImpl::getMvDescriptor(const NAString& textTable, const char * uid) { _int64 objectUID = atoInt64(uid); Lng32 sqlCode = queries_->openMvDescriptorText(textTable, objectUID); assertLogAndThrow1(CAT_SQL_COMP_QR_COMMON, LL_ERROR, sqlCode==SQL_Success || sqlCode==SQL_Eof, QRDatabaseException, "Error %d performing get MV descriptor.", sqlCode); NAString* mvDescriptorText = new(heap_) NAString(heap_); Int32 buffNum = 1; while (sqlCode == SQL_Success) { sqlCode = queries_->fetchMvDescriptorText(data_); assertLogAndThrow1(CAT_SQL_COMP_QR_COMMON, LL_ERROR, sqlCode==SQL_Success || sqlCode==SQL_Eof, QRDatabaseException, "Error %d performing get MV descriptor.", sqlCode); if (sqlCode == SQL_Success) { *mvDescriptorText += data_->mvText_; } } // Always close to free up resources queries_->closeMvDescriptorText(); TrimNAStringSpace ( *mvDescriptorText // NAString &ns , FALSE // NABoolean leading , TRUE // NABoolean trailing ); return mvDescriptorText; } // End of getMvDescriptor
Int32 InputStmt::isIgnoreStmt(const char *str, NABoolean *ignoreJustThis) { if (!str) { ComASSERT(packed_string); if (ignoreJustThis) *ignoreJustThis = ignoreJustThis_; return isIgnoreStmt_; } if (ignoreJustThis) *ignoreJustThis = FALSE; if (*str != '?' && *str != '#') return 0; // These directives can only be used when running regressions. Regressions // can be run by setting the SQLMX_REGRESS environment variable. // If we are not running regressions, then execute all statements // char *ev = getenv("SQLMX_REGRESS"); // if (!ev) // return 0; NAString ns(&str[1]); TrimNAStringSpace(ns); ns.toUpper(); NABoolean ignoreAll = FALSE; NABoolean ignoreOnMX = FALSE; NABoolean ignoreOnMP = FALSE; NABoolean ignoreOnNT = FALSE; NABoolean ignoreOnLINUX = FALSE; NABoolean ignoreOnNSK = FALSE; // #ifNT -> include the input stmt on NT or LINUX platform // #ifLINUX -> include the input stme on LINUX platform // #ifNSK -> include the input stme on NSK platform if (ns == "IFMX") ignoreOnMP = TRUE; else if (ns == "IFMP") ignoreOnMX = TRUE; else if (ns == "IFNT") ignoreOnNSK = TRUE; else if (ns == "IFNTNOTLINUX") { ignoreOnNSK = TRUE; ignoreOnLINUX = TRUE; } else if (ns == "IFNSK") { ignoreOnNT = TRUE; ignoreOnLINUX = TRUE; } else if (ns == "IFLINUX") { ignoreOnNSK = TRUE; ignoreOnNT = TRUE; } else if (ns == "IGNORE") ignoreAll = TRUE; else if (*str != '#') // Only the #xxxx form is acceptable return 0; // for all future keywords we add! else if (isIfdefStmtTransition(ns, ignoreJustThis)) return -1; else return 0; if (ignoreJustThis) *ignoreJustThis = TRUE; // We are on an NSK system if (ignoreOnLINUX || ignoreOnMX) ignoreAll = TRUE; return (ignoreAll ? -1 : 0); } // isIgnoreStmt
// LCOV_EXCL_START :cnu // *************************************************************** // * Get the DEFAULT_CHARSET setting from the SYSTEM DEFAULTS TABLE // * for National character set support. // *************************************************************** CharInfo::CharSet QRQueriesImpl::getDefaultCharset() { static const char defaultCharset[] = "DEFAULT_CHARSET"; char defValue[MAX_DEFAULTS_UTF8_VALUE_IN_BYTES]; if (getSystemDefault(defaultCharset, defValue) == FALSE) return CharInfo::getCharSetEnum((const char *)"ISO88591"); // Use the default value else { NAString(defValue); TrimNAStringSpace(defValue); defValue.toUpper(); if (defValue != "ISO88591") // This will break when we allow setting DEFAULT_CHARSET { QRLogger::instance().log(CAT_SQL_COMP_QR_COMMON, LL_WARN, "The default attribute DEFAULT_CHARSET can be set to ISO88591 only. " "Its current default setting in SYSTEM_DEFAULTS is invalid: %s", defValue.toCharStar()); } return CharInfo::getCharSetEnum((const char *)"ISO88591"); } } // End of getDefaultCharset
// LCOV_EXCL_START :cnu // *************************************************************** // * Get the ISO_MAPPING setting from the SYSTEM DEFAULTS TABLE // * for National character set support. // *************************************************************** CharInfo::CharSet QRQueriesImpl::getIsoMapping() { static const char isoMapping[] = "ISO_MAPPING"; char defValue[MAX_DEFAULTS_UTF8_VALUE_IN_BYTES]; if (getSystemDefault(isoMapping, defValue) == FALSE) return CharInfo::getCharSetEnum((const char *)"ISO88591"); else { NAString(defValue); TrimNAStringSpace(defValue); defValue.toUpper(); if (defValue != "ISO88591") { QRLogger::instance().log(CAT_SQL_COMP_QR_COMMON, LL_WARN, "The default attribute ISO_MAPPING is depricated " "and can be set to ISO88591 only. " "Its current default setting in SYSTEM_DEFAULTS is invalid: %s", defValue.toCharStar()); } return CharInfo::getCharSetEnum((const char *)"ISO88591"); } } // End of getIsoMapping
// // This is the LmUtility.nativeUtils method. It takes one string as // input and produces one string as output. The output string gets // written to the first element of the String[] array object passed in // as the jobjectArray parameter. // // Although we do not document this method for customers, there is // nothing preventing customer code from calling this method. So don't // put anything in the method that you wouldn't want customers // doing. Currently this function just serves as an entry point to // various systems calls such as TMF operations and getting/setting // environment variables. There is nothing here that customers could // not do on their own if they wanted to. // JNIEXPORT void JNICALL Java_org_trafodion_sql_udr_LmUtility_nativeUtils (JNIEnv * env, jclass jc, jstring js, jobjectArray joa) { const char *input = env->GetStringUTFChars(js, NULL); if (input == NULL) { // OutOfMemory error already thrown return; } NAString action(input); TrimNAStringSpace(action); short error; NAString result("OK"); static MXStatement staticStmt; // LCOV_EXCL_START if (action.compareTo("GetTxName", NAString::ignoreCase) == 0) { Int64 transid; error = GETTRANSID((short *) &transid); if (error) { if (error == 75) { result = "No active transaction"; } else { result = "GETTRANSID returned "; result += LongToNAString((Lng32) error); } Throw(env, result.data()); } else { short actualLen; char text[256]; error = TRANSIDTOTEXT(transid, text, 255, &actualLen); if (error) { result = "TRANSIDTOTEXT returned "; result += LongToNAString((Lng32) error); Throw(env, result); } else { text[actualLen] = 0; result = text; } } } // GetTxName else if (action.compareTo("BeginTx", NAString::ignoreCase) == 0) { Int32 tag; error = BEGINTRANSACTION(&tag); if (error) { result = "BEGINTRANSACTION returned "; result += LongToNAString((Lng32) error); Throw(env, result); } } // BeginTx else if (action.compareTo("CommitTx", NAString::ignoreCase) == 0) { error = ENDTRANSACTION(); if (error) { if (error == 75) { result = "No active transaction"; } else { result = "ENDTRANSACTION returned "; result += LongToNAString((Lng32) error); } Throw(env, result); } } // CommitTx else if (action.compareTo("RollbackTx", NAString::ignoreCase) == 0) { error = ABORTTRANSACTION(); if (error) { if (error == 75) { result = "No active transaction"; } else { result = "ABORTTRANSACTION returned "; result += LongToNAString((Lng32) error); } Throw(env, result); } } // RollbackTx else if (action.compareTo("GetProcessId", NAString::ignoreCase) == 0) { Lng32 pid = GETPID(); result = LongToNAString(pid); } // GetProcessId else if (action.index("GetEnv ", 0, NAString::ignoreCase) == 0) { NAString name = action; name.remove(0, str_len("GetEnv ")); TrimNAStringSpace(name); char *value = getenv(name.data()); if (value != NULL) { result = value; } else { result = ""; } } // GetEnv else if (action.index("PutEnv ", 0, NAString::ignoreCase) == 0) { NAString nameAndValue = action; nameAndValue.remove(0, str_len("PutEnv ")); TrimNAStringSpace(nameAndValue); Int32 retcode = putenv((char *) nameAndValue.data()); if (retcode != 0) { result = "putenv returned "; result += LongToNAString((Lng32) retcode); Throw(env, result); } } // PutEnv else if (action.index("LmDebug ", 0, NAString::ignoreCase) == 0) { NAString name = action; name.remove(0, str_len("LmDebug ")); LM_DEBUG0(name.data()); } // LmDebug else if (action.index("ExecSql ", 0, NAString::ignoreCase) == 0) { NAString stmtText = action.remove(0, str_len("ExecSql ")); MXStatement s; const char *status = "OK"; Lng32 retcode = 0; retcode = s.init(status); if (retcode == 0) { retcode = s.prepare(stmtText.data()); if (retcode != 0) { status = "PREPARE failed"; } } if (retcode == 0) { retcode = s.execute(); if (retcode != 0) { status = "EXECUTE failed"; } } if (retcode == 0) { retcode = s.fetchEOD(); if (retcode != 0) { status = "FETCH failed"; } } if (retcode == 0) { retcode = s.close(); if (retcode != 0) { status = "CLOSE failed"; } } if (retcode != 0) { char msg[256]; sprintf(msg, "[UdrSqlException %d] %s", retcode, status); Throw(env, msg); } } // ExecSql else if (action.index("FetchSql ", 0, NAString::ignoreCase) == 0) { // The incoming string is SQL statement text. The code below will // prepare and execute the statement then fetch only the first // row. It will build one long multi-line string containing all // column values, one on each line. The multi-line string can be // split by the Java caller into an array of Strings with the // split("\n") method. Lng32 i; NAString stmtText = action.remove(0, str_len("FetchSql ")); MXStatement s; const char *status = "OK"; Lng32 retcode = 0; retcode = s.init(status); if (!retcode) { retcode = s.prepare(stmtText.data()); if (retcode) status = "PREPARE failed"; } if (!retcode) { retcode = s.execute(); if (retcode) status = "EXECUTE failed"; } Lng32 numOutColumns = s.getNumOutColumns(); NABoolean stringsAllocated = FALSE; char **argv = NULL; if (!retcode && numOutColumns > 0) { argv = new char *[numOutColumns]; Lng32 bufLen = 1000; for (i = 0; i < numOutColumns; i++) argv[i] = new char[bufLen + 1]; stringsAllocated = TRUE; retcode = s.fetchStrings(argv, bufLen); if (retcode) status = "FETCH STRINGS failed"; if (!retcode) { result = argv[0]; for (i = 1; i < numOutColumns; i++) { result += "\n"; result += argv[i]; } } } if (!retcode) { retcode = s.fetchEOD(); if (retcode) status = "FETCH EOD failed"; } if (!retcode) { retcode = s.close(); if (retcode) status = "CLOSE failed"; } if (stringsAllocated) { for (i = 0; i < numOutColumns; i++) delete [] argv[i]; delete [] argv; } if (retcode) { char msg[256]; sprintf(msg, "[UdrSqlException %d] %s", retcode, status); Throw(env, msg); } } // FetchSql else if (action.index("Prepare ", 0, NAString::ignoreCase) == 0) { NAString stmtText = action.remove(0, str_len("Prepare ")); const char *status = "OK"; Lng32 retcode = 0; retcode = staticStmt.init(status); if (retcode == 0) { retcode = staticStmt.prepare(stmtText.data()); if (retcode != 0) { status = "PREPARE failed"; } } if (retcode) { char msg[256]; sprintf(msg, "[UdrSqlException %d] %s", retcode, status); Throw(env, msg); } } // Prepare else if (action.index("ExecUsingString ", 0, NAString::ignoreCase) == 0) { NAString data = action.remove(0, str_len("ExecUsingString ")); const char *status = "OK"; Lng32 retcode = 0; if (retcode == 0) { retcode = staticStmt.executeUsingString(data.data(), (Lng32) data.length()); if (retcode != 0) { status = "EXECUTE failed"; } } if (retcode == 0) { retcode = staticStmt.fetchEOD(); if (retcode != 0) { status = "FETCH failed"; } } if (retcode == 0) { retcode = staticStmt.close(); if (retcode != 0) { status = "CLOSE failed"; } } if (retcode != 0) { char msg[256]; sprintf(msg, "[UdrSqlException %d] %s", retcode, status); Throw(env, msg); } } // ExecUsingString else if (action.index("FetchUsingString ", 0, NAString::ignoreCase) == 0) { NAString data = action.remove(0, str_len("FetchUsingString ")); const char *status = "OK"; Lng32 retcode = 0; Int32 i = 0; if (!retcode) { retcode = staticStmt.executeUsingString(data.data(), (Lng32) data.length()); if (retcode) status = "EXECUTE failed"; } Lng32 numOutColumns = staticStmt.getNumOutColumns(); NABoolean stringsAllocated = FALSE; char **argv = NULL; if (!retcode && numOutColumns > 0) { argv = new char *[numOutColumns]; Lng32 bufLen = 1000; for (i = 0; i < numOutColumns; i++) argv[i] = new char[bufLen + 1]; stringsAllocated = TRUE; retcode = staticStmt.fetchStrings(argv, bufLen); if (retcode) status = "FETCH STRINGS failed"; if (!retcode) { result = argv[0]; for (i = 1; i < numOutColumns; i++) { result += "\n"; result += argv[i]; } } } if (!retcode) { retcode = staticStmt.fetchEOD(); if (retcode) status = "FETCH EOD failed"; } if (!retcode) { retcode = staticStmt.close(); if (retcode) status = "CLOSE failed"; } if (stringsAllocated) { for (i = 0; i < numOutColumns; i++) delete [] argv[i]; delete [] argv; } if (retcode) { char msg[256]; sprintf(msg, "[UdrSqlException %d] %s", retcode, status); Throw(env, msg); } } // FetchUsingString else { // // Over time other operations can be supported // result = "Invalid action: "; result += action; Throw(env, result); } // LCOV_EXCL_STOP // // Create the Java output string // if (env->ExceptionCheck() == JNI_FALSE) { jobject j = env->NewStringUTF(result.data()); env->SetObjectArrayElement(joa, 0, j); } }
Int32 ValidateCollationList::validate(const char *value, const NADefaults *nad, Int32 attrEnum, Int32 errOrWarn, float *) const { if (errOrWarn) { CMPASSERT(nad && attrEnum); errOrWarn = +1; // warnings only (else silent) } // Cast away constness on various private members which are really implicit // arguments (the validate method by itself vs. from insertIntoCDB). ValidateCollationList *ncThis = (ValidateCollationList *)this; #ifndef NDEBUG if (getenv("NCHAR_DEBUG")) ncThis->formatRetry_ = TRUE; #endif // If cdb is NULL, we are validating only; if nonNULL, we are inserting. CollationDB *cdb = ncThis->cdb_; const ComMPLoc *defaultMPLoc = NULL; const SchemaName *defaultSchema = NULL; if (cdb) { CMPASSERT(sdb_); defaultMPLoc = &SqlParser_MPLOC; defaultSchema = &sdb_->getDefaultSchema(); } // Make our own copy of the value string data, // on which we can safely cast away const-ness for the loop, // which chops the list up into individual names by replacing // (in place, i.e. w/o additional copying) // each semicolon with a string-terminating nul. NAString collNAS(value); char *collList = (char *)collNAS.data(); while (*collList) { // SYNTAX OF THE MP_COLLATIONS LIST: // // The list may look like any of these: // '' (empty) // 'collname' // 'c1; sv.c2; $v.sv.c3; \s.$v.sv.c4' // 'c1; sv.c2; $v.sv.c3; \s.$v.sv.c4;' // ' = c1; =sv.c2;=$v.sv.c3;\s.$v.sv.c4;' // We also ignore pathologies like // ' ' or '=========;;;;;===; ; = = == =; ; ; ' // // The '=' flags the following collation name as one that has a 1:1 mapping, // i.e. its CPRULES.CHARACTERISTICS == 'O', // i.e. in Rel1 it allows only equality comparisons // (SQL '=', '<>', DISTINCT, GROUP BY), // although no other operations // (other predicates, ordering, MIN/MAX, partitioning) // would be disallowed -- the column wouldn't even be updatable, // but it could be at least read and appear in some limited other places. // // The absence of a '=' means the collation's CHARACTERISTICS == 'N', // and in Rel1 we cannot support *any* comparisons, predicates, MIN/MAX, // ordering, partitioning, on it -- // it's basically just a name attached to a column, // but the intent was to allow the column to be at least readable. // // See ReadTableDef and NATable to see if MP COLLATEd column support // is or is not currently being enabled. // Find the next semicolon separator outside of delim-ident quotes, // or find end of string. // Set collStr to be the fragment up to (excluding) the semicolon or zero; // set collList to be the rest of itself (after the semicolon). // // LCOV_EXCL_START :mp char *s = collList; for (NABoolean quoted = FALSE; *s; s++) { if (*s == '"') quoted = !quoted; else if (*s == ';' && !quoted) break; } char sep = *s; // sep is either ';' or '\0' *s = '\0'; NAString collStr(collList); collList = sep ? ++s : s; // get past ';' OR stay on final '\0' CollationInfo::CollationFlags flags = CollationInfo::ALL_CMP_ILLEGAL; TrimNAStringSpace(collStr); // remove leading/trailing blanks size_t i = 0, n = collStr.length(); while (i < n) if (collStr[i] == '=' || collStr[i] == ' ') i++; // get past leading '=' (and blanks) else break; if (i) { // an '=' was seen, EQ_NE_CMP is LEGAL flags = CollationInfo::ORDERED_CMP_ILLEGAL; collStr.remove(0, i); } if (!collStr.isNull()) { NABoolean ok = FALSE; NABoolean nsk = formatNSK_; NABoolean retry = formatRetry_; retry_as_other_format: if (nsk) { ComMPLoc collMP(collStr, ComMPLoc::FILE); if (collMP.isValid(ComMPLoc::FILE)) { ok = TRUE; if (cdb) { ncThis->lastCoInserted_ = cdb->insert(collMP, defaultMPLoc, flags); } } } else { ComObjectName collMX(collStr); if (collMX.isValid()) { ok = TRUE; if (cdb) { QualifiedName collQN(collMX); ncThis->lastCoInserted_ = cdb->insert(collQN, defaultSchema, flags); } } } if (ok) ncThis->cntCoParsed_++; if (!ok && retry) { retry = FALSE; // Retry only once, nsk = !nsk; // using the other name format. goto retry_as_other_format; } if (!ok && errOrWarn) *CmpCommon::diags() << DgSqlCode(ERRWARN(2055)) << DgString0(collStr) << DgString1(nad->lookupAttrName(attrEnum, errOrWarn)); // LCOV_EXCL_STOP } // !collStr.isNull() } // while return TRUE; // warnings only; all is valid }
static void SqlciEnv_prologue_to_run(SqlciEnv *sqlciEnv) { if (sqlciEnv->doneWithPrologue()) return; if (NOT sqlciEnv->noBanner()) sqlciEnv->welcomeMessage(); setupForSockets(); // If a user name was specified on the command line, call CLI to set // the database user identity. // // *** NOTE: This should always be sqlci's first CLI interaction // *** because CLI treats this operation as the beginning of a new // *** session with the compiler. Previous state in the compiler is // *** not guaranteed to persist after this interaction. // sqlciEnv->setUserIdentityInCLI(); // Suppress console messages sqlciEnv->setSpecialError(MXCI_DONOTISSUE_ERRMSGS, NULL); sqlciEnv->autoCommit(); sqlciEnv->readonlyCursors(); sqlciEnv->pertableStatistics(); sqlciEnv->generateExplain(); sqlciEnv->floattypeIEEE(); sqlciEnv->sqlmxRegress(); // see catman/CatWellKnownTables.cpp for this envvar need. char * ltmi = getenv("LOB_TEST_METADATA_INIT"); if (ltmi) { SqlCmd::executeQuery("CONTROL QUERY DEFAULT CAT_DISTRIBUTE_METADATA 'OFF';", sqlciEnv); } sqlciEnv->resetSpecialError(); // Enable break handling. SQL_EXEC_BreakEnabled_Internal (TRUE); const char* initCmd = NULL; if (initCmd) { NAString cmd(initCmd); TrimNAStringSpace(cmd); size_t len = cmd.length(); if (len > 1) { // ignore if empty or ';' or '0' or '1' or ... if (cmd[len-1] != ';') cmd += ';'; SqlCmd::executeQuery(cmd, sqlciEnv); } } // indicate that the caller is sqlci SqlCmd::executeQuery("CONTROL QUERY DEFAULT IS_SQLCI 'ON';", sqlciEnv); // Protect our startup CQDs and SET SCHEMA (from any SQL_MXCI_INITIALIZATION) // from being RESET. User may still manually alter them, of course. // SqlCmd::executeQuery("CONTROL QUERY DEFAULT * RESET RESET;", sqlciEnv); // tell CLI that datetime & interval values are to be input/output in internal format. SqlCmd::executeQuery("SET SESSION DEFAULT INTERNAL_FORMAT_IO 'ON';", sqlciEnv); // get the defaults Define::getDefaults(sqlciEnv->defaultSubvol()); // get sqlmx_terminal_charset if environment variable exists const char *termCS = getenv("SQLMX_TERMINAL_CHARSET"); if (termCS) { SetTerminalCharset setTermCS((char*)termCS); setTermCS.process(sqlciEnv); } // get the DEFAULT_CHARSET CQD default attribute sqlciEnv->retrieveDefaultCharsetViaShowControlDefault(); // get the INFER_CHARSET CQD default attribute sqlciEnv->retrieveInferCharsetViaShowControlDefault(); // undo the CQD set by DDOL while retrieving the other CQDs SqlCmd::executeQuery("CONTROL QUERY DEFAULT SHOWCONTROL_SHOW_ALL RESET;", sqlciEnv); sqlciEnv->setDoneWithPrologue(TRUE); }
short Env::process(SqlciEnv *sqlci_env) { // ## Should any of this text come from the message file, // ## i.e. from a translatable file for I18N? // When adding new variables, please keep the information in // alphabetic order Logfile *log = sqlci_env->get_logfile(); log->WriteAll("----------------------------------"); log->WriteAll("Current Environment"); log->WriteAll("----------------------------------"); bool authenticationEnabled = false; bool authorizationEnabled = false; bool authorizationReady = false; bool auditingEnabled = false; Int32 rc = sqlci_env->getAuthState(authenticationEnabled, authorizationEnabled, authorizationReady, auditingEnabled); // TDB: add auditing state log->WriteAllWithoutEOL("AUTHENTICATION "); if (authenticationEnabled) log->WriteAll("enabled"); else log->WriteAll("disabled"); log->WriteAllWithoutEOL("AUTHORIZATION "); if (authorizationEnabled) log->WriteAll("enabled"); else log->WriteAll("disabled"); log->WriteAllWithoutEOL("CURRENT DIRECTORY "); // NT_PORT (bv 10/24/96) Added NA_MAX_PATH here and in common/Platform.h log->WriteAll(getcwd((char *)NULL, NA_MAX_PATH)); log->WriteAllWithoutEOL("LIST_COUNT "); char buf[100]; Int32 len = sprintf(buf, "%u", sqlci_env->getListCount()); if (len-- > 0) if (buf[len] == 'L' || buf[len] == 'l') buf[len] = '\0'; log->WriteAll(buf); if (log->IsOpen()) { log->WriteAllWithoutEOL("LOG FILE "); log->WriteAll(log->Logname()); } else { log->WriteAll("LOG FILE"); } log->WriteAllWithoutEOL("MESSAGEFILE "); const char *mf = GetErrorMessageFileName(); log->WriteAll(mf ? mf : ""); #if 0 log->WriteAllWithoutEOL("ISO88591 MAPPING "); log->WriteAll(CharInfo::getCharSetName(sqlci_env->getIsoMappingCharset())); log->WriteAllWithoutEOL("DEFAULT CHARSET "); log->WriteAll(CharInfo::getCharSetName(sqlci_env->getDefaultCharset())); log->WriteAllWithoutEOL("INFER CHARSET "); log->WriteAll((sqlci_env->getInferCharset())?"ON":"OFF"); #endif // ## These need to have real values detected from the env and written out: // "US English" is more "politically correct" than "American English". // log->WriteAllWithoutEOL("MESSAGEFILE LANG US English\n"); log->WriteAllWithoutEOL("MESSAGEFILE VRSN "); char vmsgcode[10]; sprintf(vmsgcode, "%d", SQLERRORS_MSGFILE_VERSION_INFO); #pragma nowarn(1506) // warning elimination Error vmsg(vmsgcode, strlen(vmsgcode), Error::ENVCMD_); #pragma warn(1506) // warning elimination vmsg.process(sqlci_env); ComAnsiNamePart defaultCat; ComAnsiNamePart defaultSch; sqlci_env->getDefaultCatAndSch (defaultCat, defaultSch); CharInfo::CharSet TCS = sqlci_env->getTerminalCharset(); CharInfo::CharSet ISOMAPCS = sqlci_env->getIsoMappingCharset(); if(TCS != CharInfo::UTF8 ) { NAString dCat = defaultCat.getExternalName(); NAString dSch = defaultSch.getExternalName(); charBuf cbufCat((unsigned char*)dCat.data(), dCat.length()); charBuf cbufSch((unsigned char*)dSch.data(), dSch.length()); NAWcharBuf* wcbuf = 0; Int32 errorcode = 0; wcbuf = csetToUnicode(cbufCat, 0, wcbuf, CharInfo::UTF8, errorcode); NAString* tempstr; if (errorcode != 0){ tempstr = new NAString(defaultCat.getExternalName().data()); } else { tempstr = unicodeToChar(wcbuf->data(),wcbuf->getStrLen(), TCS, NULL, TRUE); TrimNAStringSpace(*tempstr, FALSE, TRUE); // trim trailing blanks } log->WriteAllWithoutEOL("SQL CATALOG "); log->WriteAll(tempstr->data()); // Default Schema wcbuf = 0; // must 0 out to get next call to allocate memory. wcbuf = csetToUnicode(cbufSch, 0, wcbuf, CharInfo::UTF8, errorcode); if (errorcode != 0){ tempstr = new NAString(defaultSch.getExternalName().data()); } else { tempstr = unicodeToChar(wcbuf->data(),wcbuf->getStrLen(), TCS, NULL, TRUE); TrimNAStringSpace(*tempstr, FALSE, TRUE); // trim trailing blanks } log->WriteAllWithoutEOL("SQL SCHEMA "); log->WriteAll(tempstr->data()); } else { log->WriteAllWithoutEOL("SQL CATALOG "); log->WriteAll(defaultCat.getExternalName()); log->WriteAllWithoutEOL("SQL SCHEMA "); log->WriteAll(defaultSch.getExternalName()); } // On Linux we include the database user name and user ID in the // command output NAString username; rc = sqlci_env->getExternalUserName(username); log->WriteAllWithoutEOL("SQL USER CONNECTED "); if (rc >= 0) log->WriteAll(username.data()); else log->WriteAll("?"); rc = sqlci_env->getDatabaseUserName(username); log->WriteAllWithoutEOL("SQL USER DB NAME "); if (rc >= 0) log->WriteAll(username.data()); else log->WriteAll("?"); Int32 uid = 0; rc = sqlci_env->getDatabaseUserID(uid); log->WriteAllWithoutEOL("SQL USER ID "); if (rc >= 0) sprintf(buf, "%d", (int) uid); else strcpy(buf, "?"); log->WriteAll(buf); log->WriteAllWithoutEOL("TERMINAL CHARSET "); log->WriteAll(CharInfo::getCharSetName(sqlci_env->getTerminalCharset())); Int64 transid; if (sqlci_env->statusTransaction(&transid)) { // transaction is active. char transid_str[20]; convertInt64ToAscii(transid, transid_str); log->WriteAllWithoutEOL("TRANSACTION ID "); log->WriteAll(transid_str); log->WriteAll("TRANSACTION STATE in progress"); } else { log->WriteAll("TRANSACTION ID "); log->WriteAll("TRANSACTION STATE not in progress"); } if (log->isVerbose()) log->WriteAll("WARNINGS on"); else log->WriteAll("WARNINGS off"); return 0; }
// default constructor ElemDDLUdrExternalPath::ElemDDLUdrExternalPath(NAString &thePath) : ElemDDLNode(ELM_UDR_EXTERNAL_PATH), externalPath_(thePath) { TrimNAStringSpace(externalPath_); }