[DEVELOPMENT ENVIRONMENT]

* BUG: Fix table creation and renaming dialog when checking if a table name 
  already exists.

[GB.DB]
* BUG: Table quoting works as expected now.

[GB.DB.POSTGRESQL]
* NEW: Now, if no schema is specified in a table name, the "public" schema 
  is used. Consequently, the schema must be specified, unless the table is
  in the "public" schema.


git-svn-id: svn://localhost/gambas/trunk@2443 867c0c6c-44f3-4631-809d-bfa615b0a4ec
This commit is contained in:
Benoît Minisini 2009-11-28 02:05:10 +00:00
parent 83d84d7ee5
commit 71db2b5689
6 changed files with 50 additions and 55 deletions

View File

@ -350,7 +350,7 @@ msgstr ""
#: FCommit.class:391 FConnectionEditor.class:398 FCreateFile.class:879
#: FFontChooser.class:80 FGotoLine.class:57 FList.class:333 FMain.class:2768
#: FMakeExecutable.class:138 FMenu.class:1091 FNewConnection.class:586
#: FNewTable.class:161 FNewTranslation.class:64 FOpenProject.class:433
#: FNewTable.class:162 FNewTranslation.class:64 FOpenProject.class:433
#: FPasteSpecial.class:273 FPropertyProject.class:252
#: FSelectExtraFile.class:72 FSelectIcon.class:266 FTableChooser.class:139
#: FText.class:101
@ -438,7 +438,7 @@ msgstr ""
#: FFontChooser.class:86 FForm.class:2821 FGotoLine.class:63
#: FIconEditor.class:1393 FImportTable.class:38 FList.class:155
#: FMain.class:203 FMakeExecutable.class:144 FMakeInstall.class:309
#: FMenu.class:1097 FNewConnection.class:317 FNewTable.class:167
#: FMenu.class:1097 FNewConnection.class:317 FNewTable.class:168
#: FNewTranslation.class:70 FOpenProject.class:146 FPasteSpecial.class:279
#: FPropertyProject.class:1236 FSave.class:118 FSelectExtraFile.class:78
#: FSelectIcon.class:271 FTableChooser.class:145 FTextEditor.class:462
@ -475,31 +475,31 @@ msgid ""
"Some files are not versioned and should be added manually to the repository."
msgstr ""
#: FCommit.class:234 FConflict.class:327 FConnectionEditor.class:1783
#: FCommit.class:234 FConflict.class:327 FConnectionEditor.class:1777
#: FEditor.class:3200 FForm.class:3360 FIconEditor.class:2168
#: FOutput.class:473 FTextEditor.class:660
msgid "Cut"
msgstr ""
#: FCommit.class:241 FConflict.class:334 FConnectionEditor.class:1681
#: FCommit.class:241 FConflict.class:334 FConnectionEditor.class:1675
#: FEditor.class:3206 FForm.class:3367 FIconEditor.class:2177
#: FOutput.class:480 FTextEditor.class:667
msgid "Copy"
msgstr ""
#: FCommit.class:248 FConflict.class:341 FConnectionEditor.class:1807
#: FCommit.class:248 FConflict.class:341 FConnectionEditor.class:1801
#: FEditor.class:3213 FForm.class:3374 FIconEditor.class:2186
#: FOutput.class:487 FTextEditor.class:674
msgid "Paste"
msgstr ""
#: FCommit.class:255 FConflict.class:348 FConnectionEditor.class:1815
#: FCommit.class:255 FConflict.class:348 FConnectionEditor.class:1809
#: FEditor.class:3183 FForm.class:3602 FIconEditor.class:2150
#: FOption.class:1136 FOutput.class:455 FTextEditor.class:642
msgid "Undo"
msgstr ""
#: FCommit.class:262 FConflict.class:355 FConnectionEditor.class:1823
#: FCommit.class:262 FConflict.class:355 FConnectionEditor.class:1817
#: FEditor.class:3190 FForm.class:3613 FOutput.class:462 FTextEditor.class:649
msgid "Redo"
msgstr ""
@ -620,12 +620,12 @@ msgstr ""
#: FConnectionEditor.class:32 FCreateFile.class:733 FCreateProject.class:640
#: FDebugInfo.class:30 FMenu.class:884 FNewConnection.class:394
#: FNewTable.class:111
#: FNewTable.class:112
msgid "Name"
msgstr ""
#: FConnectionEditor.class:37 FCreateFile.class:786 FCreateProject.class:368
#: FInfo.class:333 FNewConnection.class:409 FNewTable.class:127
#: FInfo.class:333 FNewConnection.class:409 FNewTable.class:128
#: FPropertyProject.class:889
msgid "Type"
msgstr ""
@ -776,80 +776,80 @@ msgstr ""
msgid "Remove"
msgstr ""
#: FConnectionEditor.class:1525
#: FConnectionEditor.class:1519
msgid "Connection editor"
msgstr ""
#: FConnectionEditor.class:1540 FEditor.class:2128 FForm.class:2821
#: FConnectionEditor.class:1534 FEditor.class:2128 FForm.class:2821
#: FIconEditor.class:2032 FTextEditor.class:462 FTranslate.class:700
msgid "Reload"
msgstr ""
#: FConnectionEditor.class:1548 FNewTable.class:97
#: FConnectionEditor.class:1542 FNewTable.class:98
msgid "New table"
msgstr ""
#: FConnectionEditor.class:1555
#: FConnectionEditor.class:1549
msgid "Delete table"
msgstr ""
#: FConnectionEditor.class:1562 FNewTable.class:29
#: FConnectionEditor.class:1556 FNewTable.class:30
msgid "Rename table"
msgstr ""
#: FConnectionEditor.class:1564
#: FConnectionEditor.class:1558
msgid "Rename..."
msgstr ""
#: FConnectionEditor.class:1570
#: FConnectionEditor.class:1564
msgid "Import text file"
msgstr ""
#: FConnectionEditor.class:1572
#: FConnectionEditor.class:1566
msgid "Import..."
msgstr ""
#: FConnectionEditor.class:1578
#: FConnectionEditor.class:1572
msgid "SQL request"
msgstr ""
#: FConnectionEditor.class:1637
#: FConnectionEditor.class:1631
msgid "Fields"
msgstr ""
#: FConnectionEditor.class:1654 FMain.class:1609
#: FConnectionEditor.class:1648 FMain.class:1609
msgid "Add"
msgstr ""
#: FConnectionEditor.class:1668
#: FConnectionEditor.class:1662
msgid "Down"
msgstr ""
#: FConnectionEditor.class:1675
#: FConnectionEditor.class:1669
msgid "Up"
msgstr ""
#: FConnectionEditor.class:1683
#: FConnectionEditor.class:1677
msgid "Copy field list"
msgstr ""
#: FConnectionEditor.class:1700
#: FConnectionEditor.class:1694
msgid "Indexes"
msgstr ""
#: FConnectionEditor.class:1718
#: FConnectionEditor.class:1712
msgid "New index"
msgstr ""
#: FConnectionEditor.class:1777
#: FConnectionEditor.class:1771
msgid "Run query"
msgstr ""
#: FConnectionEditor.class:1831
#: FConnectionEditor.class:1825
msgid "Test"
msgstr ""
#: FConnectionEditor.class:1888
#: FConnectionEditor.class:1882
msgid "Export..."
msgstr ""
@ -2851,15 +2851,15 @@ msgstr ""
msgid "Ignore database charset"
msgstr ""
#: FNewTable.class:32
#: FNewTable.class:33
msgid "Create table"
msgstr ""
#: FNewTable.class:52
#: FNewTable.class:53
msgid "Please enter the name of the new table."
msgstr ""
#: FNewTable.class:58 MConnection.module:277
#: FNewTable.class:59 MConnection.module:272
msgid "Table '&1' already exists."
msgstr ""
@ -3882,7 +3882,7 @@ msgstr ""
msgid "Unknown"
msgstr ""
#: MConnection.module:290
#: MConnection.module:285
msgid "Cannot create table '&1'."
msgstr ""

