2017-09-08 16:00 UTC Viktor Szakats (vszakats users.noreply.github.com)
* *
* partial sync with the 3.4 fork codebase. These are the things
synces for the most part:
- copyright headers
- grammar/typos in comments and some readmes
- comment/whitespace/decorations
- variable scoping in C files
- DO CASE/SWITCH and some other alternate syntax usage
- minimal amount of human readable text in strings
- minor code updates
- HB_TRACE() void * casts for pointers and few other changes to
avoid C compiler warnings
- various other, minor code cleanups
- only Harbour/C code/headers were touched in src, utils, contrib,
include. No 3rd party code, no make files, and with just a few
exceptions, no 'tests' code was touched.
- certain components were not touched were 3.4 diverged too much
already, like f.e. hbmk2, hbssl, hbcurl, hbexpat
- the goal was that no actual program logic should be altered by
these changes. Except some possible minor exceptions, any such
change is probably a bug in this patch.
It's a massive patch, if you find anything broken after it, please
open an Issue with the details. Build test was done on macOS.
The goal is make it easier to see what actual code/logic was changed
in 3.4 compared to 3.2 and to make patches easier to apply in both
ways.
This commit is contained in:
@@ -48,17 +48,13 @@
|
||||
#ifndef HB_RDDSQL_H_
|
||||
#define HB_RDDSQL_H_
|
||||
|
||||
#include "hbapi.h"
|
||||
#include "hbapirdd.h"
|
||||
#include "hbdbferr.h"
|
||||
#include "hbapierr.h"
|
||||
#include "hbapilng.h"
|
||||
#include "hbapi.h"
|
||||
|
||||
/*
|
||||
====================================================================
|
||||
SQLBASE
|
||||
====================================================================
|
||||
*/
|
||||
/* SQLBASE */
|
||||
|
||||
#define MAX_FIELD_NAME 64
|
||||
|
||||
@@ -73,9 +69,7 @@ typedef struct _SQLBASEAREA
|
||||
{
|
||||
AREA area;
|
||||
|
||||
/*
|
||||
* SQLBASE additions to the workarea structure
|
||||
*/
|
||||
/* SQLBASE additions to the workarea structure */
|
||||
|
||||
LPDBRELINFO lpdbPendingRel;
|
||||
|
||||
@@ -113,11 +107,7 @@ typedef struct _SQLDDCONNECTION
|
||||
} SQLDDCONNECTION;
|
||||
|
||||
|
||||
/*
|
||||
====================================================================
|
||||
SQLMIX
|
||||
====================================================================
|
||||
*/
|
||||
/* SQLMIX */
|
||||
|
||||
#define MIX_MAXKEYLEN 1024
|
||||
#define MIX_MAXTAGNAMELEN 16
|
||||
@@ -178,7 +168,7 @@ typedef struct _MIXTAG
|
||||
PMIXKEY HotKey;
|
||||
HB_BOOL HotFor;
|
||||
|
||||
PHB_CODEPAGE pCodepage; /* National sorttable for character key tags, NULL otherwise */
|
||||
PHB_CODEPAGE pCodepage; /* National sort table for character key tags, NULL otherwise */
|
||||
} MIXTAG, * PMIXTAG;
|
||||
|
||||
|
||||
@@ -196,11 +186,7 @@ typedef struct _SQLMIXAREA
|
||||
} SQLMIXAREA, * SQLMIXAREAP;
|
||||
|
||||
|
||||
/*
|
||||
====================================================================
|
||||
SQLDD
|
||||
====================================================================
|
||||
*/
|
||||
/* SQLDD */
|
||||
|
||||
typedef HB_ERRCODE ( *SDDFUNC_CONNECT )( SQLDDCONNECTION * pConnection, PHB_ITEM pItem );
|
||||
typedef HB_ERRCODE ( *SDDFUNC_DISCONNECT )( SQLDDCONNECTION * pConnection );
|
||||
|
||||
@@ -18,7 +18,7 @@ emulated by creating additional table columns to store delete flag. Some
|
||||
record and file locks in DBF style. The idea of SQL query is also lost. If
|
||||
you do a simple loop
|
||||
|
||||
dbUseArea(, "select * from my_table" )
|
||||
dbUseArea( , "select * from my_table" )
|
||||
DO WHILE ! Eof()
|
||||
somefunc( FIELD->some_sql_field )
|
||||
dbSkip()
|
||||
@@ -26,8 +26,8 @@ you do a simple loop
|
||||
|
||||
RDD usualy will read SQL rows in portions, let's say 100 records per query.
|
||||
So, hidden queries are generated. If you are using indexes these queries
|
||||
are really complicated. Let's have index on FIELD1 + Str(FIELD2). A seek to
|
||||
value cValue1 + Str(nValue2) will generate a query like:
|
||||
are really complicated. Let's have index on FIELD1 + Str( FIELD2 ). A seek
|
||||
to value cValue1 + Str( nValue2 ) will generate a query like:
|
||||
|
||||
SELECT * FROM my_table
|
||||
WHERE (FIELD1 == cValue1 and FIELD2 >= nValue2) or FIELD1 > cValue1
|
||||
@@ -55,7 +55,7 @@ queries should be made explicitly by programmer. SSI gives access to query
|
||||
result via RDD interface, it does not tries to emulate DBF and be
|
||||
"plug-and-play" solution for DBF to SQL migration. If you do
|
||||
|
||||
dbUseArea(, "select * from my_table")
|
||||
dbUseArea( , "select * from my_table")
|
||||
|
||||
all query (it could contain millions of records!) will be cached.
|
||||
|
||||
|
||||
@@ -104,11 +104,11 @@ void hb_rddsqlSetError( HB_ERRCODE errCode, const char * szError, const char * s
|
||||
|
||||
static HB_ERRCODE hb_errRT_SQLBASE( HB_ERRCODE errGenCode, HB_ERRCODE errSubCode, const char * szDescription, const char * szOperation )
|
||||
{
|
||||
PHB_ITEM pError;
|
||||
HB_ERRCODE iRet = HB_FAILURE;
|
||||
|
||||
if( hb_vmRequestQuery() == 0 )
|
||||
{
|
||||
PHB_ITEM pError;
|
||||
pError = hb_errRT_New( ES_ERROR, "SQLBASE", errGenCode, errSubCode, szDescription, szOperation, 0, EF_NONE );
|
||||
iRet = hb_errLaunch( pError );
|
||||
hb_itemRelease( pError );
|
||||
@@ -117,7 +117,7 @@ static HB_ERRCODE hb_errRT_SQLBASE( HB_ERRCODE errGenCode, HB_ERRCODE errSubCode
|
||||
}
|
||||
|
||||
|
||||
/*================ NULL SDD ==========================================================*/
|
||||
/* --- NULL SDD --- */
|
||||
|
||||
static HB_ERRCODE sddConnect( SQLDDCONNECTION * pConnection, PHB_ITEM pItem );
|
||||
static HB_ERRCODE sddDisconnect( SQLDDCONNECTION * pConnection );
|
||||
@@ -224,7 +224,7 @@ static HB_ERRCODE sddGetVarLen( SQLBASEAREAP pArea, HB_USHORT uiIndex, HB_ULONG
|
||||
}
|
||||
|
||||
|
||||
/*==================== SDD registration =====================================*/
|
||||
/* --- SDD registration --- */
|
||||
|
||||
static PSDDNODE s_pSdd = NULL;
|
||||
|
||||
@@ -263,7 +263,7 @@ int hb_sddRegister( PSDDNODE pSdd )
|
||||
}
|
||||
|
||||
|
||||
/*============= RDD METHODS =============================================================*/
|
||||
/* --- RDD METHODS --- */
|
||||
|
||||
static HB_ERRCODE sqlbaseGoBottom( SQLBASEAREAP pArea )
|
||||
{
|
||||
@@ -310,13 +310,11 @@ static HB_ERRCODE sqlbaseGoTo( SQLBASEAREAP pArea, HB_ULONG ulRecNo )
|
||||
|
||||
static HB_ERRCODE sqlbaseGoToId( SQLBASEAREAP pArea, PHB_ITEM pItem )
|
||||
{
|
||||
PHB_ITEM pError;
|
||||
|
||||
if( HB_IS_NUMERIC( pItem ) )
|
||||
return SELF_GOTO( &pArea->area, hb_itemGetNL( pItem ) );
|
||||
else
|
||||
{
|
||||
pError = hb_errNew();
|
||||
PHB_ITEM pError = hb_errNew();
|
||||
hb_errPutGenCode( pError, EG_DATATYPE );
|
||||
hb_errPutDescription( pError, hb_langDGetErrorDesc( EG_DATATYPE ) );
|
||||
hb_errPutSubCode( pError, EDBF_DATATYPE );
|
||||
@@ -900,12 +898,12 @@ static HB_ERRCODE sqlbaseInit( LPRDDNODE pRDD )
|
||||
|
||||
static HB_ERRCODE sqlbaseExit( LPRDDNODE pRDD )
|
||||
{
|
||||
HB_ULONG ul;
|
||||
|
||||
HB_SYMBOL_UNUSED( pRDD );
|
||||
|
||||
if( s_pConnection )
|
||||
{
|
||||
HB_ULONG ul;
|
||||
|
||||
/* Disconnect all connections */
|
||||
for( ul = 0; ul < s_ulConnectionCount; ul++ )
|
||||
{
|
||||
@@ -1089,7 +1087,7 @@ static HB_ERRCODE sqlbaseRddInfo( LPRDDNODE pRDD, HB_USHORT uiIndex, HB_ULONG ul
|
||||
}
|
||||
|
||||
|
||||
/*====================================================================================*/
|
||||
/* --- */
|
||||
|
||||
static RDDFUNCS sqlbaseTable =
|
||||
{
|
||||
@@ -1196,7 +1194,7 @@ static RDDFUNCS sqlbaseTable =
|
||||
};
|
||||
|
||||
|
||||
/*================ Module initialization code ========================================*/
|
||||
/* --- Module initialization code --- */
|
||||
|
||||
HB_FUNC( SQLBASE )
|
||||
{
|
||||
|
||||
@@ -90,21 +90,16 @@ static HB_USHORT s_uiRddIdSQLMIX = ( HB_USHORT ) -1;
|
||||
static RDDFUNCS sqlmixSuper;
|
||||
|
||||
|
||||
/*
|
||||
=======================================================================
|
||||
Misc functions
|
||||
=======================================================================
|
||||
*/
|
||||
/* --- Misc functions --- */
|
||||
|
||||
|
||||
static HB_ERRCODE sqlmixErrorRT( SQLMIXAREAP pArea, HB_ERRCODE errGenCode, HB_ERRCODE errSubCode, char * filename, HB_ERRCODE errOsCode, HB_USHORT uiFlags )
|
||||
{
|
||||
PHB_ITEM pError;
|
||||
HB_ERRCODE iRet = HB_FAILURE;
|
||||
|
||||
if( hb_vmRequestQuery() == 0 )
|
||||
{
|
||||
pError = hb_errNew();
|
||||
PHB_ITEM pError = hb_errNew();
|
||||
hb_errPutGenCode( pError, errGenCode );
|
||||
hb_errPutSubCode( pError, errSubCode );
|
||||
hb_errPutOsCode( pError, errOsCode );
|
||||
@@ -120,13 +115,10 @@ static HB_ERRCODE sqlmixErrorRT( SQLMIXAREAP pArea, HB_ERRCODE errGenCode, HB_ER
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
=======================================================================
|
||||
Memory Index
|
||||
=======================================================================
|
||||
*/
|
||||
/* --- Memory Index --- */
|
||||
|
||||
/* --- Key management --- */
|
||||
|
||||
/* -------------------------- Key management ---------------------------- */
|
||||
/* hb_mixKey*() */
|
||||
|
||||
static PMIXKEY hb_mixKeyNew( PMIXTAG pTag )
|
||||
@@ -293,7 +285,8 @@ static int hb_mixKeyCompare( PMIXTAG pTag, PMIXKEY pKey1, PMIXKEY pKey2, unsigne
|
||||
}
|
||||
|
||||
|
||||
/* -------------------------- Tag management ---------------------------- */
|
||||
/* --- Tag management --- */
|
||||
|
||||
/* hb_mixTag*() */
|
||||
|
||||
/* This function is used for debugging purposes. Uncomment it, if you need it. */
|
||||
@@ -771,7 +764,7 @@ static PMIXTAG hb_mixTagCreate( const char * szTagName, PHB_ITEM pKeyExpr, PHB_I
|
||||
pTag->szKeyExpr = ( char * ) hb_xgrab( hb_itemGetCLen( pKeyExpr ) + 1 );
|
||||
hb_strncpyTrim( pTag->szKeyExpr, hb_itemGetCPtr( pKeyExpr ), hb_itemGetCLen( pKeyExpr ) );
|
||||
|
||||
/* TODO: FOR expresion */
|
||||
/* TODO: FOR expression */
|
||||
pTag->szForExpr = NULL;
|
||||
|
||||
pTag->pKeyItem = pKeyItem;
|
||||
@@ -1080,7 +1073,8 @@ static void hb_mixTagSkip( PMIXTAG pTag, HB_LONG lSkip )
|
||||
}
|
||||
}
|
||||
|
||||
/* -------------------------- Misc functions ---------------------------- */
|
||||
/* --- Misc functions --- */
|
||||
|
||||
/* hb_mix*() */
|
||||
|
||||
static PMIXTAG hb_mixFindTag( SQLMIXAREAP pArea, PHB_ITEM pOrder )
|
||||
@@ -1110,20 +1104,20 @@ static PMIXTAG hb_mixFindTag( SQLMIXAREAP pArea, PHB_ITEM pOrder )
|
||||
}
|
||||
|
||||
|
||||
/*=======================================================================*/
|
||||
/* --- */
|
||||
|
||||
|
||||
static HB_ULONG hb_mixTagNodeKeyCount( PMIXNODE pNode )
|
||||
{
|
||||
HB_ULONG ulKeyCount;
|
||||
unsigned int ui;
|
||||
HB_ULONG ulKeyCount = pNode->KeyCount;
|
||||
|
||||
ulKeyCount = pNode->KeyCount;
|
||||
if( ! pNode->Leaf )
|
||||
{
|
||||
unsigned int ui;
|
||||
for( ui = 0; ui <= pNode->KeyCount; ui++ )
|
||||
ulKeyCount += hb_mixTagNodeKeyCount( pNode->Child[ ui ] );
|
||||
}
|
||||
|
||||
return ulKeyCount;
|
||||
}
|
||||
|
||||
@@ -1216,11 +1210,7 @@ static HB_ULONG hb_mixDBOIKeyNo( PMIXTAG pTag, HB_BOOL fFilter )
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
=======================================================================
|
||||
SQLMIX RDD METHODS
|
||||
=======================================================================
|
||||
*/
|
||||
/* --- SQLMIX RDD METHODS --- */
|
||||
|
||||
static HB_ERRCODE sqlmixGoBottom( SQLMIXAREAP pArea )
|
||||
{
|
||||
@@ -1809,7 +1799,7 @@ static HB_ERRCODE sqlmixOrderInfo( SQLMIXAREAP pArea, HB_USHORT uiIndex, LPDBORD
|
||||
break;
|
||||
|
||||
case DBOI_NUMBER:
|
||||
pOrderInfo->itmResult = hb_itemPutNI( pOrderInfo->itmResult, uiTag ); /* kitaip */
|
||||
pOrderInfo->itmResult = hb_itemPutNI( pOrderInfo->itmResult, uiTag ); /* otherwise */
|
||||
break;
|
||||
|
||||
case DBOI_ISCOND:
|
||||
|
||||
Reference in New Issue
Block a user