[DEVELOPMENT ENVIRONMENT]
* BUG: Don't use "sTable" as field name for the metadata table, because apparently "STABLE" is a reserved word in PostgreSQL. Upgrade an already existing metadata table automatically. * BUG: Don't crash when starting a search from a image or connection editor. [WEBSITE MAKER] * NEW: Update for 3.6. [GB.DB] * NEW: Add support for databases like PostgreSQL that are not fully case insensitive. [GB.DB.POSTGRESQL] * BUG: Automatically convert field names to lowercase when creating a table. [GB.GUI.BASE] * BUG: IconView item renaming don't crash anymore. git-svn-id: svn://localhost/gambas/trunk@6559 867c0c6c-44f3-4631-809d-bfa615b0a4ec
This commit is contained in:
parent
d20ad59bd7
commit
d57578377c
22 changed files with 207 additions and 107 deletions
|
@ -1,9 +1,9 @@
|
|||
# Gambas Project File 3.0
|
||||
# Compiled with Gambas 3.5.90
|
||||
# Compiled with Gambas 3.6.0
|
||||
Title=Gambas web site generator
|
||||
Startup=MMain
|
||||
Icon=html.png
|
||||
Version=3.5.90
|
||||
Version=3.6.0
|
||||
VersionFile=1
|
||||
Component=gb.image
|
||||
Component=gb.gui
|
||||
|
|
|
@ -39,31 +39,11 @@ SearchComment=False
|
|||
SearchString=True
|
||||
|
||||
[OpenFile]
|
||||
File[1]="gambas.sourceforge.net/index.html:0.0"
|
||||
File[2]="gambas.sourceforge.net/main.html:22.4"
|
||||
File[3]="gambas.sourceforge.net/home.html:0.0"
|
||||
File[4]=".src/MMain.module:323.2"
|
||||
File[5]="gambas.sourceforge.net/menu.html:25.36"
|
||||
File[6]="gambas.sourceforge.net/raspberrypi.png"
|
||||
File[7]="gambas.sourceforge.net/news.html#:0.0"
|
||||
File[8]="gambas.sourceforge.net/news.html.template#:0.0"
|
||||
File[9]="authors.txt:469.6"
|
||||
File[10]="html.png"
|
||||
File[11]="news.html:0.0"
|
||||
File[12]="gambas.sourceforge.net/changelog.html#:0.0"
|
||||
File[13]="gambas.sourceforge.net/compilation.html.template#:0.0"
|
||||
File[14]="gambas.sourceforge.net/flag/nl.png"
|
||||
File[15]="gambas.sourceforge.net/flag/ko.png"
|
||||
File[16]="gambas.sourceforge.net/flag/zh.png"
|
||||
File[17]="gambas.sourceforge.net/flag/tr.png"
|
||||
File[18]="gambas.sourceforge.net/flag/es.png"
|
||||
File[19]="gambas.sourceforge.net/flag/ar.png"
|
||||
File[20]=".src/MTranslation.module:0.0"
|
||||
File[21]=".src/MChangeLog.module:0.0"
|
||||
File[22]=".src/MBeams.module:0.0"
|
||||
Active=23
|
||||
File[23]=".src/CAuthor.class:0.0"
|
||||
Count=23
|
||||
File[1]=".src/MMain.module:17.2"
|
||||
File[2]="gambas.sourceforge.net/home.html:0.0"
|
||||
Active=3
|
||||
File[3]="gambas.sourceforge.net/index.html:0.0"
|
||||
Count=3
|
||||
|
||||
[VersionControl]
|
||||
User="gbWilly"
|
||||
|
|
|
@ -14,7 +14,7 @@ Sub InitVar()
|
|||
'DIM aDev AS String[] = ["92", "91", "90", "51"]
|
||||
|
||||
$cVar["OLD_VERSION"] = "2.24.0"
|
||||
$cVar["DEV_VERSION"] = "3.5.4"
|
||||
$cVar["DEV_VERSION"] = "3.6.0"
|
||||
|
||||
InitAuthor
|
||||
|
||||
|
|
|
@ -2,7 +2,7 @@ MMain
|
|||
Gambas web site generator
|
||||
0
|
||||
0
|
||||
3.5.90
|
||||
3.6.0
|
||||
|
||||
gb.image
|
||||
gb.gui
|
||||
|
|
|
@ -41,10 +41,10 @@
|
|||
<div align="center"><img id="logo" src="logo.png"/></div>
|
||||
|
||||
<div>
|
||||
<a class="download-orange" target="_blank" href="http://sourceforge.net/projects/gambas/files/gambas3/gambas3-3.5.4.tar.bz2/download">
|
||||
{Download} <b>Gambas 3.5.4</b>
|
||||
<a class="download-orange" target="_blank" href="http://sourceforge.net/projects/gambas/files/gambas3/gambas3-3.6.0.tar.bz2/download">
|
||||
{Download} <b>Gambas 3.6.0</b>
|
||||
</a>
|
||||
<div class="release-notes" align="center"><a href="http://gambaswiki.org/wiki/doc/release/3.5.4?w&l=$(LANG)">{Release Notes}</a></div>
|
||||
<div class="release-notes" align="center"><a href="http://gambaswiki.org/wiki/doc/release/3.6.0?w&l=$(LANG)">{Release Notes}</a></div>
|
||||
</div>
|
||||
|
||||
<div style="display:inline-table;">
|
||||
|
|
|
@ -1,13 +1,18 @@
|
|||
' Gambas module file
|
||||
|
||||
Public Password As New Collection
|
||||
Public Const METADATA_TABLE_NAME As String = "__gb_metadata"
|
||||
|
||||
Public Const METADATA_TABLE_PREFIX As String = "__gb_metadata"
|
||||
Public Const OLD_METADATA_TABLE_NAME As String = "__gb_metadata"
|
||||
Public Const METADATA_TABLE_NAME As String = "__gb_metadata_v2"
|
||||
|
||||
Public Const VOID_PASSWORD As String = "\x00"
|
||||
|
||||
Public Enum MD_VERSION = 0, MD_FIELD = 1, MD_INDEX = 2, MD_TABLE = 3
|
||||
|
||||
Private $bError As Boolean
|
||||
|
||||
Public Sub InitFrom(hConn As Connection, hConfig As Object, sName As String, Optional bWithDatabase As Boolean)
|
||||
Public Sub InitFrom(hConn As Connection, hConfig As Object, sName As String, Optional bWithDatabase As Boolean) As Boolean
|
||||
|
||||
hConn.Type = LCase(hConfig["Connection/Type"])
|
||||
If hConn.Type = "sqlite" Then
|
||||
|
@ -338,7 +343,7 @@ Public Sub FillViewWithTables(lvwTable As TreeView, hConn As Connection, bShowSy
|
|||
For Each hTable In hConn.Tables
|
||||
|
||||
If Not bShowSystem Then
|
||||
If hTable.System Or If hTable.Name = METADATA_TABLE_NAME Then Continue
|
||||
If hTable.System Or If hTable.Name Begins METADATA_TABLE_PREFIX Then Continue
|
||||
Endif
|
||||
|
||||
sName = hTable.Name
|
||||
|
@ -426,22 +431,43 @@ End
|
|||
Public Sub CreateMetadataTable(hConn As Connection) As Boolean
|
||||
|
||||
Dim hTable As Table
|
||||
Dim rTable As Result
|
||||
Dim rOldTable As Result
|
||||
Dim sErr As String
|
||||
|
||||
If hConn.Tables.Exist(METADATA_TABLE_NAME) Then Return
|
||||
|
||||
hTable = hConn.Tables.Add(METADATA_TABLE_NAME)
|
||||
With hTable
|
||||
.Fields.Add("sTable", gb.String)
|
||||
.Fields.Add("sTableName", gb.String)
|
||||
.Fields.Add("iType", gb.Integer)
|
||||
.Fields.Add("sKey", gb.String)
|
||||
.Fields.Add("sValue", gb.String)
|
||||
.PrimaryKey = ["sTable", "iType", "sKey"]
|
||||
.PrimaryKey = ["sTableName", "iType", "sKey"]
|
||||
.Update
|
||||
End With
|
||||
|
||||
If hConn.Tables.Exist(OLD_METADATA_TABLE_NAME) Then
|
||||
hConn.Begin
|
||||
rOldTable = hConn.Find(OLD_METADATA_TABLE_NAME)
|
||||
While rOldTable.Available
|
||||
rTable = hConn.Create(METADATA_TABLE_NAME)
|
||||
rTable!sTableName = rOldTable!sTable
|
||||
rTable!iType = rOldTable!iType
|
||||
rTable!sKey = rOldTable!sKey
|
||||
rTable!sValue = rOldTable!sValue
|
||||
rTable.Update
|
||||
rOldTable.MoveNext
|
||||
Wend
|
||||
hConn.Tables.Remove(OLD_METADATA_TABLE_NAME)
|
||||
hConn.Commit
|
||||
Endif
|
||||
|
||||
Catch
|
||||
|
||||
Message(("Cannot create metadata table.") & "\n\n" & Error.Text)
|
||||
sErr = Error.Text
|
||||
hConn.Rollback
|
||||
Message(("Cannot create metadata table.") & "\n\n" & sErr)
|
||||
Return True
|
||||
|
||||
End
|
||||
|
|
|
@ -962,30 +962,30 @@ Public Sub Editors_KeyPress()
|
|||
For Each sLine In Split(File.Load("/proc/self/maps"), "\n")
|
||||
If InStr(sLine, "[heap]") Then
|
||||
aScan = Scan(sLine, "*-* *")
|
||||
Print "Heap size is " & Format(Val("&H" & aScan[1] & "&") - Val("&H" & aScan[0] & "&"), "#,##0") & " bytes."
|
||||
Print "------------ Heap size is " & Format(Val("&H" & aScan[1] & "&") - Val("&H" & aScan[0] & "&"), "#,##0") & " bytes."
|
||||
Break
|
||||
Endif
|
||||
Next
|
||||
|
||||
aClass = New String[]
|
||||
|
||||
For Each hClass In Classes
|
||||
aClass.Add(hClass.Name)
|
||||
Next
|
||||
|
||||
aClass.Sort
|
||||
|
||||
For Each sClass In aClass
|
||||
Try hClass = Classes[sClass]
|
||||
If Error Then Continue
|
||||
With hClass
|
||||
iOldCount = 0
|
||||
Try iOldCount = $cLastClassCount[sClass]
|
||||
If .Count = iOldCount Then Continue
|
||||
Print sClass; ": "; .Count;; "("; Format(.Count - iOldCount, "+0"); ")"
|
||||
$cLastClassCount[sClass] = .Count
|
||||
End With
|
||||
Next
|
||||
' aClass = New String[]
|
||||
'
|
||||
' For Each hClass In Classes
|
||||
' aClass.Add(hClass.Name)
|
||||
' Next
|
||||
'
|
||||
' aClass.Sort
|
||||
'
|
||||
' For Each sClass In aClass
|
||||
' Try hClass = Classes[sClass]
|
||||
' If Error Then Continue
|
||||
' With hClass
|
||||
' iOldCount = 0
|
||||
' Try iOldCount = $cLastClassCount[sClass]
|
||||
' If .Count = iOldCount Then Continue
|
||||
' Print sClass; ": "; .Count;; "("; Format(.Count - iOldCount, "+0"); ")"
|
||||
' $cLastClassCount[sClass] = .Count
|
||||
' End With
|
||||
' Next
|
||||
|
||||
Endif
|
||||
|
||||
|
|
|
@ -266,6 +266,9 @@ Public Sub Reload() As Boolean
|
|||
$bMetadata = hConfig["Connection/DisplayMetadata"]
|
||||
|
||||
If $bMetadata Then
|
||||
|
||||
MConnection.CreateMetadataTable($hConn)
|
||||
|
||||
tbvField.Columns.Count = 7
|
||||
With tbvField.Columns[6]
|
||||
.Text = ("Description")
|
||||
|
@ -276,9 +279,12 @@ Public Sub Reload() As Boolean
|
|||
.Text = ("Description")
|
||||
.Width = Desktop.Scale * 24
|
||||
End With
|
||||
|
||||
Else
|
||||
|
||||
tbvField.Columns.Count = 6
|
||||
tbvIndex.Columns.Count = 3
|
||||
|
||||
Endif
|
||||
|
||||
LoadRequest
|
||||
|
@ -444,7 +450,7 @@ Private Sub ReloadTable()
|
|||
cDescField = New Collection
|
||||
cDescIndex = New Collection
|
||||
|
||||
Try hResult = $hConn.Find(MConnection.METADATA_TABLE_NAME, "sTable = &1", $sTable)
|
||||
Try hResult = $hConn.Find(MConnection.METADATA_TABLE_NAME, "sTableName = &1", $sTable)
|
||||
If hResult And If hResult.Available Then
|
||||
|
||||
For Each hResult
|
||||
|
@ -1346,11 +1352,12 @@ Private Sub WriteTable(Optional sOldTable As String) As Boolean
|
|||
Dim rTable As Result
|
||||
|
||||
Dim sError As String
|
||||
Dim bTrans As Boolean
|
||||
|
||||
' If $hFieldEditor.Hide() Then Return True
|
||||
' If $hIndexEditor.Hide() Then Return True
|
||||
|
||||
If $bModifyTable Then
|
||||
If $bModifyTable Or If sOldTable Then
|
||||
|
||||
For Each hCField In $aField
|
||||
If hCField.Key Then
|
||||
|
@ -1428,13 +1435,21 @@ Private Sub WriteTable(Optional sOldTable As String) As Boolean
|
|||
|
||||
If Not MConnection.CreateMetadataTable($hConn) Then
|
||||
|
||||
bTrans = True
|
||||
$hConn.Begin
|
||||
Try $hConn.Delete(MConnection.METADATA_TABLE_NAME, "sTable = &1", $sTable)
|
||||
|
||||
Try $hConn.Delete(MConnection.METADATA_TABLE_NAME, "sTableName = &1", $sTable)
|
||||
|
||||
' rResult = $hConn.Exec("select pg_attribute.attname, pg_attribute.atttypid::int, pg_attribute.atttypmod, pg_attribute.attnotnull, pg_attrdef.adsrc, pg_attribute.atthasdef, pg_collation.collname from pg_class, pg_attribute LEFT JOIN pg_catalog.pg_attrdef ON"
|
||||
' " (pg_attrdef.adnum = pg_attribute.attnum AND pg_attrdef.adrelid = pg_attribute.attrelid) LEFT JOIN pg_collation ON (pg_collation.oid = pg_attribute.attcollation) where pg_class.relname = '__gb_metadata' and (pg_class.relnamespace in (select oid from pg_namespace where"
|
||||
' " nspname = 'public')) and pg_attribute.attnum > 0 and not pg_attribute.attisdropped and pg_attribute.attrelid = pg_class.oid")
|
||||
'
|
||||
' rResult = $hConn.Exec("select relname from pg_class where (relkind = 'r' or relkind = 'v') and (relname = '__gb_metadata') and (relnamespace in (select oid from pg_namespace where nspname = 'public'))")
|
||||
'
|
||||
For Each hCField In $aField
|
||||
If Not hCField.Description Then Continue
|
||||
rInfo = $hConn.Create(MConnection.METADATA_TABLE_NAME)
|
||||
rInfo!sTable = $sTable
|
||||
rInfo!sTableName = $sTable
|
||||
rInfo!iType = MConnection.MD_FIELD
|
||||
rInfo!sKey = hCField.Name
|
||||
rInfo!sValue = hCField.Description
|
||||
|
@ -1445,7 +1460,7 @@ Private Sub WriteTable(Optional sOldTable As String) As Boolean
|
|||
If Not hCIndexField.Index Then Continue
|
||||
If Not hCIndexField.Description Then Continue
|
||||
rInfo = $hConn.Create(MConnection.METADATA_TABLE_NAME)
|
||||
rInfo!sTable = $sTable
|
||||
rInfo!sTableName = $sTable
|
||||
rInfo!iType = MConnection.MD_INDEX
|
||||
rInfo!sKey = hCIndexField.Index
|
||||
rInfo!sValue = hCIndexField.Description
|
||||
|
@ -1453,6 +1468,7 @@ Private Sub WriteTable(Optional sOldTable As String) As Boolean
|
|||
Next
|
||||
|
||||
$hConn.Commit
|
||||
bTrans = False
|
||||
|
||||
Endif
|
||||
|
||||
|
@ -1467,8 +1483,8 @@ Private Sub WriteTable(Optional sOldTable As String) As Boolean
|
|||
Finally
|
||||
|
||||
sError = Error.Text
|
||||
|
||||
'If Not sOldTable Then
|
||||
|
||||
$hConn.Rollback
|
||||
|
||||
If sTemp Then
|
||||
Try $hConn.Tables.Remove(sTemp)
|
||||
|
|
|
@ -405,6 +405,7 @@ Private Sub Run(iAction As Integer)
|
|||
Dim iTry As Integer
|
||||
Dim nReplace As Integer
|
||||
Dim hEditor As FEditor
|
||||
Dim hTextEditor As Editor
|
||||
Dim iLastPos As Integer
|
||||
|
||||
If InitSearch() Then Return
|
||||
|
@ -417,6 +418,9 @@ Private Sub Run(iAction As Integer)
|
|||
Endif
|
||||
Endif
|
||||
|
||||
Try hTextEditor = $hCurrent.Editor
|
||||
If Error Then Return
|
||||
|
||||
aResult = GrepFile($hCurrent)
|
||||
|
||||
If iAction And DO_REPLACE And If iAction And DO_ALL Then
|
||||
|
|
|
@ -139,7 +139,7 @@ Static Public Sub GetInfo() As String[]
|
|||
Else
|
||||
cSearch = ["Qt4": "libQtCore.so.*.*.*", "GTK+": "libgtk-x11-2*.so.*.*.*", "GTK+3": "libgtk-3*.so.*.*.*", "SDL": "libSDL-1.*.so.*.*.*", "GStreamer": "libgstreamer-*.so.*.*.*", "Poppler": "libpoppler.so.*.*.*", "Curl": "libcurl.so.*.*.*",
|
||||
"OpenGL": "libGL.so.*.*.*", "Cairo": "libcairo.so.*.*.*", "DBus": "libdbus-[0-9].so.*.*.*"]
|
||||
EndIf
|
||||
Endif
|
||||
cFile = New Collection
|
||||
|
||||
aText.Add("[Libraries]")
|
||||
|
|
|
@ -1304,10 +1304,11 @@ Public Sub _RenameItem(hItem As _IconView_Item)
|
|||
_EnsureVisible($iRename)
|
||||
GetIconGeometry($iRename, hRect)
|
||||
hRect = hItem._GetTextRect(hRect, $bHorizontal)
|
||||
hRect.Adjust(-1)
|
||||
|
||||
If Not $hRenameBox Then
|
||||
Object.Lock(Me)
|
||||
$hRenameBox = New RenameBox(Me) As "RenameBox"
|
||||
$hRenameBox = New RenameBox(Me, 0) As "RenameBox"
|
||||
Object.Unlock(Me)
|
||||
Endif
|
||||
|
||||
|
|
|
@ -220,9 +220,9 @@ Public Sub _GetTextRect(hRect As Rect, bHorizontal As Boolean) As Rect
|
|||
If $hPicture Then Y += $hPicture.H + 4
|
||||
|
||||
If $sRichText Then
|
||||
H = GetIconView().Font.RichTextHeight($sRichText, hRect.W - 4) '+ 4
|
||||
H = GetIconView().Font.RichTextHeight($sRichText, hRect.W) '+ 4
|
||||
Else
|
||||
H = GetIconView().Font.RichTextHeight(Html($sText), hRect.W - 4) '+ 4
|
||||
H = GetIconView().Font.RichTextHeight(Html($sText), hRect.W) '+ 4
|
||||
Endif
|
||||
HT = Min(H, hRect.H - (Y - hRect.Y) - 8)
|
||||
|
||||
|
|
Binary file not shown.
Before Width: | Height: | Size: 4 KiB After Width: | Height: | Size: 3.3 KiB |
|
@ -1,12 +1,12 @@
|
|||
# Gambas Project File 3.0
|
||||
# Compiled with Gambas 3.5.90
|
||||
# Compiled with Gambas 3.6.0
|
||||
Title=File browser example
|
||||
Startup=FExplorer
|
||||
Icon=folder.png
|
||||
Version=3.6.0
|
||||
VersionFile=1
|
||||
Component=gb.image
|
||||
Component=gb.gtk
|
||||
Component=gb.gui
|
||||
Component=gb.form
|
||||
Environment="GB_GUI=gb.gtk"
|
||||
TabSize=2
|
||||
|
|
|
@ -736,6 +736,7 @@ static int open_database(DB_DESC *desc, DB_DATABASE *db)
|
|||
|
||||
db->flags.no_table_type = TRUE;
|
||||
db->flags.no_nest = TRUE;
|
||||
db->flags.no_case = TRUE;
|
||||
db->flags.schema = TRUE;
|
||||
db->flags.no_collation = db->version < 90100;
|
||||
|
||||
|
@ -1117,7 +1118,7 @@ static int field_index(DB_RESULT Result, const char *name, DB_DATABASE *db)
|
|||
if (PQftable((PGresult *)result, index) != oid){
|
||||
numfields = PQnfields((PGresult *)result);
|
||||
while ( ++index < numfields){
|
||||
if (strcmp(PQfname((PGresult *)result, index),
|
||||
if (strcasecmp(PQfname((PGresult *)result, index),
|
||||
fld) == 0){ //Check Fieldname
|
||||
if (PQftable((PGresult *)result, index) == oid){ //check oid
|
||||
break; // is the required table oid
|
||||
|
@ -1321,7 +1322,7 @@ static int table_init(DB_DATABASE *db, const char *table, DB_INFO *info)
|
|||
"pg_attribute.attnotnull, pg_attrdef.adsrc, pg_attribute.atthasdef, pg_collation.collname "
|
||||
"from pg_class, pg_attribute "
|
||||
"LEFT JOIN pg_catalog.pg_attrdef ON (pg_attrdef.adnum = pg_attribute.attnum AND pg_attrdef.adrelid = pg_attribute.attrelid) "
|
||||
"LEFT JOIN pg_collation ON (pg_collation.oid = col.attcollation) "
|
||||
"LEFT JOIN pg_collation ON (pg_collation.oid = pg_attribute.attcollation) "
|
||||
"where pg_class.relname = '&1' "
|
||||
"and (pg_class.relnamespace in (select oid from pg_namespace where nspname = '&2')) "
|
||||
"and pg_attribute.attnum > 0 and not pg_attribute.attisdropped "
|
||||
|
@ -1869,9 +1870,7 @@ static int table_create(DB_DATABASE *db, const char *table, DB_FIELD *fields, ch
|
|||
else
|
||||
comma = TRUE;
|
||||
|
||||
DB.Query.Add(QUOTE_STRING);
|
||||
DB.Query.Add(fp->name);
|
||||
DB.Query.Add(QUOTE_STRING);
|
||||
DB.Query.AddLower(fp->name);
|
||||
|
||||
if (fp->type == DB_T_SERIAL)
|
||||
{
|
||||
|
@ -1936,7 +1935,7 @@ static int table_create(DB_DATABASE *db, const char *table, DB_FIELD *fields, ch
|
|||
if (i > 0)
|
||||
DB.Query.Add(",");
|
||||
|
||||
DB.Query.Add(primary[i]);
|
||||
DB.Query.AddLower(primary[i]);
|
||||
}
|
||||
|
||||
DB.Query.Add(")");
|
||||
|
|
|
@ -1430,7 +1430,7 @@ void GDocument::colorize(int y, bool force)
|
|||
old = l->s;
|
||||
GB.FreeArray(&l->highlight);
|
||||
proc = l->proc;
|
||||
(*highlightCallback)(views.first(), yy,state, alternate, tag, l->s, &l->highlight, proc);
|
||||
(*highlightCallback)(views.first(), yy, state, alternate, tag, l->s, &l->highlight, proc);
|
||||
|
||||
updateAll |= proc != l->proc;
|
||||
l->proc = proc;
|
||||
|
|
|
@ -466,9 +466,10 @@ void DEBUG_print_backtrace(STACK_BACKTRACE *bt)
|
|||
if (bt[i].pc)
|
||||
{
|
||||
n++;
|
||||
fprintf(stderr, "%d: %s\n", n, DEBUG_get_position(bt[i].cp, bt[i].fp, bt[i].pc));
|
||||
fprintf(stderr, "%s ", DEBUG_get_position(bt[i].cp, bt[i].fp, bt[i].pc));
|
||||
}
|
||||
}
|
||||
fputc('\n', stderr);
|
||||
|
||||
STACK_backtrace_set_end(end);
|
||||
}
|
||||
|
|
|
@ -276,6 +276,15 @@ BEGIN_PROPERTY(CCONNECTION_error)
|
|||
END_PROPERTY
|
||||
|
||||
|
||||
/*BEGIN_PROPERTY(Connection_Transaction)
|
||||
|
||||
CHECK_DB();
|
||||
|
||||
GB.ReturnInteger(THIS->trans);
|
||||
|
||||
END_PROPERTY*/
|
||||
|
||||
|
||||
BEGIN_METHOD_VOID(CCONNECTION_open)
|
||||
|
||||
CHECK_DB();
|
||||
|
@ -761,6 +770,7 @@ GB_DESC CConnectionDesc[] =
|
|||
GB_PROPERTY_READ("Version", "i", CCONNECTION_version),
|
||||
GB_PROPERTY_READ("Opened", "b", CCONNECTION_opened),
|
||||
GB_PROPERTY_READ("Error", "i", CCONNECTION_error),
|
||||
//GB_PROPERTY_READ("Transaction", "i", Connection_Transaction),
|
||||
GB_PROPERTY("IgnoreCharset", "b", CCONNECTION_ignore_charset),
|
||||
GB_PROPERTY_READ("Collations", "String[]", Connection_Collations),
|
||||
GB_STATIC_PROPERTY_READ("Handle", "p", Connection_Handle),
|
||||
|
@ -816,6 +826,7 @@ GB_DESC CDBDesc[] =
|
|||
GB_STATIC_PROPERTY_READ("Version", "i", CCONNECTION_version),
|
||||
GB_STATIC_PROPERTY_READ("Opened", "b", CCONNECTION_opened),
|
||||
GB_STATIC_PROPERTY_READ("Error", "i", CCONNECTION_error),
|
||||
//GB_STATIC_PROPERTY_READ("Transaction", "i", Connection_Transaction),
|
||||
GB_STATIC_PROPERTY("IgnoreCharset", "b", CCONNECTION_ignore_charset),
|
||||
GB_STATIC_PROPERTY_READ("Collations", "String[]", Connection_Collations),
|
||||
GB_STATIC_PROPERTY_READ("Handle", "p", Connection_Handle),
|
||||
|
|
|
@ -59,13 +59,24 @@ int CRESULTFIELD_find(CRESULT *result, const char *name, bool error)
|
|||
if (result->handle)
|
||||
index = result->driver->Result.Field.Index(result->handle, (char *)name, &result->conn->db);
|
||||
else
|
||||
{
|
||||
for (index = 0; index < result->info.nfield; index++)
|
||||
{
|
||||
if (strcmp(name, result->info.field[index].name) == 0)
|
||||
break;
|
||||
}
|
||||
}
|
||||
{
|
||||
if (result->conn->db.flags.no_case)
|
||||
{
|
||||
for (index = 0; index < result->info.nfield; index++)
|
||||
{
|
||||
if (strcasecmp(name, result->info.field[index].name) == 0)
|
||||
break;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
for (index = 0; index < result->info.nfield; index++)
|
||||
{
|
||||
if (strcmp(name, result->info.field[index].name) == 0)
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (index < 0 || index >= result->info.nfield)
|
||||
{
|
||||
|
|
|
@ -61,7 +61,7 @@ typedef
|
|||
unsigned no_blob : 1; /* Blob fields are not supported */
|
||||
unsigned no_seek : 1; /* Cannot seek anywhere in a Result */
|
||||
unsigned no_nest : 1; /* Cannot nest transactions */
|
||||
unsigned no_case : 1; /* If table, field and index names can be case sensitive or not */
|
||||
unsigned no_case : 1; /* table, field and index names must be converted to lower case */
|
||||
unsigned schema : 1; /* If table names can be prefixed by a schema name and a dot */
|
||||
unsigned no_collation : 1; /* No collation support at field level */
|
||||
}
|
||||
|
@ -232,6 +232,7 @@ typedef
|
|||
struct {
|
||||
void (*Init)(void);
|
||||
void (*Add)(const char *);
|
||||
void (*AddLower)(const char *);
|
||||
void (*AddLength)(const char *, int);
|
||||
char *(*Get)(void);
|
||||
char *(*GetNew)(void);
|
||||
|
|
|
@ -413,6 +413,26 @@ void q_add(const char *str)
|
|||
q_add_length(str, strlen(str));
|
||||
}
|
||||
|
||||
void q_add_lower(const char *str)
|
||||
{
|
||||
int i, len;
|
||||
char *lstr;
|
||||
|
||||
if (!str)
|
||||
return;
|
||||
|
||||
len = strlen(str);
|
||||
|
||||
if (len <= 0)
|
||||
return;
|
||||
|
||||
lstr = GB.TempString(str, len);
|
||||
for (i = 0; i < len; i++)
|
||||
lstr[i] = GB.ToLower(lstr[i]);
|
||||
|
||||
q_add_length(lstr, len);
|
||||
}
|
||||
|
||||
char *q_get(void)
|
||||
{
|
||||
q_dump_temp();
|
||||
|
@ -639,6 +659,7 @@ void *GB_DB_1[] EXPORT = {
|
|||
|
||||
(void *)q_init,
|
||||
(void *)q_add,
|
||||
(void *)q_add_lower,
|
||||
(void *)q_add_length,
|
||||
(void *)q_get,
|
||||
(void *)q_steal,
|
||||
|
|
|
@ -38,9 +38,11 @@
|
|||
int MEMORY_count = 0;
|
||||
|
||||
//#define DEBUG_ME
|
||||
//#define DO_NOT_PRINT_MEMORY
|
||||
|
||||
#if defined(DEBUG_ME) || DEBUG_MEMORY
|
||||
size_t MEMORY_size = 0;
|
||||
size_t MEMORY_pool_size = 0;
|
||||
#endif
|
||||
|
||||
#if DEBUG_MEMORY
|
||||
|
@ -65,6 +67,8 @@ FILE *MEMORY_log;
|
|||
|
||||
static size_t *_pool[POOL_SIZE] = { 0 };
|
||||
static int _pool_count[POOL_SIZE] = { 0 };
|
||||
/*static size_t *_first_alloc = 0;
|
||||
static size_t *_max_alloc = 0;*/
|
||||
|
||||
#endif
|
||||
|
||||
|
@ -97,7 +101,7 @@ void MEMORY_clear_cache()
|
|||
{
|
||||
next = *((void **)ptr);
|
||||
size += (i + 1) * SIZE_INC;
|
||||
#if DEBUG_ME
|
||||
#ifdef DEBUG_ME
|
||||
MEMORY_size -= (i + 1) * SIZE_INC;
|
||||
#endif
|
||||
free(ptr);
|
||||
|
@ -107,7 +111,7 @@ void MEMORY_clear_cache()
|
|||
_pool_count[i] = 0;
|
||||
}
|
||||
|
||||
#if DEBUG_ME
|
||||
#ifdef DEBUG_ME
|
||||
fprintf(stderr, "free %ld bytes [%ld / %p]\n", size, MEMORY_size, sbrk(0));
|
||||
#endif
|
||||
|
||||
|
@ -331,6 +335,9 @@ void MEMORY_free(void *p_ptr)
|
|||
|
||||
#if OPTIMIZE_MEMORY
|
||||
|
||||
//void DEBUG_print_current_backtrace(void);
|
||||
//static bool _print_backtrace = FALSE;
|
||||
|
||||
void *my_malloc(size_t len)
|
||||
{
|
||||
size_t *ptr;
|
||||
|
@ -344,8 +351,9 @@ void *my_malloc(size_t len)
|
|||
if (_pool_count[pool])
|
||||
{
|
||||
ptr = _pool[pool];
|
||||
#ifdef DEBUG_ME
|
||||
fprintf(stderr, "my_malloc: %d bytes from pool #%d -> %p [%ld / %p]\n", size, pool, ptr + 1, MEMORY_size, sbrk(0));
|
||||
#if defined(DEBUG_ME) && !defined(DO_NOT_PRINT_MEMORY)
|
||||
MEMORY_pool_size -= size;
|
||||
fprintf(stderr, "my_malloc: %d bytes from pool #%d -> %p (%p) [%ld / %ld]\n", size, pool, ptr + 1, sbrk(0), MEMORY_size - MEMORY_pool_size, MEMORY_size);
|
||||
#endif
|
||||
_pool[pool] = *((void **)ptr);
|
||||
_pool_count[pool]--;
|
||||
|
@ -360,9 +368,21 @@ void *my_malloc(size_t len)
|
|||
ptr = malloc(size);
|
||||
if (!ptr)
|
||||
THROW_MEMORY();
|
||||
#ifdef DEBUG_ME
|
||||
fprintf(stderr, "my_malloc: %d bytes from malloc -> %p [%ld / %p]\n", size, ptr + 1, MEMORY_size, sbrk(0));
|
||||
#if defined(DEBUG_ME) && !defined(DO_NOT_PRINT_MEMORY)
|
||||
fprintf(stderr, "my_malloc: %d bytes from malloc -> %p (%p) [%ld / %ld]\n", size, ptr + 1, sbrk(0), MEMORY_size - MEMORY_pool_size, MEMORY_size);
|
||||
#endif
|
||||
|
||||
/*if (!_first_alloc)
|
||||
_first_alloc = ptr;
|
||||
if (ptr > _max_alloc && !_print_backtrace)
|
||||
{
|
||||
_max_alloc = ptr;
|
||||
fprintf(stderr, "%ld\n", (char *)_max_alloc - (char *)_first_alloc + size);
|
||||
_print_backtrace = TRUE;
|
||||
DEBUG_print_current_backtrace();
|
||||
_print_backtrace = FALSE;
|
||||
}*/
|
||||
|
||||
*ptr++ = size;
|
||||
return ptr;
|
||||
}
|
||||
|
@ -384,23 +404,30 @@ void my_free(void *alloc)
|
|||
size = (int)*ptr;
|
||||
pool = (size / SIZE_INC) - 1;
|
||||
|
||||
if (pool < POOL_SIZE)
|
||||
//if (ptr < (_first_alloc + (_max_alloc - _first_alloc) / 2))
|
||||
if (1)
|
||||
{
|
||||
if (_pool_count[pool] < POOL_MAX)
|
||||
if (pool < POOL_SIZE)
|
||||
{
|
||||
#ifdef DEBUG_ME
|
||||
fprintf(stderr, "my_free: (%p) %d bytes to pool #%d [%ld / %p]\n", alloc, size, pool, MEMORY_size, sbrk(0));
|
||||
#endif
|
||||
*((void **)ptr) = _pool[pool];
|
||||
_pool[pool] = ptr;
|
||||
_pool_count[pool]++;
|
||||
return;
|
||||
if (_pool_count[pool] < POOL_MAX)
|
||||
{
|
||||
#if defined(DEBUG_ME) && !defined(DO_NOT_PRINT_MEMORY)
|
||||
MEMORY_pool_size += size;
|
||||
fprintf(stderr, "my_free: %p (%p) -> %d bytes to pool #%d [%ld / %ld]\n", alloc, sbrk(0), size, pool, MEMORY_size - MEMORY_pool_size, MEMORY_size);
|
||||
#endif
|
||||
*((void **)ptr) = _pool[pool];
|
||||
_pool[pool] = ptr;
|
||||
_pool_count[pool]++;
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
#ifdef DEBUG_ME
|
||||
MEMORY_size -= size;
|
||||
fprintf(stderr, "my_free: (%p) %d bytes freed [%ld / %p]\n", alloc, size, MEMORY_size, sbrk(0));
|
||||
#ifndef DO_NOT_PRINT_MEMORY
|
||||
fprintf(stderr, "my_free: %p (%p) -> %d bytes freed [%ld / %ld]\n", alloc, sbrk(0), size, MEMORY_size - MEMORY_pool_size, MEMORY_size);
|
||||
#endif
|
||||
#endif
|
||||
free(ptr);
|
||||
}
|
||||
|
@ -422,8 +449,8 @@ void *my_realloc(void *alloc, size_t new_len)
|
|||
if (size == new_size)
|
||||
return alloc;
|
||||
|
||||
#ifdef DEBUG_ME
|
||||
fprintf(stderr, "my_realloc: (%p) %d -> %d\n", alloc, size, new_size);
|
||||
#if defined(DEBUG_ME) && !defined(DO_NOT_PRINT_MEMORY)
|
||||
fprintf(stderr, "my_realloc: %p (%p) -> %d ==> %d\n", alloc, sbrk(0), size, new_size);
|
||||
#endif
|
||||
|
||||
if (new_len == 0)
|
||||
|
@ -435,7 +462,9 @@ void *my_realloc(void *alloc, size_t new_len)
|
|||
{
|
||||
#ifdef DEBUG_ME
|
||||
MEMORY_size += new_size - size;
|
||||
fprintf(stderr, "my_realloc: (%p) %d bytes reallocated to %d [%ld / %p]\n", alloc, size, new_size, MEMORY_size, sbrk(0));
|
||||
#ifndef DO_NOT_PRINT_MEMORY
|
||||
fprintf(stderr, "my_realloc: %p (%p) -> %d bytes reallocated to %d [%ld / %ld]\n", alloc, sbrk(0), size, new_size, MEMORY_size - MEMORY_pool_size, MEMORY_size);
|
||||
#endif
|
||||
#endif
|
||||
ptr = realloc(ptr, new_size);
|
||||
if (!ptr)
|
||||
|
|
Loading…
Reference in a new issue