View File

@ -258,12 +258,7 @@ Public Function CountTableData(Handle As Connection, sTable As String) As Intege
Dim rResult As Result
Dim iPos As Integer
iPos = InStr(sTable, ".")
If iPos Then
rResult = Handle.Exec("SELECT COUNT(*) AS nRecord FROM " & Left(sTable, iPos) & Handle.Quote(Mid$(sTable, iPos + 1)))
Else
rResult = Handle.Exec("SELECT COUNT(*) AS nRecord FROM " & Handle.Quote(sTable))
Endif
rResult = Handle.Exec("SELECT COUNT(*) AS nRecord FROM " & Handle.Quote(sTable, True))
Return rResult!nRecord
End

View File

@ -407,7 +407,7 @@ Public Sub tbvField_Data(Row As Integer, Column As Integer)
Dim hCField As CField
hCField = $aField[Row]
Try hCField = $aField[Row]
If Not hCField Then Return
With tbvField.Data
@ -1250,7 +1250,7 @@ Public Sub btnNewTable_Click()
aType = ["MyISAM", "MERGE", "HEAP", "InnoDB", "BDB", "ISAM"]
Endif
If FNewTable.Run("", "InnoDB", aType) Then Return
If FNewTable.Run($hConn, "", "InnoDB", aType) Then Return
sName = FNewTable.TableName
If MConnection.CreateTable($hConn, sName, FNewTable.Type) Then Return
@ -1336,7 +1336,7 @@ Public Sub btnRename_Click()
If $bReadOnly Then Return
If SaveTable() Then Return
If FNewTable.Run($sTable, $sType) Then Return
If FNewTable.Run($hConn, $sTable, $sType) Then Return
sNewName = FNewTable.TableName
If Not sNewName Then Return
@ -1436,13 +1436,7 @@ End
Public Sub ToolButton1_Click()
Dim sStr As String
Dim iInd As Integer
For iInd = 0 To 255
sStr &= Chr$(iInd)
Next
Print $hConn.FormatBlob(sStr)
Print $hConn.Quote("haddock")
Print $hConn.Quote("haddock", True)
End

