diff --git a/app/other/MakeWebSite/.project b/app/other/MakeWebSite/.project index fd97c59f4..9cedf18ef 100644 --- a/app/other/MakeWebSite/.project +++ b/app/other/MakeWebSite/.project @@ -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 diff --git a/app/other/MakeWebSite/.settings b/app/other/MakeWebSite/.settings index 9083e4f3f..017879f3b 100644 --- a/app/other/MakeWebSite/.settings +++ b/app/other/MakeWebSite/.settings @@ -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" diff --git a/app/other/MakeWebSite/.src/MMain.module b/app/other/MakeWebSite/.src/MMain.module index 3652e8110..e06bcb569 100644 --- a/app/other/MakeWebSite/.src/MMain.module +++ b/app/other/MakeWebSite/.src/MMain.module @@ -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 diff --git a/app/other/MakeWebSite/.startup b/app/other/MakeWebSite/.startup index 34a660803..f86e1f496 100644 --- a/app/other/MakeWebSite/.startup +++ b/app/other/MakeWebSite/.startup @@ -2,7 +2,7 @@ MMain Gambas web site generator 0 0 -3.5.90 +3.6.0 gb.image gb.gui diff --git a/app/other/MakeWebSite/gambas.sourceforge.net/home.html b/app/other/MakeWebSite/gambas.sourceforge.net/home.html index 32d668f8a..9a26ca3cc 100644 --- a/app/other/MakeWebSite/gambas.sourceforge.net/home.html +++ b/app/other/MakeWebSite/gambas.sourceforge.net/home.html @@ -41,10 +41,10 @@
- - {Download} Gambas 3.5.4 + + {Download} Gambas 3.6.0 -
{Release Notes}
+
{Release Notes}
diff --git a/app/src/gambas3/.src/Connection/MConnection.module b/app/src/gambas3/.src/Connection/MConnection.module index eff0fdc7a..2561c3063 100644 --- a/app/src/gambas3/.src/Connection/MConnection.module +++ b/app/src/gambas3/.src/Connection/MConnection.module @@ -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 diff --git a/app/src/gambas3/.src/Editor/Code/FEditor.class b/app/src/gambas3/.src/Editor/Code/FEditor.class index bd7437a6d..bab43e20c 100644 --- a/app/src/gambas3/.src/Editor/Code/FEditor.class +++ b/app/src/gambas3/.src/Editor/Code/FEditor.class @@ -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 diff --git a/app/src/gambas3/.src/Editor/Connection/FConnectionEditor.class b/app/src/gambas3/.src/Editor/Connection/FConnectionEditor.class index 208616f5d..a2dfdc221 100644 --- a/app/src/gambas3/.src/Editor/Connection/FConnectionEditor.class +++ b/app/src/gambas3/.src/Editor/Connection/FConnectionEditor.class @@ -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) diff --git a/app/src/gambas3/.src/Search/FSearch.class b/app/src/gambas3/.src/Search/FSearch.class index 140493748..6a37154ea 100644 --- a/app/src/gambas3/.src/Search/FSearch.class +++ b/app/src/gambas3/.src/Search/FSearch.class @@ -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 diff --git a/app/src/gambas3/.src/Welcome/FSystemInfo.class b/app/src/gambas3/.src/Welcome/FSystemInfo.class index 3153012f9..2998a8c4a 100644 --- a/app/src/gambas3/.src/Welcome/FSystemInfo.class +++ b/app/src/gambas3/.src/Welcome/FSystemInfo.class @@ -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]") diff --git a/comp/src/gb.gui.base/.src/IconView/IconView.class b/comp/src/gb.gui.base/.src/IconView/IconView.class index fba997f31..06d931138 100644 --- a/comp/src/gb.gui.base/.src/IconView/IconView.class +++ b/comp/src/gb.gui.base/.src/IconView/IconView.class @@ -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 diff --git a/comp/src/gb.gui.base/.src/IconView/_IconView_Item.class b/comp/src/gb.gui.base/.src/IconView/_IconView_Item.class index 7d7836c11..a3b40461a 100644 --- a/comp/src/gb.gui.base/.src/IconView/_IconView_Item.class +++ b/comp/src/gb.gui.base/.src/IconView/_IconView_Item.class @@ -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) diff --git a/examples/examples/Misc/Explorer/.icon.png b/examples/examples/Misc/Explorer/.icon.png index aa738dca8..20a808354 100644 Binary files a/examples/examples/Misc/Explorer/.icon.png and b/examples/examples/Misc/Explorer/.icon.png differ diff --git a/examples/examples/Misc/Explorer/.project b/examples/examples/Misc/Explorer/.project index 02e8e1774..19d3a7709 100644 --- a/examples/examples/Misc/Explorer/.project +++ b/examples/examples/Misc/Explorer/.project @@ -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 diff --git a/gb.db.postgresql/src/main.c b/gb.db.postgresql/src/main.c index df840979c..6a59ef03f 100644 --- a/gb.db.postgresql/src/main.c +++ b/gb.db.postgresql/src/main.c @@ -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(")"); diff --git a/gb.qt4/src/ext/gdocument.cpp b/gb.qt4/src/ext/gdocument.cpp index a39c9777c..e50ae8698 100644 --- a/gb.qt4/src/ext/gdocument.cpp +++ b/gb.qt4/src/ext/gdocument.cpp @@ -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; diff --git a/main/gbx/gbx_debug.c b/main/gbx/gbx_debug.c index 689508234..0ca76fb97 100644 --- a/main/gbx/gbx_debug.c +++ b/main/gbx/gbx_debug.c @@ -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); } diff --git a/main/lib/db/CConnection.c b/main/lib/db/CConnection.c index ce2136ba7..6b079b43a 100644 --- a/main/lib/db/CConnection.c +++ b/main/lib/db/CConnection.c @@ -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), diff --git a/main/lib/db/CResultField.c b/main/lib/db/CResultField.c index f46e9023d..8015415e8 100644 --- a/main/lib/db/CResultField.c +++ b/main/lib/db/CResultField.c @@ -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) { diff --git a/main/lib/db/gb.db.h b/main/lib/db/gb.db.h index 0722ac4a3..4f40eb2f2 100644 --- a/main/lib/db/gb.db.h +++ b/main/lib/db/gb.db.h @@ -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); diff --git a/main/lib/db/main.c b/main/lib/db/main.c index 65835ec0f..067297585 100644 --- a/main/lib/db/main.c +++ b/main/lib/db/main.c @@ -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, diff --git a/main/share/gb_alloc_temp.h b/main/share/gb_alloc_temp.h index f7ad97f56..31ee68109 100644 --- a/main/share/gb_alloc_temp.h +++ b/main/share/gb_alloc_temp.h @@ -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)