diff options
author | Jörg Frings-Fürst <debian@jff-webhosting.net> | 2023-03-11 18:15:40 +0100 |
---|---|---|
committer | Jörg Frings-Fürst <debian@jff-webhosting.net> | 2023-03-11 18:15:40 +0100 |
commit | 82f6dc9f22dded1754b36b00e34e0d6806c2a55e (patch) | |
tree | 5cbcd7f9ffa01d6024fb5d2f2b5d435b5b4c7577 /src/sql/xbcrtbl.cpp | |
parent | 76f06edcf417fea572c0c0d2240ada4f377267ea (diff) | |
parent | dd70ff8bf32c2d7ed365004b1770058265db1978 (diff) |
Update upstream source from tag 'upstream/4.1.0'
Update to upstream version '4.1.0'
with Debian dir 668270cd298c590544bcaef85759fa4c7f5afc6e
Diffstat (limited to 'src/sql/xbcrtbl.cpp')
-rwxr-xr-x | src/sql/xbcrtbl.cpp | 49 |
1 files changed, 30 insertions, 19 deletions
diff --git a/src/sql/xbcrtbl.cpp b/src/sql/xbcrtbl.cpp index 7f6b8fa..dfb3403 100755 --- a/src/sql/xbcrtbl.cpp +++ b/src/sql/xbcrtbl.cpp @@ -29,7 +29,7 @@ xbInt16 xbSql::SqlCreateTable( const xbString &sCmdLine ){ // expected format: // CREATE TABLE tablename.dbf (Field1 CHAR(10), INTFLD1 INTEGER, ... ) - // supported fields types + // supported field types // // SQL TYPE XBASE Field Type // -------- ---------------- @@ -61,6 +61,7 @@ xbInt16 xbSql::SqlCreateTable( const xbString &sCmdLine ){ xbLinkList<xbString> ll; xbSchema *schema = NULL; xbString sMsg; + xbString sWork; try{ // retrieve table name @@ -75,7 +76,7 @@ xbInt16 xbSql::SqlCreateTable( const xbString &sCmdLine ){ xbFile f( xbase ); f.SetFileName( sTableName ); if( f.FileExists() ){ - iErrorStop = 10; + iErrorStop = 100; iRc = XB_FILE_EXISTS; throw iRc; } @@ -90,8 +91,6 @@ xbInt16 xbSql::SqlCreateTable( const xbString &sCmdLine ){ s.Remove( s.Len(), 1 ); s.Trim(); - //std::cout << "s = [" << s << "]\n"; - xbBool bDone = xbFalse; xbInt16 iLoop = 0; @@ -129,7 +128,7 @@ xbInt16 xbSql::SqlCreateTable( const xbString &sCmdLine ){ else if( sDataType == "SMALLINT" || sDataType == "INTEGER" || sDataType == "DATE" || sDataType == "VARCHAR" || sDataType == "LOGICAL" ) iAttribCnt = 0; else{ - iErrorStop = 20; + iErrorStop = 110; iRc = XB_INVALID_FIELD_TYPE; throw iRc; } @@ -143,25 +142,37 @@ xbInt16 xbSql::SqlCreateTable( const xbString &sCmdLine ){ } else if( iAttribCnt > 0 ){ lPos = s.Pos( '(' ); if( lPos <= 0 ){ - iErrorStop = 30; + iErrorStop = 120; iRc = XB_INVALID_FIELD_LEN; throw iRc; } s.Ltrunc( lPos ); - if( iAttribCnt == 1 ) - lPos = s.Pos( ')' ); - else - lPos = s.Pos( ',' ); - - sAttrib1.Assign( s, 1, lPos-1 ); - sAttrib1.Trim(); - s.Ltrunc( lPos ); - if( iAttribCnt > 1 ){ - lPos = s.Pos( ')' ); - sAttrib2.Assign( s, 1, lPos-1 ); - s.Ltrunc( lPos ); + lPos = s.Pos( ')' ); + if( lPos <= 0 ){ + iErrorStop = 130; + iRc = XB_INVALID_FIELD_LEN; + throw iRc; } + sWork.Assign( s, 1, lPos - 1); + sWork.Trim(); + + if( iAttribCnt == 1 ){ + sAttrib1 = sWork; + } else { + lCmPos = sWork.Pos( ',' ); + if( lCmPos <= 0 ){ + iErrorStop = 140; + iRc = XB_INVALID_FIELD_LEN; + throw iRc; + } + sAttrib1.Assign( sWork, 1, lCmPos - 1); + sAttrib1.Trim(); + sWork.Ltrunc( lCmPos ); + sAttrib2 = sWork; + sAttrib2.Trim(); + } + s.Ltrunc( lPos ); } s.Ltrim(); @@ -229,7 +240,7 @@ xbInt16 xbSql::SqlCreateTable( const xbString &sCmdLine ){ dbf = new xbDbf3( xbase ); #endif if(( iRc = dbf->CreateTable( sTableName, "", schema, 0, XB_MULTI_USER )) != XB_NO_ERROR ){ - iErrorStop = 50; + iErrorStop = 150; throw iRc; } |