View File

@ -5,11 +5,12 @@ Static Public TableType As String
Static Private $aType As String[]
Static Public Function Run(Optional sTable As String, Optional sType As String, Optional aType As String[]) As Boolean
Static Public Function Run(hConn As Connection, Optional sTable As String, Optional sType As String, Optional aType As String[]) As Boolean
TableName = sTable
TableType = sType
$aType = aType
DB.Current = hConn
Return Not FNewTable.ShowModal()
End

View File

@ -199,7 +199,8 @@ static bool get_table_schema(const char **table, char **schema)
if (!point)
{
//fprintf(stderr, "get_table_schema: -> No point\n");
return TRUE;
*schema = "public";
return FALSE;
}
GB.TempString(schema, *table, point - *table);
@ -1385,11 +1386,15 @@ static int table_exist(DB_DATABASE *db, const char *table)
"and (relnamespace not in (select oid from pg_namespace where nspname = 'information_schema'))";
const char *query_schema =
"select pg_class.relname,pg_namespace.nspname from pg_class,pg_namespace where (pg_class.relkind = 'r' or pg_class.relkind = 'v') "
"select relname from pg_class where (relkind = 'r' or relkind = 'v') "
"and (relname = '&1') "
"and (relnamespace in (select oid from pg_namespace where nspname = '&2'))";
/*"select pg_class.relname,pg_namespace.nspname from pg_class,pg_namespace where (pg_class.relkind = 'r' or pg_class.relkind = 'v') "
"and (pg_namespace.oid = pg_class.relnamespace) "
"and (pg_class.relname = '&1') "
"and (pg_namespace.nspname = '&2') "
"and (pg_namespace.oid not in (select oid from pg_namespace where nspname = 'information_schema'))";
"and (pg_namespace.oid not in (select oid from pg_namespace where nspname = 'information_schema'))";*/
PGresult *res;
int exist;
@ -1453,7 +1458,7 @@ static int table_list_73(DB_DATABASE *db, char ***tables)
for (i = 0; i < PQntuples(res); i++)
{
schema = PQgetvalue(res, i, 1);
if (!strcmp(schema, "public") || !strcmp(schema, "pg_catalog"))
if (!strcmp(schema, "public")) // || !strcmp(schema, "pg_catalog"))
GB.NewString(&((*tables)[i]), PQgetvalue(res, i, 0), 0);
else
{

View File

@ -584,7 +584,7 @@ char *DB_GetQuotedTable(DB_DRIVER *driver, DB_DATABASE *db, const char *table)
if (!point)
{
GB.TempString(&res, NULL, len + 2);
sprintf(res, "%s%s%s", table, quote, quote);
sprintf(res, "%s%s%s", quote, table, quote);
}
else
{