summaryrefslogtreecommitdiff
path: root/src/sql/xbcrtbl.cpp
diff options
context:
space:
mode:
authorJörg Frings-Fürst <debian@jff-webhosting.net>2023-03-11 18:15:37 +0100
committerJörg Frings-Fürst <debian@jff-webhosting.net>2023-03-11 18:15:37 +0100
commitdd70ff8bf32c2d7ed365004b1770058265db1978 (patch)
tree084788d142d86c4dc38f5c48606523b4040596e6 /src/sql/xbcrtbl.cpp
parent517ad9d4b6eae320b708d03a9340a22893b0cab7 (diff)
New upstream version 4.1.0upstream/4.1.0
Diffstat (limited to 'src/sql/xbcrtbl.cpp')
-rwxr-xr-xsrc/sql/xbcrtbl.cpp49
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;
}