Repository: trafodion Updated Branches: refs/heads/master 84bb7c03c -> 449572de3
fix trafodion-2955 Project: http://git-wip-us.apache.org/repos/asf/trafodion/repo Commit: http://git-wip-us.apache.org/repos/asf/trafodion/commit/7eecb50b Tree: http://git-wip-us.apache.org/repos/asf/trafodion/tree/7eecb50b Diff: http://git-wip-us.apache.org/repos/asf/trafodion/diff/7eecb50b Branch: refs/heads/master Commit: 7eecb50b7cac562b26fe1bd48ff64ee7f21a6349 Parents: 622e67b Author: SuJinpei <[email protected]> Authored: Tue Feb 6 11:18:22 2018 +0800 Committer: SuJinpei <[email protected]> Committed: Tue Feb 6 11:18:22 2018 +0800 ---------------------------------------------------------------------- core/conn/odb/src/odb.c | 43 ++++++++++++++++++++++++++----------------- 1 file changed, 26 insertions(+), 17 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/trafodion/blob/7eecb50b/core/conn/odb/src/odb.c ---------------------------------------------------------------------- diff --git a/core/conn/odb/src/odb.c b/core/conn/odb/src/odb.c index 5f8db45..4ba4bcc 100755 --- a/core/conn/odb/src/odb.c +++ b/core/conn/odb/src/odb.c @@ -13417,27 +13417,36 @@ static int runsql(int tid, int eid, int ten, char *script) line = l ; } strmcpy ( line, (char *)Ocmd, j ); - if ( !strmicmp(line, "odb ", 4) ) { - snprintf((char *)Ocmd, bs, "%s -u %s -p %s %s%s %s%s %s", - odbcmd, (char *)Ouser, (char *)Opwd, Odsn[0] ? "-d " : "", Odsn[0] ? (char *)Odsn : "", - clca ? "-ca" : "", clca ? clca : "", line + 4 ); + // eliminate left spaces + unsigned int alphaIndex = 0; + while (alphaIndex < j && (line[alphaIndex] == ' ' || line[alphaIndex] == '\t')) ++alphaIndex; + + if (alphaIndex != j) { // skip blank line + if (!strmicmp(line, "odb ", 4)) { + snprintf((char *)Ocmd, bs, "%s -u %s -p %s %s%s %s%s %s", + odbcmd, (char *)Ouser, (char *)Opwd, Odsn[0] ? "-d " : "", Odsn[0] ? (char *)Odsn : "", + clca ? "-ca" : "", clca ? clca : "", line + 4); #ifdef _WIN32 - _spawnlp(_P_WAIT, "cmd.exe", "cmd.exe", "/c", var_exp((char *)Ocmd, &bs, &thps[tid].tva), NULL); + _spawnlp(_P_WAIT, "cmd.exe", "cmd.exe", "/c", var_exp((char *)Ocmd, &bs, &thps[tid].tva), NULL); #else - if ( system((const char *)var_exp((char *)Ocmd, &bs, &thps[tid].tva)) < 0 ) - fprintf(stderr, "odb [runsql(%d)] - Error running %s\n", __LINE__, &Ocmd[1]); + if (system((const char *)var_exp((char *)Ocmd, &bs, &thps[tid].tva)) < 0) + fprintf(stderr, "odb [runsql(%d)] - Error running %s\n", __LINE__, &Ocmd[1]); #endif - j = 0; - } else { - nrag = tokenize ( line, j, rag ); - if ( nrag && !strmicmp(rag[0], "set", 0) ) { - setan ( eid, tid, nrag, rag, ql ); - j = 0; - } else if ( !strmicmp(rag[0], "print", 0 ) ) { - var_exp (nrag ? rag[1] : "", 0, &thps[0].tva); j = 0; - } else { - Ocmd[j++] = (SQLCHAR)ch; + } + else { + nrag = tokenize(line, j, rag); + if (nrag && !strmicmp(rag[0], "set", 0)) { + setan(eid, tid, nrag, rag, ql); + j = 0; + } + else if (!strmicmp(rag[0], "print", 0)) { + var_exp(nrag ? rag[1] : "", 0, &thps[0].tva); + j = 0; + } + else { + Ocmd[j++] = (SQLCHAR)ch; + } } } }
