summaryrefslogtreecommitdiff
path: root/src/sql/xbcrix.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/sql/xbcrix.cpp')
-rwxr-xr-xsrc/sql/xbcrix.cpp60
1 files changed, 35 insertions, 25 deletions
diff --git a/src/sql/xbcrix.cpp b/src/sql/xbcrix.cpp
index b24782e..8dc6f62 100755
--- a/src/sql/xbcrix.cpp
+++ b/src/sql/xbcrix.cpp
@@ -21,6 +21,7 @@ namespace xb{
/***********************************************************************/
+#ifdef XB_INDEX_SUPPORT
xbInt16 xbSql::SqlCreateIndex( const xbString &sCmdLine ){
// std::cout << "CREATE INDEX " << sCmdLine << std::endl;
@@ -68,8 +69,6 @@ xbInt16 xbSql::SqlCreateIndex( const xbString &sCmdLine ){
try{
- // std::cout << "xbSql::CreateIx()\n" ;
-
// drop off the first node
ulPos = sCmd.Pos( ' ' );
sCmd.Ltrunc( ulPos );
@@ -104,7 +103,7 @@ xbInt16 xbSql::SqlCreateIndex( const xbString &sCmdLine ){
if( sIxType == "" ){
if(( iRc = uda.GetTokenForKey( "IXTYPE", sIxType )) != XB_NO_ERROR ){
- iErrorStop = 20;
+ iErrorStop = 100;
throw iRc;
}
}
@@ -114,7 +113,7 @@ xbInt16 xbSql::SqlCreateIndex( const xbString &sCmdLine ){
xbFile f( xbase );
f.SetFileName( sIxName );
if( f.FileExists()){
- iErrorStop = 30;
+ iErrorStop = 110;
iRc = XB_FILE_EXISTS;
throw iRc;
}
@@ -143,7 +142,7 @@ xbInt16 xbSql::SqlCreateIndex( const xbString &sCmdLine ){
dbf = xbase->GetDbfPtr( fDbf.GetFqFileName());
if( !dbf ){
if(( iRc = xbase->OpenHighestVersion( sTableName, "", &dbf )) != XB_NO_ERROR ){
- iErrorStop = 40;
+ iErrorStop = 120;
throw iRc;
}
}
@@ -154,13 +153,14 @@ xbInt16 xbSql::SqlCreateIndex( const xbString &sCmdLine ){
}
sCmd.Ltrunc( ulPos );
- // std::cout << "cp1 ulPos = " << ulPos << " scmd = " << sCmd << "\n";
+ std::cout << "cp1 ulPos = " << ulPos << " sCmd = [" << sCmd << "]\n";
//ulPos = sCmd.GetLastPos( ')' );
xbString sKeyExpression;
xbBool bDone = xbFalse;
xbUInt32 lPos = 1;
xbInt16 iParenCtr = 0;
+
while( !bDone && lPos < sCmd.Len()){
if( sCmd[lPos] == '(' ){
iParenCtr++;
@@ -172,19 +172,21 @@ xbInt16 xbSql::SqlCreateIndex( const xbString &sCmdLine ){
} else {
bDone = xbTrue;
}
- } else if( sCmd[lPos] == ',' ){
+ } else if( sCmd[lPos] == ',' && iParenCtr == 0 ){
sKeyExpression.Append( '+' );
} else if( sCmd[lPos] != ' ' ){
sKeyExpression.Append( sCmd[lPos] );
}
lPos++;
}
-// std::cout << "Key Expression =[" << sKeyExpression << "]\n";
+
+ std::cout << "Key Expression =[" << sKeyExpression << "]\n";
+
sCmd.Ltrunc( lPos );
sCmd.Trim();
xbBool bDesc = xbFalse;
-// std::cout << "sCmd - looking for DESC [" << sCmd << "]\n";
+ // std::cout << "sCmd - looking for DESC [" << sCmd << "]\n";
if( sCmd.Len() > 4 ){
sNode = sCmd;
sNode.ToUpperCase();
@@ -193,11 +195,12 @@ xbInt16 xbSql::SqlCreateIndex( const xbString &sCmdLine ){
bDesc = xbTrue;
sCmd.Ltrunc( 4 );
sCmd.Trim();
- // std::cout << "Descending\n";
+ std::cout << "Descending\n";
}
}
-// std::cout << "sCmd - looking for FILTER stuff [" << sCmd << "]\n";
+
+ // std::cout << "sCmd - looking for FILTER stuff [" << sCmd << "]\n";
xbString sFilter;
if( sCmd.Len() > 6 ){
sNode = sCmd;
@@ -205,29 +208,29 @@ xbInt16 xbSql::SqlCreateIndex( const xbString &sCmdLine ){
ulPos = sNode.Pos( "FILTER" );
if( ulPos > 0 ){
sFilter = sCmd;
- sFilter.Ltrunc( ulPos + 7 );
+ sFilter.Ltrunc( ulPos + 6 );
sFilter.Trim();
}
}
-// std::cout << "sCmd - FILTER = [" << sFilter << "]\n";
+ // std::cout << "sCmd - FILTER = [" << sFilter << "]\n";
#ifdef XB_LOCKING_SUPPORT
if(( iRc = dbf->LockTable( XB_LOCK )) != XB_NO_ERROR ){
- iErrorStop = 60;
+ iErrorStop = 130;
throw iRc;
}
#endif // XB_LOCKING_SUPPORT
-// std::cout << "SqlCreateIndex() - ixtype = " << sIxType << "\n";
+ // std::cout << "SqlCreateIndex() - ixtype = " << sIxType << "\n";
xbIx *pIx;
void *vpTag;
if(( iRc = dbf->CreateTag( sIxType, sIxName, sKeyExpression, sFilter, bDesc, bUnique, xbFalse, &pIx, &vpTag )) != XB_NO_ERROR ){
- iErrorStop = 70;
+ iErrorStop = 140;
throw iRc;
}
-// std::cout << "SqlCreateIndex() - back from tag create\n";
+ // std::cout << "SqlCreateIndex() - back from tag create\n";
#ifdef XB_NDX_SUPPORT
if( sIxType == "NDX"){
sCmd.Ltrunc( ulPos );
@@ -236,20 +239,27 @@ xbInt16 xbSql::SqlCreateIndex( const xbString &sCmdLine ){
sCmd.ToUpperCase();
if( sCmd.Pos( "ASSOCIATE" )){
if(( iRc = dbf->AssociateIndex( "NDX", sIxName, 0 )) != XB_NO_ERROR ){
- iErrorStop = 80;
+ iErrorStop = 150;
throw iRc;
}
}
}
}
- if( sIxType == "NDX"){
- if(( iRc = pIx->Reindex( &vpTag )) != XB_NO_ERROR ){
- iErrorStop = 100;
- throw iRc;
- }
- }
+// if( sIxType == "NDX"){
+// if(( iRc = pIx->Reindex( &vpTag )) != XB_NO_ERROR ){
+// iErrorStop = 160;
+// throw iRc;
+// }
+// }
#endif // XB_NDX_SUPPORT
+
+ if(( iRc = pIx->Reindex( &vpTag )) != XB_NO_ERROR ){
+ iErrorStop = 160;
+ throw iRc;
+ }
+
+
#ifdef XB_LOCKING_SUPPORT
if(( iRc = dbf->LockTable( XB_UNLOCK )) != XB_NO_ERROR ){
iErrorStop = 140;
@@ -272,7 +282,7 @@ xbInt16 xbSql::SqlCreateIndex( const xbString &sCmdLine ){
return iRc;
}
-
+#endif // XB_INDEX_SUPPORT
/***********************************************************************/
} /* namespace */
#endif /* XB_SQL_SUPPORT */