Переглянути джерело

Comparison: Removed db objects
modified: TurboBird.lpi
modified: TurboBird.lpr
modified: comparison.lfm
modified: comparison.pas
modified: newtable.lfm
modified: newtable.lrs
modified: newtable.pas
modified: scriptdb.pas
modified: systables.pas
modified: tablemanage.lfm
modified: tablemanage.lrs

motaz 13 роки тому
батько
коміт
4554f6b4b4
11 змінених файлів з 655 додано та 261 видалено
  1. 143 143
      TurboBird.lpi
  2. 1 1
      TurboBird.lpr
  3. 16 16
      comparison.lfm
  4. 373 33
      comparison.pas
  5. 0 1
      newtable.lfm
  6. 5 5
      newtable.lrs
  7. 1 14
      newtable.pas
  8. 1 1
      scriptdb.pas
  9. 73 5
      systables.pas
  10. 2 2
      tablemanage.lfm
  11. 40 40
      tablemanage.lrs

+ 143 - 143
TurboBird.lpi

@@ -63,7 +63,7 @@
         <EditorIndex Value="0"/>
         <WindowIndex Value="0"/>
         <TopLine Value="1"/>
-        <CursorPos X="26" Y="5"/>
+        <CursorPos X="12" Y="11"/>
         <UsageCount Value="200"/>
         <Loaded Value="True"/>
       </Unit0>
@@ -73,11 +73,10 @@
         <ComponentName Value="fmMain"/>
         <ResourceBaseClass Value="Form"/>
         <UnitName Value="main"/>
-        <IsVisibleTab Value="True"/>
         <EditorIndex Value="8"/>
         <WindowIndex Value="0"/>
-        <TopLine Value="3675"/>
-        <CursorPos X="19" Y="3698"/>
+        <TopLine Value="1913"/>
+        <CursorPos X="27" Y="1902"/>
         <UsageCount Value="200"/>
         <Loaded Value="True"/>
         <LoadedDesigner Value="True"/>
@@ -109,7 +108,7 @@
         <UnitName Value="Buttons"/>
         <TopLine Value="125"/>
         <CursorPos X="25" Y="141"/>
-        <UsageCount Value="28"/>
+        <UsageCount Value="27"/>
       </Unit4>
       <Unit5>
         <Filename Value="querywindow.pas"/>
@@ -130,13 +129,13 @@
         <UnitName Value="Dialogs"/>
         <TopLine Value="530"/>
         <CursorPos X="10" Y="489"/>
-        <UsageCount Value="9"/>
+        <UsageCount Value="8"/>
       </Unit6>
       <Unit7>
         <Filename Value="/usr/lib/lazarus/0.9.28.2/lcl/include/messagedialogs.inc"/>
         <TopLine Value="152"/>
         <CursorPos X="6" Y="159"/>
-        <UsageCount Value="9"/>
+        <UsageCount Value="8"/>
       </Unit7>
       <Unit8>
         <Filename Value="tableinfo.pas"/>
@@ -146,7 +145,7 @@
         <WindowIndex Value="0"/>
         <TopLine Value="67"/>
         <CursorPos X="6" Y="97"/>
-        <UsageCount Value="189"/>
+        <UsageCount Value="188"/>
       </Unit8>
       <Unit9>
         <Filename Value="viewview.pas"/>
@@ -198,10 +197,10 @@
         <ComponentName Value="fmNewTable"/>
         <ResourceBaseClass Value="Form"/>
         <UnitName Value="NewTable"/>
-        <EditorIndex Value="4"/>
+        <EditorIndex Value="3"/>
         <WindowIndex Value="0"/>
-        <TopLine Value="13"/>
-        <CursorPos X="13" Y="20"/>
+        <TopLine Value="79"/>
+        <CursorPos X="16" Y="85"/>
         <UsageCount Value="200"/>
         <Loaded Value="True"/>
         <LoadedDesigner Value="True"/>
@@ -247,19 +246,19 @@
         <UnitName Value="Interfaces"/>
         <TopLine Value="1"/>
         <CursorPos X="1" Y="1"/>
-        <UsageCount Value="7"/>
+        <UsageCount Value="6"/>
       </Unit17>
       <Unit18>
         <Filename Value="/usr/share/fpcsrc/2.2.4/rtl/objpas/sysutils/datih.inc"/>
         <TopLine Value="101"/>
         <CursorPos X="10" Y="130"/>
-        <UsageCount Value="5"/>
+        <UsageCount Value="4"/>
       </Unit18>
       <Unit19>
         <Filename Value="/usr/share/fpcsrc/2.2.4/rtl/objpas/sysutils/dati.inc"/>
         <TopLine Value="53"/>
         <CursorPos X="1" Y="1"/>
-        <UsageCount Value="3"/>
+        <UsageCount Value="2"/>
       </Unit19>
       <Unit20>
         <Filename Value="createtrigger.pas"/>
@@ -277,33 +276,33 @@
         <UnitName Value="sqldb"/>
         <TopLine Value="1643"/>
         <CursorPos X="17" Y="1647"/>
-        <UsageCount Value="4"/>
+        <UsageCount Value="3"/>
       </Unit21>
       <Unit22>
         <Filename Value="/usr/share/fpcsrc/2.2.4/packages/fcl-db/src/base/sqlscript.pp"/>
         <UnitName Value="sqlscript"/>
         <TopLine Value="472"/>
         <CursorPos X="23" Y="401"/>
-        <UsageCount Value="4"/>
+        <UsageCount Value="3"/>
       </Unit22>
       <Unit23>
         <Filename Value="/usr/share/fpcsrc/2.2.4/packages/fcl-db/src/base/db.pas"/>
         <UnitName Value="db"/>
         <TopLine Value="1759"/>
         <CursorPos X="15" Y="1783"/>
-        <UsageCount Value="9"/>
+        <UsageCount Value="8"/>
       </Unit23>
       <Unit24>
         <Filename Value="/usr/share/fpcsrc/2.2.4/packages/fcl-db/src/base/datasource.inc"/>
         <TopLine Value="467"/>
         <CursorPos X="26" Y="471"/>
-        <UsageCount Value="9"/>
+        <UsageCount Value="8"/>
       </Unit24>
       <Unit25>
         <Filename Value="/usr/share/fpcsrc/2.2.4/packages/fcl-db/src/base/dsparams.inc"/>
         <TopLine Value="1"/>
         <CursorPos X="1" Y="1"/>
-        <UsageCount Value="9"/>
+        <UsageCount Value="8"/>
       </Unit25>
       <Unit26>
         <Filename Value="indices.pas"/>
@@ -313,14 +312,14 @@
         <WindowIndex Value="0"/>
         <TopLine Value="27"/>
         <CursorPos X="1" Y="127"/>
-        <UsageCount Value="145"/>
+        <UsageCount Value="144"/>
       </Unit26>
       <Unit27>
         <Filename Value="/usr/lib/lazarus/0.9.28.2/components/cgi/ide/cgilazideintf.pas"/>
         <UnitName Value="CGILazIDEIntf"/>
         <TopLine Value="131"/>
         <CursorPos X="13" Y="138"/>
-        <UsageCount Value="8"/>
+        <UsageCount Value="7"/>
       </Unit27>
       <Unit28>
         <Filename Value="../spidercgi/freespiderideintf.pas"/>
@@ -328,14 +327,14 @@
         <WindowIndex Value="0"/>
         <TopLine Value="1"/>
         <CursorPos X="18" Y="21"/>
-        <UsageCount Value="84"/>
+        <UsageCount Value="83"/>
       </Unit28>
       <Unit29>
         <Filename Value="/usr/lib/lazarus/0.9.28.2/components/cgi/cgimodules.pas"/>
         <UnitName Value="cgiModules"/>
         <TopLine Value="1"/>
         <CursorPos X="1" Y="1"/>
-        <UsageCount Value="8"/>
+        <UsageCount Value="7"/>
       </Unit29>
       <Unit30>
         <Filename Value="/usr/lib/lazarus/0.9.28.2/ideintf/actionseditor.pas"/>
@@ -345,28 +344,28 @@
         <UnitName Value="ActionsEditor"/>
         <TopLine Value="1"/>
         <CursorPos X="30" Y="7"/>
-        <UsageCount Value="2"/>
+        <UsageCount Value="1"/>
       </Unit30>
       <Unit31>
         <Filename Value="/usr/lib/lazarus/0.9.28.2/ideintf/formeditingintf.pas"/>
         <UnitName Value="FormEditingIntf"/>
         <TopLine Value="14"/>
         <CursorPos X="55" Y="25"/>
-        <UsageCount Value="2"/>
+        <UsageCount Value="1"/>
       </Unit31>
       <Unit32>
         <Filename Value="/usr/lib/lazarus/0.9.28.2/ideintf/projectintf.pas"/>
         <UnitName Value="ProjectIntf"/>
         <TopLine Value="1"/>
         <CursorPos X="1" Y="1"/>
-        <UsageCount Value="2"/>
+        <UsageCount Value="1"/>
       </Unit32>
       <Unit33>
         <Filename Value="/usr/lib/lazarus/0.9.28.2/ideintf/lazideintf.pas"/>
         <UnitName Value="LazIDEIntf"/>
         <TopLine Value="14"/>
         <CursorPos X="24" Y="26"/>
-        <UsageCount Value="2"/>
+        <UsageCount Value="1"/>
       </Unit33>
       <Unit34>
         <Filename Value="edittable.pas"/>
@@ -384,7 +383,7 @@
         <UnitName Value="CustApp"/>
         <TopLine Value="231"/>
         <CursorPos X="11" Y="234"/>
-        <UsageCount Value="25"/>
+        <UsageCount Value="24"/>
       </Unit35>
       <Unit36>
         <Filename Value="callproc.pas"/>
@@ -446,7 +445,7 @@
         <UnitName Value="SynEdit"/>
         <TopLine Value="1075"/>
         <CursorPos X="14" Y="1097"/>
-        <UsageCount Value="12"/>
+        <UsageCount Value="11"/>
       </Unit41>
       <Unit42>
         <Filename Value="systables.pas"/>
@@ -456,8 +455,8 @@
         <UnitName Value="SysTables"/>
         <EditorIndex Value="1"/>
         <WindowIndex Value="0"/>
-        <TopLine Value="229"/>
-        <CursorPos X="1" Y="257"/>
+        <TopLine Value="299"/>
+        <CursorPos X="16" Y="332"/>
         <UsageCount Value="200"/>
         <Loaded Value="True"/>
         <LoadedDesigner Value="True"/>
@@ -467,7 +466,7 @@
         <UnitName Value="SynEditMiscClasses"/>
         <TopLine Value="89"/>
         <CursorPos X="14" Y="111"/>
-        <UsageCount Value="5"/>
+        <UsageCount Value="4"/>
       </Unit43>
       <Unit44>
         <Filename Value="constraints.pas"/>
@@ -477,7 +476,7 @@
         <WindowIndex Value="0"/>
         <TopLine Value="73"/>
         <CursorPos X="1" Y="95"/>
-        <UsageCount Value="97"/>
+        <UsageCount Value="96"/>
       </Unit44>
       <Unit45>
         <Filename Value="newconstraint.pas"/>
@@ -506,20 +505,20 @@
         <UnitName Value="DBGrids"/>
         <TopLine Value="510"/>
         <CursorPos X="16" Y="526"/>
-        <UsageCount Value="15"/>
+        <UsageCount Value="14"/>
       </Unit47>
       <Unit48>
         <Filename Value="/usr/lib/lazarus/0.9.28.2/lcl/controls.pp"/>
         <UnitName Value="Controls"/>
         <TopLine Value="859"/>
         <CursorPos X="5" Y="875"/>
-        <UsageCount Value="15"/>
+        <UsageCount Value="14"/>
       </Unit48>
       <Unit49>
         <Filename Value="/usr/share/fpcsrc/2.2.4/rtl/objpas/classes/classesh.inc"/>
         <TopLine Value="104"/>
         <CursorPos X="3" Y="120"/>
-        <UsageCount Value="15"/>
+        <UsageCount Value="14"/>
       </Unit49>
       <Unit50>
         <Filename Value="calen.pas"/>
@@ -538,8 +537,8 @@
         <UnitName Value="Scriptdb"/>
         <EditorIndex Value="7"/>
         <WindowIndex Value="0"/>
-        <TopLine Value="148"/>
-        <CursorPos X="3" Y="148"/>
+        <TopLine Value="1"/>
+        <CursorPos X="11" Y="15"/>
         <UsageCount Value="200"/>
         <Loaded Value="True"/>
       </Unit51>
@@ -550,7 +549,7 @@
         <UnitName Value="ConnectAs"/>
         <TopLine Value="1"/>
         <CursorPos X="1" Y="1"/>
-        <UsageCount Value="14"/>
+        <UsageCount Value="13"/>
       </Unit52>
       <Unit53>
         <Filename Value="userpermissions.pas"/>
@@ -569,7 +568,7 @@
         <WindowIndex Value="0"/>
         <TopLine Value="1"/>
         <CursorPos X="40" Y="18"/>
-        <UsageCount Value="13"/>
+        <UsageCount Value="12"/>
       </Unit54>
       <Unit55>
         <Filename Value="tablemanage.pas"/>
@@ -577,10 +576,13 @@
         <ComponentName Value="fmTableManage"/>
         <ResourceBaseClass Value="Form"/>
         <UnitName Value="TableManage"/>
+        <EditorIndex Value="4"/>
         <WindowIndex Value="0"/>
-        <TopLine Value="67"/>
-        <CursorPos X="7" Y="15"/>
-        <UsageCount Value="193"/>
+        <TopLine Value="128"/>
+        <CursorPos X="79" Y="156"/>
+        <UsageCount Value="200"/>
+        <Loaded Value="True"/>
+        <LoadedDesigner Value="True"/>
       </Unit55>
       <Unit56>
         <Filename Value="/usr/lib/lazarus/0.9.29/lcl/grids.pas"/>
@@ -588,7 +590,7 @@
         <WindowIndex Value="0"/>
         <TopLine Value="1"/>
         <CursorPos X="1" Y="1"/>
-        <UsageCount Value="10"/>
+        <UsageCount Value="9"/>
       </Unit56>
       <Unit57>
         <Filename Value="/usr/lib/lazarus/0.9.29/components/synedit/synedit.pp"/>
@@ -596,7 +598,7 @@
         <WindowIndex Value="0"/>
         <TopLine Value="783"/>
         <CursorPos X="30" Y="804"/>
-        <UsageCount Value="5"/>
+        <UsageCount Value="4"/>
       </Unit57>
       <Unit58>
         <Filename Value="/usr/lib/lazarus/0.9.29/components/synedit/synedittypes.pp"/>
@@ -604,7 +606,7 @@
         <WindowIndex Value="0"/>
         <TopLine Value="1"/>
         <CursorPos X="18" Y="38"/>
-        <UsageCount Value="5"/>
+        <UsageCount Value="4"/>
       </Unit58>
       <Unit59>
         <Filename Value="/usr/lib/lazarus/0.9.29/lcl/dialogs.pp"/>
@@ -612,7 +614,7 @@
         <WindowIndex Value="0"/>
         <TopLine Value="346"/>
         <CursorPos X="33" Y="369"/>
-        <UsageCount Value="5"/>
+        <UsageCount Value="4"/>
       </Unit59>
       <Unit60>
         <Filename Value="backuprestore.pas"/>
@@ -623,7 +625,7 @@
         <WindowIndex Value="0"/>
         <TopLine Value="13"/>
         <CursorPos X="22" Y="54"/>
-        <UsageCount Value="179"/>
+        <UsageCount Value="186"/>
       </Unit60>
       <Unit61>
         <Filename Value="unitfirebirdservices.pas"/>
@@ -631,7 +633,7 @@
         <WindowIndex Value="0"/>
         <TopLine Value="1"/>
         <CursorPos X="1" Y="1"/>
-        <UsageCount Value="23"/>
+        <UsageCount Value="22"/>
       </Unit61>
       <Unit62>
         <Filename Value="/usr/share/fpcsrc/2.4.0/packages/fcl-db/src/sqldb/interbase/ibconnection.pp"/>
@@ -639,7 +641,7 @@
         <WindowIndex Value="0"/>
         <TopLine Value="435"/>
         <CursorPos X="19" Y="447"/>
-        <UsageCount Value="3"/>
+        <UsageCount Value="2"/>
       </Unit62>
       <Unit63>
         <Filename Value="ibconnection.pp"/>
@@ -647,7 +649,7 @@
         <WindowIndex Value="0"/>
         <TopLine Value="141"/>
         <CursorPos X="71" Y="165"/>
-        <UsageCount Value="26"/>
+        <UsageCount Value="25"/>
       </Unit63>
       <Unit64>
         <Filename Value="/usr/share/fpcsrc/2.4.0/packages/fcl-db/src/sqldb/sqldb.pp"/>
@@ -655,7 +657,7 @@
         <WindowIndex Value="0"/>
         <TopLine Value="1"/>
         <CursorPos X="44" Y="23"/>
-        <UsageCount Value="7"/>
+        <UsageCount Value="6"/>
       </Unit64>
       <Unit65>
         <Filename Value="/usr/share/fpcsrc/2.4.0/packages/fcl-db/src/base/db.pas"/>
@@ -663,7 +665,7 @@
         <WindowIndex Value="0"/>
         <TopLine Value="1293"/>
         <CursorPos X="15" Y="1310"/>
-        <UsageCount Value="7"/>
+        <UsageCount Value="6"/>
       </Unit65>
       <Unit66>
         <Filename Value="/usr/share/fpcsrc/2.4.0/packages/fcl-db/src/base/sqlscript.pp"/>
@@ -671,14 +673,14 @@
         <WindowIndex Value="0"/>
         <TopLine Value="1"/>
         <CursorPos X="1" Y="1"/>
-        <UsageCount Value="3"/>
+        <UsageCount Value="2"/>
       </Unit66>
       <Unit67>
         <Filename Value="/usr/share/fpcsrc/2.4.0/packages/fcl-db/src/base/dataset.inc"/>
         <WindowIndex Value="0"/>
         <TopLine Value="21"/>
         <CursorPos X="1" Y="1"/>
-        <UsageCount Value="3"/>
+        <UsageCount Value="2"/>
       </Unit67>
       <Unit68>
         <Filename Value="createuser.pas"/>
@@ -689,7 +691,7 @@
         <WindowIndex Value="0"/>
         <TopLine Value="3"/>
         <CursorPos X="71" Y="7"/>
-        <UsageCount Value="149"/>
+        <UsageCount Value="156"/>
       </Unit68>
       <Unit69>
         <Filename Value="changepass.pas"/>
@@ -700,7 +702,7 @@
         <WindowIndex Value="0"/>
         <TopLine Value="3"/>
         <CursorPos X="88" Y="14"/>
-        <UsageCount Value="148"/>
+        <UsageCount Value="155"/>
       </Unit69>
       <Unit70>
         <Filename Value="permissionmanage.pas"/>
@@ -708,13 +710,10 @@
         <ComponentName Value="fmPermissionManage"/>
         <ResourceBaseClass Value="Form"/>
         <UnitName Value="PermissionManage"/>
-        <EditorIndex Value="3"/>
         <WindowIndex Value="0"/>
         <TopLine Value="341"/>
         <CursorPos X="54" Y="343"/>
-        <UsageCount Value="146"/>
-        <Loaded Value="True"/>
-        <LoadedDesigner Value="True"/>
+        <UsageCount Value="153"/>
       </Unit70>
       <Unit71>
         <Filename Value="sqlhistory.pas"/>
@@ -725,21 +724,21 @@
         <WindowIndex Value="0"/>
         <TopLine Value="1"/>
         <CursorPos X="35" Y="66"/>
-        <UsageCount Value="131"/>
+        <UsageCount Value="138"/>
       </Unit71>
       <Unit72>
         <Filename Value="../../lazarus/lazarus/lcl/include/menuitem.inc"/>
         <WindowIndex Value="0"/>
         <TopLine Value="57"/>
         <CursorPos X="1" Y="77"/>
-        <UsageCount Value="8"/>
+        <UsageCount Value="7"/>
       </Unit72>
       <Unit73>
         <Filename Value="../../lazarus/lazarus/lcl/include/menu.inc"/>
         <WindowIndex Value="0"/>
         <TopLine Value="241"/>
         <CursorPos X="1" Y="273"/>
-        <UsageCount Value="8"/>
+        <UsageCount Value="7"/>
       </Unit73>
       <Unit74>
         <Filename Value="copytable.pas"/>
@@ -750,7 +749,7 @@
         <WindowIndex Value="0"/>
         <TopLine Value="18"/>
         <CursorPos X="1" Y="44"/>
-        <UsageCount Value="102"/>
+        <UsageCount Value="109"/>
       </Unit74>
       <Unit75>
         <Filename Value="/usr/lib/lazarus/0.9.30/lcl/comctrls.pp"/>
@@ -758,14 +757,14 @@
         <WindowIndex Value="0"/>
         <TopLine Value="2685"/>
         <CursorPos X="3" Y="2707"/>
-        <UsageCount Value="6"/>
+        <UsageCount Value="5"/>
       </Unit75>
       <Unit76>
         <Filename Value="/usr/lib/lazarus/0.9.30/lcl/include/menuitem.inc"/>
         <WindowIndex Value="0"/>
         <TopLine Value="53"/>
         <CursorPos X="1" Y="75"/>
-        <UsageCount Value="6"/>
+        <UsageCount Value="5"/>
       </Unit76>
       <Unit77>
         <Filename Value="/usr/lib/lazarus/0.9.30/ide/lazconf.pp"/>
@@ -773,7 +772,7 @@
         <WindowIndex Value="0"/>
         <TopLine Value="1"/>
         <CursorPos X="1" Y="1"/>
-        <UsageCount Value="7"/>
+        <UsageCount Value="6"/>
       </Unit77>
       <Unit78>
         <Filename Value="/usr/lib/lazarus/0.9.30/ide/definetemplates.pas"/>
@@ -781,7 +780,7 @@
         <WindowIndex Value="0"/>
         <TopLine Value="1"/>
         <CursorPos X="1" Y="1"/>
-        <UsageCount Value="7"/>
+        <UsageCount Value="6"/>
       </Unit78>
       <Unit79>
         <Filename Value="/usr/lib/lazarus/0.9.30/ide/codetoolsstrconsts.pas"/>
@@ -789,7 +788,7 @@
         <WindowIndex Value="0"/>
         <TopLine Value="1"/>
         <CursorPos X="1" Y="1"/>
-        <UsageCount Value="7"/>
+        <UsageCount Value="6"/>
       </Unit79>
       <Unit80>
         <Filename Value="/usr/lib/lazarus/0.9.30/ide/expreval.pas"/>
@@ -797,7 +796,7 @@
         <WindowIndex Value="0"/>
         <TopLine Value="1"/>
         <CursorPos X="1" Y="1"/>
-        <UsageCount Value="7"/>
+        <UsageCount Value="6"/>
       </Unit80>
       <Unit81>
         <Filename Value="/usr/lib/lazarus/0.9.30/ide/buildlazdialog.pas"/>
@@ -805,7 +804,7 @@
         <WindowIndex Value="0"/>
         <TopLine Value="1"/>
         <CursorPos X="1" Y="1"/>
-        <UsageCount Value="7"/>
+        <UsageCount Value="6"/>
       </Unit81>
       <Unit82>
         <Filename Value="/usr/lib/lazarus/0.9.30/ide/laz2_xmlread.pas"/>
@@ -813,7 +812,7 @@
         <WindowIndex Value="0"/>
         <TopLine Value="1"/>
         <CursorPos X="1" Y="1"/>
-        <UsageCount Value="7"/>
+        <UsageCount Value="6"/>
       </Unit82>
       <Unit83>
         <Filename Value="/usr/lib/lazarus/0.9.30/ide/registersdf.pas"/>
@@ -821,7 +820,7 @@
         <WindowIndex Value="0"/>
         <TopLine Value="1"/>
         <CursorPos X="1" Y="1"/>
-        <UsageCount Value="7"/>
+        <UsageCount Value="6"/>
       </Unit83>
       <Unit84>
         <Filename Value="/usr/lib/lazarus/0.9.30/ide/printer4lazarus.pas"/>
@@ -829,7 +828,7 @@
         <WindowIndex Value="0"/>
         <TopLine Value="1"/>
         <CursorPos X="1" Y="1"/>
-        <UsageCount Value="7"/>
+        <UsageCount Value="6"/>
       </Unit84>
       <Unit85>
         <Filename Value="/usr/lib/lazarus/0.9.30/ide/printersdlgs.pp"/>
@@ -837,7 +836,7 @@
         <WindowIndex Value="0"/>
         <TopLine Value="1"/>
         <CursorPos X="1" Y="1"/>
-        <UsageCount Value="7"/>
+        <UsageCount Value="6"/>
       </Unit85>
       <Unit86>
         <Filename Value="/usr/lib/lazarus/0.9.30/ide/osprinters.pas"/>
@@ -845,7 +844,7 @@
         <WindowIndex Value="0"/>
         <TopLine Value="29"/>
         <CursorPos X="8" Y="49"/>
-        <UsageCount Value="7"/>
+        <UsageCount Value="6"/>
       </Unit86>
       <Unit87>
         <Filename Value="/usr/lib/lazarus/0.9.30/ide/lazcontrols.pas"/>
@@ -853,7 +852,7 @@
         <WindowIndex Value="0"/>
         <TopLine Value="1"/>
         <CursorPos X="1" Y="1"/>
-        <UsageCount Value="7"/>
+        <UsageCount Value="6"/>
       </Unit87>
       <Unit88>
         <Filename Value="/usr/lib/lazarus/0.9.30/ide/runtimetypeinfocontrols.pas"/>
@@ -861,7 +860,7 @@
         <WindowIndex Value="0"/>
         <TopLine Value="1"/>
         <CursorPos X="1" Y="1"/>
-        <UsageCount Value="7"/>
+        <UsageCount Value="6"/>
       </Unit88>
       <Unit89>
         <Filename Value="/usr/lib/lazarus/0.9.30/ide/rttictrls.pas"/>
@@ -869,7 +868,7 @@
         <WindowIndex Value="0"/>
         <TopLine Value="1"/>
         <CursorPos X="1" Y="1"/>
-        <UsageCount Value="6"/>
+        <UsageCount Value="5"/>
       </Unit89>
       <Unit90>
         <Filename Value="/usr/lib/lazarus/0.9.30/ide/rttigrids.pas"/>
@@ -877,7 +876,7 @@
         <WindowIndex Value="0"/>
         <TopLine Value="1"/>
         <CursorPos X="1" Y="1"/>
-        <UsageCount Value="6"/>
+        <UsageCount Value="5"/>
       </Unit90>
       <Unit91>
         <Filename Value="/usr/lib/lazarus/0.9.30/ide/sourceprinter.pas"/>
@@ -885,7 +884,7 @@
         <WindowIndex Value="0"/>
         <TopLine Value="1"/>
         <CursorPos X="1" Y="1"/>
-        <UsageCount Value="6"/>
+        <UsageCount Value="5"/>
       </Unit91>
       <Unit92>
         <Filename Value="/usr/lib/lazarus/0.9.30/ide/memdslaz.pas"/>
@@ -893,7 +892,7 @@
         <WindowIndex Value="0"/>
         <TopLine Value="1"/>
         <CursorPos X="1" Y="1"/>
-        <UsageCount Value="6"/>
+        <UsageCount Value="5"/>
       </Unit92>
       <Unit93>
         <Filename Value="/usr/lib/lazarus/0.9.30/ide/frmselectdataset.pp"/>
@@ -901,7 +900,7 @@
         <WindowIndex Value="0"/>
         <TopLine Value="156"/>
         <CursorPos X="4" Y="193"/>
-        <UsageCount Value="6"/>
+        <UsageCount Value="5"/>
       </Unit93>
       <Unit94>
         <Filename Value="../../lazarus/lazarus/lcl/controls.pp"/>
@@ -909,14 +908,14 @@
         <WindowIndex Value="0"/>
         <TopLine Value="139"/>
         <CursorPos X="23" Y="163"/>
-        <UsageCount Value="6"/>
+        <UsageCount Value="5"/>
       </Unit94>
       <Unit95>
         <Filename Value="../../lazarus/lazarus/lcl/include/control.inc"/>
         <WindowIndex Value="0"/>
         <TopLine Value="2262"/>
         <CursorPos X="1" Y="2286"/>
-        <UsageCount Value="11"/>
+        <UsageCount Value="10"/>
       </Unit95>
       <Unit96>
         <Filename Value="../../lazarus/lazarus/lcl/forms.pp"/>
@@ -924,14 +923,14 @@
         <WindowIndex Value="0"/>
         <TopLine Value="559"/>
         <CursorPos X="23" Y="600"/>
-        <UsageCount Value="7"/>
+        <UsageCount Value="6"/>
       </Unit96>
       <Unit97>
         <Filename Value="../../lazarus/lazarus/lcl/include/customform.inc"/>
         <WindowIndex Value="0"/>
         <TopLine Value="359"/>
         <CursorPos X="3" Y="381"/>
-        <UsageCount Value="7"/>
+        <UsageCount Value="6"/>
       </Unit97>
       <Unit98>
         <Filename Value="dbinfo.pas"/>
@@ -942,7 +941,7 @@
         <WindowIndex Value="0"/>
         <TopLine Value="20"/>
         <CursorPos X="22" Y="41"/>
-        <UsageCount Value="70"/>
+        <UsageCount Value="77"/>
       </Unit98>
       <Unit99>
         <Filename Value="../../FromInternet/fpc2.4/fpc-2.4.4/packages/ibase/src/ibase60dyn.pp"/>
@@ -950,14 +949,14 @@
         <WindowIndex Value="0"/>
         <TopLine Value="1"/>
         <CursorPos X="1" Y="1"/>
-        <UsageCount Value="9"/>
+        <UsageCount Value="8"/>
       </Unit99>
       <Unit100>
         <Filename Value="../../FromInternet/fpc2.4/fpc-2.4.4/packages/ibase/src/ibase60.inc"/>
         <WindowIndex Value="0"/>
         <TopLine Value="1"/>
         <CursorPos X="50" Y="6"/>
-        <UsageCount Value="9"/>
+        <UsageCount Value="8"/>
       </Unit100>
       <Unit101>
         <Filename Value="../FreeSpider/spiderutils.pas"/>
@@ -965,7 +964,7 @@
         <WindowIndex Value="0"/>
         <TopLine Value="1"/>
         <CursorPos X="1" Y="1"/>
-        <UsageCount Value="12"/>
+        <UsageCount Value="11"/>
       </Unit101>
       <Unit102>
         <Filename Value="comparison.pas"/>
@@ -973,11 +972,12 @@
         <ComponentName Value="fmComparison"/>
         <ResourceBaseClass Value="Form"/>
         <UnitName Value="Comparison"/>
+        <IsVisibleTab Value="True"/>
         <EditorIndex Value="2"/>
         <WindowIndex Value="0"/>
-        <TopLine Value="154"/>
-        <CursorPos X="26" Y="170"/>
-        <UsageCount Value="57"/>
+        <TopLine Value="1396"/>
+        <CursorPos X="81" Y="1423"/>
+        <UsageCount Value="64"/>
         <Loaded Value="True"/>
         <LoadedDesigner Value="True"/>
       </Unit102>
@@ -987,7 +987,7 @@
         <WindowIndex Value="0"/>
         <TopLine Value="815"/>
         <CursorPos X="11" Y="832"/>
-        <UsageCount Value="18"/>
+        <UsageCount Value="22"/>
         <Loaded Value="True"/>
       </Unit103>
       <Unit104>
@@ -995,77 +995,77 @@
         <WindowIndex Value="0"/>
         <TopLine Value="350"/>
         <CursorPos X="3" Y="352"/>
-        <UsageCount Value="11"/>
+        <UsageCount Value="10"/>
       </Unit104>
     </Units>
     <JumpHistory Count="30" HistoryIndex="29">
       <Position1>
         <Filename Value="comparison.pas"/>
-        <Caret Line="137" Column="17" TopLine="129"/>
+        <Caret Line="1039" Column="45" TopLine="1020"/>
       </Position1>
       <Position2>
         <Filename Value="comparison.pas"/>
-        <Caret Line="138" Column="3" TopLine="136"/>
+        <Caret Line="639" Column="1" TopLine="618"/>
       </Position2>
       <Position3>
         <Filename Value="comparison.pas"/>
-        <Caret Line="453" Column="22" TopLine="441"/>
+        <Caret Line="858" Column="66" TopLine="831"/>
       </Position3>
       <Position4>
         <Filename Value="comparison.pas"/>
-        <Caret Line="45" Column="9" TopLine="37"/>
+        <Caret Line="842" Column="24" TopLine="829"/>
       </Position4>
       <Position5>
         <Filename Value="comparison.pas"/>
-        <Caret Line="138" Column="17" TopLine="136"/>
+        <Caret Line="184" Column="23" TopLine="153"/>
       </Position5>
       <Position6>
         <Filename Value="comparison.pas"/>
-        <Caret Line="80" Column="15" TopLine="63"/>
+        <Caret Line="146" Column="3" TopLine="144"/>
       </Position6>
       <Position7>
         <Filename Value="comparison.pas"/>
-        <Caret Line="171" Column="78" TopLine="145"/>
+        <Caret Line="489" Column="1" TopLine="465"/>
       </Position7>
       <Position8>
-        <Filename Value="main.pas"/>
-        <Caret Line="670" Column="14" TopLine="663"/>
+        <Filename Value="comparison.pas"/>
+        <Caret Line="180" Column="39" TopLine="156"/>
       </Position8>
       <Position9>
-        <Filename Value="main.pas"/>
-        <Caret Line="1" Column="1" TopLine="1"/>
+        <Filename Value="comparison.pas"/>
+        <Caret Line="91" Column="15" TopLine="63"/>
       </Position9>
       <Position10>
-        <Filename Value="main.pas"/>
-        <Caret Line="93" Column="16" TopLine="65"/>
+        <Filename Value="newtable.pas"/>
+        <Caret Line="20" Column="13" TopLine="13"/>
       </Position10>
       <Position11>
-        <Filename Value="main.pas"/>
-        <Caret Line="124" Column="26" TopLine="96"/>
+        <Filename Value="newtable.pas"/>
+        <Caret Line="191" Column="1" TopLine="186"/>
       </Position11>
       <Position12>
-        <Filename Value="main.pas"/>
-        <Caret Line="641" Column="32" TopLine="634"/>
+        <Filename Value="newtable.pas"/>
+        <Caret Line="151" Column="14" TopLine="146"/>
       </Position12>
       <Position13>
-        <Filename Value="main.pas"/>
-        <Caret Line="649" Column="3" TopLine="644"/>
+        <Filename Value="newtable.pas"/>
+        <Caret Line="27" Column="1" TopLine="10"/>
       </Position13>
       <Position14>
-        <Filename Value="enterpass.pas"/>
-        <Caret Line="21" Column="75" TopLine="20"/>
+        <Filename Value="newtable.pas"/>
+        <Caret Line="15" Column="53" TopLine="11"/>
       </Position14>
       <Position15>
-        <Filename Value="main.pas"/>
-        <Caret Line="656" Column="38" TopLine="635"/>
+        <Filename Value="newtable.pas"/>
+        <Caret Line="161" Column="3" TopLine="144"/>
       </Position15>
       <Position16>
-        <Filename Value="main.pas"/>
-        <Caret Line="3693" Column="3" TopLine="3675"/>
+        <Filename Value="systables.pas"/>
+        <Caret Line="64" Column="14" TopLine="47"/>
       </Position16>
       <Position17>
         <Filename Value="main.pas"/>
-        <Caret Line="668" Column="1" TopLine="648"/>
+        <Caret Line="3936" Column="28" TopLine="3929"/>
       </Position17>
       <Position18>
         <Filename Value="main.pas"/>
@@ -1073,51 +1073,51 @@
       </Position18>
       <Position19>
         <Filename Value="main.pas"/>
-        <Caret Line="93" Column="16" TopLine="65"/>
+        <Caret Line="73" Column="15" TopLine="45"/>
       </Position19>
       <Position20>
         <Filename Value="main.pas"/>
-        <Caret Line="124" Column="26" TopLine="96"/>
+        <Caret Line="1810" Column="33" TopLine="1782"/>
       </Position20>
       <Position21>
         <Filename Value="main.pas"/>
-        <Caret Line="643" Column="35" TopLine="610"/>
+        <Caret Line="1832" Column="56" TopLine="1804"/>
       </Position21>
       <Position22>
         <Filename Value="main.pas"/>
-        <Caret Line="1" Column="1" TopLine="1"/>
+        <Caret Line="1902" Column="27" TopLine="1913"/>
       </Position22>
       <Position23>
-        <Filename Value="main.pas"/>
-        <Caret Line="93" Column="16" TopLine="65"/>
+        <Filename Value="comparison.pas"/>
+        <Caret Line="86" Column="39" TopLine="73"/>
       </Position23>
       <Position24>
-        <Filename Value="main.pas"/>
-        <Caret Line="124" Column="26" TopLine="96"/>
+        <Filename Value="comparison.pas"/>
+        <Caret Line="885" Column="35" TopLine="868"/>
       </Position24>
       <Position25>
-        <Filename Value="main.pas"/>
-        <Caret Line="638" Column="30" TopLine="610"/>
+        <Filename Value="systables.pas"/>
+        <Caret Line="298" Column="29" TopLine="294"/>
       </Position25>
       <Position26>
-        <Filename Value="main.pas"/>
-        <Caret Line="1" Column="1" TopLine="1"/>
+        <Filename Value="systables.pas"/>
+        <Caret Line="15" Column="18" TopLine="1"/>
       </Position26>
       <Position27>
-        <Filename Value="main.pas"/>
-        <Caret Line="224" Column="25" TopLine="196"/>
+        <Filename Value="systables.pas"/>
+        <Caret Line="300" Column="41" TopLine="300"/>
       </Position27>
       <Position28>
-        <Filename Value="main.pas"/>
-        <Caret Line="346" Column="14" TopLine="321"/>
+        <Filename Value="systables.pas"/>
+        <Caret Line="323" Column="23" TopLine="300"/>
       </Position28>
       <Position29>
-        <Filename Value="main.pas"/>
-        <Caret Line="640" Column="17" TopLine="618"/>
+        <Filename Value="comparison.pas"/>
+        <Caret Line="519" Column="19" TopLine="507"/>
       </Position29>
       <Position30>
-        <Filename Value="main.pas"/>
-        <Caret Line="646" Column="29" TopLine="639"/>
+        <Filename Value="comparison.pas"/>
+        <Caret Line="883" Column="35" TopLine="872"/>
       </Position30>
     </JumpHistory>
   </ProjectOptions>

+ 1 - 1
TurboBird.lpr

@@ -2,7 +2,7 @@
 {  TurboBird: FireBird database administration and management tool          }
 {  Developed by: Motaz Abdel Azeem http://code.sd/                          }
 {  Start development :  5.Dec.2009                                          }
-{  Last updated      : 21.May.2012                                          }
+{  Last updated      : 22.May.2012                                          }
 {  License           : GPL for GUI, LGPL for Units                          }
 {***************************************************************************}
 

+ 16 - 16
comparison.lfm

@@ -1,10 +1,10 @@
 object fmComparison: TfmComparison
   Left = 447
-  Height = 478
+  Height = 550
   Top = 170
   Width = 623
   Caption = 'Database comparison'
-  ClientHeight = 478
+  ClientHeight = 550
   ClientWidth = 623
   OnClose = FormClose
   Position = poScreenCenter
@@ -58,7 +58,7 @@ object fmComparison: TfmComparison
   object bbStart: TBitBtn
     Left = 13
     Height = 30
-    Top = 184
+    Top = 240
     Width = 154
     Caption = 'Start Comparison'
     OnClick = bbStartClick
@@ -66,8 +66,8 @@ object fmComparison: TfmComparison
   end
   object meLog: TMemo
     Left = 13
-    Height = 224
-    Top = 222
+    Height = 238
+    Top = 280
     Width = 603
     Anchors = [akTop, akLeft, akRight, akBottom]
     Font.Name = 'Courier 10 Pitch'
@@ -79,9 +79,9 @@ object fmComparison: TfmComparison
   end
   object laScript: TLabel
     Cursor = crHandPoint
-    Left = 187
+    Left = 190
     Height = 18
-    Top = 196
+    Top = 252
     Width = 301
     Caption = 'Script missing objects in compared database'
     Font.Style = [fsUnderline]
@@ -165,19 +165,11 @@ object fmComparison: TfmComparison
       Caption = 'Roles'
       TabOrder = 7
     end
-    object cxUsers: TCheckBox
-      Left = 495
-      Height = 24
-      Top = 4
-      Width = 64
-      Caption = 'Users'
-      TabOrder = 8
-    end
   end
   object StatusBar1: TStatusBar
     Left = 0
     Height = 21
-    Top = 457
+    Top = 529
     Width = 623
     Panels = <    
       item
@@ -185,4 +177,12 @@ object fmComparison: TfmComparison
       end>
     SimplePanel = False
   end
+  object cxRemovedObjects: TCheckBox
+    Left = 15
+    Height = 24
+    Top = 200
+    Width = 185
+    Caption = 'Check Removed objects'
+    TabOrder = 5
+  end
 end

+ 373 - 33
comparison.pas

@@ -19,9 +19,9 @@ type
   TfmComparison = class(TForm)
     bbStart: TBitBtn;
     cbComparedDatabase: TComboBox;
+    cxRemovedObjects: TCheckBox;
     cxDomains: TCheckBox;
     cxRoles: TCheckBox;
-    cxUsers: TCheckBox;
     cxTriggers: TCheckBox;
     cxGenerators: TCheckBox;
     cxTables: TCheckBox;
@@ -45,6 +45,7 @@ type
     DiffCount: Integer;
     dbObjectsList: array [1 .. 13] of TStringList;
     dbExistingObjectsList: array [1 .. 13] of TStringList;
+    dbRemovedObjectsList: array [1 .. 13] of TStringList;
     MissingFieldsList: TStringList;
 
     ExistFieldsList: TStringList;
@@ -64,6 +65,7 @@ type
 
     fQueryWindow: TfmQueryWindow;
 
+    procedure CheckRemovedDBObjects;
     procedure DisplayStatus(AStatus: string);
 
     procedure CheckMissingIndices;
@@ -71,6 +73,7 @@ type
     procedure CheckMissingDBObjects;
     procedure CheckMissingFields;
     procedure CheckModifiedFields;
+
     procedure CheckModifiedIndices;
     procedure CheckModifiedConstraints;
     procedure CheckModifiedViews;
@@ -79,8 +82,12 @@ type
     procedure CheckModifiedFunctions;
     procedure CheckModifiedDomains;
 
+    procedure CheckRemovedIndices;
+    procedure CheckRemovedConstraints;
+
     procedure InitializeQueryWindow;
     procedure ScriptMissingFields;
+
     procedure ScriptModifiedFields;
     procedure ScriptModifiedIndices;
     procedure ScriptModifiedConstraints;
@@ -89,6 +96,8 @@ type
     procedure ScriptModifiedProcedures;
     procedure ScriptModifiedFunctions;
     procedure ScriptModifiedDomains;
+
+    procedure ScriptRemovedDBObjects;
   public
     procedure Init(dbIndex: Integer);
     { public declarations }
@@ -135,6 +144,8 @@ end;
 
 procedure TfmComparison.bbStartClick(Sender: TObject);
 begin
+  meLog.Clear;
+  meLog.Visible:= False;
   DiffCount:= 0;
   StatusBar1.Color:= clBlue;
   DisplayStatus('Searching for missing DB Objects...');
@@ -167,8 +178,14 @@ begin
   if cxDomains.Checked then
     CheckModifiedDomains;
 
+  DisplayStatus('Searching for removed db Objects...');
+
+  if cxRemovedObjects.Checked then
+    CheckRemovedDBObjects;
+
   StatusBar1.Color:= clDefault;
   DisplayStatus('Comparison Finished, ' + IntToStr(DiffCount) + ' difference(s) found');
+  meLog.Visible:= True;
 end;
 
 procedure TfmComparison.FormClose(Sender: TObject; var CloseAction: TCloseAction);
@@ -181,6 +198,9 @@ begin
   for i:= 1 to High(dbExistingObjectsList) do
     dbExistingObjectsList[i].Free;
 
+  for i:= 1 to High(dbRemovedObjectsList) do
+    dbRemovedObjectsList[i].Free;
+
   MissingFieldsList.Free;
 
   ExistFieldsList.Free;
@@ -217,12 +237,16 @@ var
   Unique, Ascending: Boolean;
   KeyName, CurrentTableName, CurrentFieldName,
   OtherTableName, OtherFieldName, UpdateRule, DeleteRule: string;
+  IsPrimary: Boolean;
+  ConstraintName: string;
 begin
   InitializeQueryWindow;
   meLog.Clear;
   ScriptList:= TStringList.Create;
   FieldsList:= TStringList.Create;
 
+  ScriptRemovedDBObjects;
+
   if cxTables.Checked then
   begin
     ScriptMissingFields;
@@ -249,7 +273,6 @@ begin
   dmSysTables.Init(fdbIndex);
 
   fQueryWindow.meQuery.Lines.Add('');
-  fQueryWindow.meQuery.Lines.Add('-- Missing db Objects');
 
   for x:= 1 to 13 do
   begin
@@ -356,17 +379,29 @@ begin
       System.Delete(Line, 1, Pos(',', Line));
       AIndexName:= Line;
       ScriptList.Clear;
-      if dmSysTables.GetIndexInfo(fdbIndex, ATableName, AIndexName, FieldsList, Unique, Ascending) then
+      if dmSysTables.GetIndexInfo(fdbIndex, ATableName, AIndexName, FieldsList, ConstraintName, Unique,
+        Ascending, IsPrimary) then
       begin
-        Line:= 'create ';
-        if Unique then
-          Line:= Line + 'Unique ';
-        if not Ascending then
-          Line:= Line + 'Descending ';
+        if IsPrimary then
+        begin
+          Line:= 'alter table ' + ATableName + #13#10 +
+          'add constraint ' + AIndexName + #13#10 +
+          'primary key (' + FieldsList.CommaText + ');';
 
-        Line:= Line + 'index ' + AIndexName + ' on ' + ATableName;
+        end
+        else
+        begin
+          Line:= 'create ';
+          if Unique then
+            Line:= Line + 'Unique ';
+          if not Ascending then
+            Line:= Line + 'Descending ';
+
+          Line:= Line + 'index ' + AIndexName + ' on ' + ATableName;
+
+          Line:= Line + ' (' + FieldsList.CommaText + ') ;';
 
-        Line:= Line + ' (' + FieldsList.CommaText + ') ;';
+        end;
 
         fQueryWindow.meQuery.Lines.Add(Line);
         fQueryWindow.meQuery.Lines.Add('');
@@ -380,12 +415,12 @@ begin
       Line:= dbObjectsList[x].Strings[i];
       ATableName:= copy(Line, 1, Pos(',', Line) - 1);
       System.Delete(Line, 1, Pos(',', Line));
-      AIndexName:= Line;
+      ConstraintName:= Line;
       ScriptList.Clear;
       if dmSysTables.GetConstraintInfo(fdbIndex, ATableName, AIndexName, KeyName, CurrentTableName, CurrentFieldName,
         OtherTableName, OtherFieldName, UpdateRule, DeleteRule) then
       begin
-        Line:= 'alter table ' + ATableName + ' add constraint ' + AIndexName +
+        Line:= 'alter table ' + ATableName + ' add constraint ' + ConstraintName +
           ' foreign key (' + CurrentFieldName + ') references ' +  OtherTableName  +
           ' (' + dmSysTables.GetConstraintForiegnKeyFields(OtherFieldName, dmSysTables.sqQuery) + ') ';
         if Trim(UpdateRule) <> 'RESTRICT' then
@@ -423,8 +458,6 @@ var
 begin
   List:= TStringList.Create;
   ComparedList:= TStringList.Create;
-  meLog.Clear;
-  meLog.Visible:= False;
   for x:= 1 to 11 do
   if ((x = 1) and cxTables.Checked) or
      ((x = 2) and cxGenerators.Checked) or
@@ -433,11 +466,10 @@ begin
      ((x = 5) and cxStoredProcs.Checked) or
      ((x = 6) and cxUDFs.Checked) or
      ((x = 8) and cxDomains.Checked) or
-     ((x = 9) and cxRoles.Checked) or
-     ((x = 11) and cxUsers.Checked) then
+     ((x = 9) and cxRoles.Checked) then
   begin
     meLog.Lines.Add('');
-    meLog.Lines.Add('Missing ' + dbObjects[x] + ':');
+    meLog.Lines.Add('Checking Missing ' + dbObjects[x] + ':');
 
     List.CommaText:= dmSysTables.GetDBObjectNames(fdbIndex, x, Count);
 
@@ -457,12 +489,51 @@ begin
   end;
 
 
-  meLog.Visible:= True;
   laScript.Enabled:= True;
   ComparedList.Free;
   List.Free;
 end;
 
+procedure TfmComparison.CheckRemovedDBObjects;
+var
+  List, ComparedList: TStringList;
+  Count: Integer;
+  x, i: Integer;
+begin
+  List:= TStringList.Create;
+  ComparedList:= TStringList.Create;
+  for x:= 1 to 11 do
+  if ((x = 1) and cxTables.Checked) or
+     ((x = 2) and cxGenerators.Checked) or
+     ((x = 3) and cxTriggers.Checked) or
+     ((x = 4) and cxViews.Checked) or
+     ((x = 5) and cxStoredProcs.Checked) or
+     ((x = 6) and cxUDFs.Checked) or
+     ((x = 8) and cxDomains.Checked) then
+  begin
+    meLog.Lines.Add('');
+    meLog.Lines.Add('Checking Removed ' + dbObjects[x] + ':');
+
+    List.CommaText:= dmSysTables.GetDBObjectNames(fdbIndex, x, Count);
+
+    ComparedList.CommaText:= dmSysTables.GetDBObjectNames(cbComparedDatabase.ItemIndex, x, Count);
+    dbRemovedObjectsList[x].Clear;
+
+    for i:= 0 to ComparedList.Count -1 do
+    if List.IndexOf(ComparedList[i]) = -1 then  // Removed
+    begin
+      meLog.Lines.Add(' ' + ComparedList[i]);
+      dbRemovedObjectsList[x].Add(ComparedList[i]);
+      Inc(DiffCount);
+    end;
+
+  end;
+  CheckRemovedIndices;
+  CheckRemovedConstraints;
+  ComparedList.Free;
+  List.Free;
+end;
+
 procedure TfmComparison.CheckMissingFields;
 var
   i, j: Integer;
@@ -545,6 +616,9 @@ var
   Unique, Ascending: Boolean;
   CFieldsList: TStringList;
   CUnique, CAscending: Boolean;
+  IsPrimary: Boolean;
+  ConstraintName: string;
+  CConstraintName: string;
 begin
   meLog.Lines.Add('');
   meLog.Lines.Add('Modified Indices');
@@ -559,8 +633,9 @@ begin
     System.Delete(Line, 1, Pos(',', Line));
     AIndexName:= Line;
 
-    dmSysTables.GetIndexInfo(fdbIndex, ATableName, AIndexName, FieldsList, Unique, Ascending);
-    dmSysTables.GetIndexInfo(cbComparedDatabase.ItemIndex, ATableName, AIndexName, CFieldsList, CUnique, CAscending);
+    dmSysTables.GetIndexInfo(fdbIndex, ATableName, AIndexName, FieldsList, ConstraintName, Unique, Ascending, IsPrimary);
+    dmSysTables.GetIndexInfo(cbComparedDatabase.ItemIndex, ATableName, AIndexName, CFieldsList, CConstraintName,
+      CUnique, CAscending, IsPrimary);
     if (FieldsList.CommaText <> CFieldsList.CommaText) or (Unique <> CUnique) or (Ascending <> CAscending) then
     begin
       meLog.Lines.Add(' ' + ExistIndicesList[i]);
@@ -757,6 +832,79 @@ begin
 
 end;
 
+procedure TfmComparison.CheckRemovedIndices;
+var
+  i: Integer;
+  OrigList: TStringList;
+  ComparedList: TStringList;
+  TablesList: TStringList;
+  CTablesList: TStringList;
+  Po: Integer;
+begin
+  OrigList:= TStringList.Create;
+  ComparedList:= TStringList.Create;
+  TablesList:= TStringList.Create;
+  CTablesList:= TStringList.Create;
+
+  dmSysTables.GetAllIndices(fdbIndex, OrigList, TablesList);
+  dmSysTables.GetAllIndices(cbComparedDatabase.ItemIndex, ComparedList, CTablesList);
+  dbRemovedObjectsList[12].Clear;
+
+  meLog.Lines.Add('');
+  meLog.Lines.Add('Checking removed indices');
+  for i:= 0 to ComparedList.Count - 1 do
+  begin
+    Po:= OrigList.IndexOf(ComparedList[i]);
+    if (Po = -1) or (TablesList[Po] <> CTablesList[i]) then
+    begin
+      dbRemovedObjectsList[12].Add(CTablesList[i] + ',' + ComparedList[i]);
+      meLog.Lines.Add(' ' + CTableslist[i] + ':' + ComparedList[i]);
+    end;
+  end;
+
+  OrigList.Free;
+  ComparedList.Free;
+  TablesList.Free;
+  CTablesList.Free;
+end;
+
+procedure TfmComparison.CheckRemovedConstraints;
+var
+  i: Integer;
+  OrigList: TStringList;
+  ComparedList: TStringList;
+  TablesList: TStringList;
+  CTablesList: TStringList;
+  Po: Integer;
+begin
+  OrigList:= TStringList.Create;
+  ComparedList:= TStringList.Create;
+  TablesList:= TStringList.Create;
+  CTablesList:= TStringList.Create;
+
+  dmSysTables.GetAllConstraints(fdbIndex, OrigList, TablesList);
+  dmSysTables.GetAllConstraints(cbComparedDatabase.ItemIndex, ComparedList, CTablesList);
+  dbRemovedObjectsList[13].Clear;
+
+  meLog.Lines.Add('');
+  meLog.Lines.Add('Checking removed constraints');
+  for i:= 0 to ComparedList.Count - 1 do
+  begin
+    Po:= OrigList.IndexOf(ComparedList[i]);
+    if (Po = -1) or (TablesList[Po] <> CTablesList[i]) then
+    begin
+      dbRemovedObjectsList[13].Add(CTablesList[i] + ',' + ComparedList[i]);
+      meLog.Lines.Add(' ' + CTableslist[i] + ':' + ComparedList[i]);
+    end;
+
+  end;
+
+  OrigList.Free;
+  ComparedList.Free;
+  TablesList.Free;
+  CTablesList.Free;
+end;
+
 procedure TfmComparison.InitializeQueryWindow;
 begin
   fQueryWindow:= fmMain.ShowQueryWindow(cbComparedDatabase.ItemIndex, 'Database Differences');
@@ -914,6 +1062,8 @@ var
   FieldsList: TStringList;
   Line: string;
   Unique, Ascending: Boolean;
+  IsPrimary: Boolean;
+  ConstraintName: string;
 begin
   if ModifiedIndicesList.Count > 0 then
   try
@@ -926,19 +1076,33 @@ begin
       ATableName:= copy(Line, 1, Pos(',', Line) - 1);
       System.Delete(Line, 1, Pos(',', Line));
       AIndexName:= Line;
-      if dmSysTables.GetIndexInfo(fdbIndex, ATableName, AIndexName, FieldsList, Unique, Ascending) then
+      if dmSysTables.GetIndexInfo(fdbIndex, ATableName, AIndexName, FieldsList, ConstraintName, Unique, Ascending,
+        IsPrimary) then
       begin
-        fQueryWindow.meQuery.Lines.Add('drop index ' + AIndexName + ';');
+        if IsPrimary then
+        begin
+          fQueryWindow.meQuery.Lines.Add('alter table AAAA DROP constraint ' + ConstraintName + ';');
+
+          Line:= 'alter table ' + ATableName + #13#10 +
+          'add constraint ' + AIndexName + #13#10 +
+          'primary key (' + FieldsList.CommaText + ')';
 
-        Line:= 'create ';
-        if Unique then
-          Line:= Line + 'Unique ';
-        if not Ascending then
-          Line:= Line + 'Descending ';
+        end
+        else // Secondary
+        begin
+          fQueryWindow.meQuery.Lines.Add('drop index ' + AIndexName + ';');
 
-        Line:= Line + 'index ' + AIndexName + ' on ' + ATableName;
+          Line:= 'create ';
+          if Unique then
+            Line:= Line + 'Unique ';
+          if not Ascending then
+            Line:= Line + 'Descending ';
 
-        Line:= Line + ' (' + FieldsList.CommaText + ') ;';
+          Line:= Line + 'index ' + AIndexName + ' on ' + ATableName;
+
+          Line:= Line + ' (' + FieldsList.CommaText + ') ;';
+
+        end;
 
         fQueryWindow.meQuery.Lines.Add(Line);
         fQueryWindow.meQuery.Lines.Add('');
@@ -1161,6 +1325,179 @@ begin
 
 end;
 
+procedure TfmComparison.ScriptRemovedDBObjects;
+var
+  x: Integer;
+  ObjName: string;
+  i: Integer;
+  IsPrimary: Boolean;
+  TableName: string;
+  IndexName: string;
+  FieldsList: TStringList;
+  Unique, Asc: Boolean;
+  ConstraintName: string;
+begin
+  FieldsList:= TStringList.Create;
+  for x:= 13 downto 1 do
+  begin
+    if (x = 1) and cxTables.Checked then
+    begin
+      if dbRemovedObjectsList[x].Count > 0 then
+      begin
+        fQueryWindow.meQuery.Lines.Add('');
+        fQueryWindow.meQuery.Lines.Add('-- Removed Tables');
+      end;
+      for i:= 0 to dbRemovedObjectsList[x].Count - 1 do
+      begin
+        ObjName:= dbRemovedObjectsList[x][i];
+        fQueryWindow.meQuery.Lines.Add('drop table ' + ObjName + ';');
+      end;
+    end
+    else
+    if (x = 2) and cxGenerators.Checked then
+    begin
+      if dbRemovedObjectsList[x].Count > 0 then
+      begin
+        fQueryWindow.meQuery.Lines.Add('');
+        fQueryWindow.meQuery.Lines.Add('-- Removed Generators');
+      end;
+      for i:= 0 to dbRemovedObjectsList[x].Count - 1 do
+      begin
+        ObjName:= dbRemovedObjectsList[x][i];
+        fQueryWindow.meQuery.Lines.Add('drop generator ' + ObjName + ';');
+      end;
+    end
+    else
+    if (x = 3) and cxTriggers.Checked then
+    begin
+      if dbRemovedObjectsList[x].Count > 0 then
+      begin
+        fQueryWindow.meQuery.Lines.Add('');
+        fQueryWindow.meQuery.Lines.Add('-- Removed Triggers');
+      end;
+      for i:= 0 to dbRemovedObjectsList[x].Count - 1 do
+      begin
+        ObjName:= dbRemovedObjectsList[x][i];
+        fQueryWindow.meQuery.Lines.Add('drop trigger ' + ObjName + ';');
+      end;
+    end
+    else
+    if (x = 4) and cxViews.Checked then
+    begin
+      if dbRemovedObjectsList[x].Count > 0 then
+      begin
+        fQueryWindow.meQuery.Lines.Add('');
+        fQueryWindow.meQuery.Lines.Add('-- Removed Views');
+      end;
+      for i:= 0 to dbRemovedObjectsList[x].Count - 1 do
+      begin
+        ObjName:= dbRemovedObjectsList[x][i];
+        fQueryWindow.meQuery.Lines.Add('drop view "' + ObjName + '";');
+      end;
+    end
+    else
+    if (x = 5) and cxStoredProcs.Checked then
+    begin
+      if dbRemovedObjectsList[x].Count > 0 then
+      begin
+        fQueryWindow.meQuery.Lines.Add('');
+        fQueryWindow.meQuery.Lines.Add('-- Removed Procedures');
+      end;
+      for i:= 0 to dbRemovedObjectsList[x].Count - 1 do
+      begin
+        ObjName:= dbRemovedObjectsList[x][i];
+        fQueryWindow.meQuery.Lines.Add('drop procedure ' + ObjName + ';');
+      end;
+    end
+    else
+    if (x = 6) and cxUDFs.Checked then
+    begin
+      if dbRemovedObjectsList[x].Count > 0 then
+      begin
+        fQueryWindow.meQuery.Lines.Add('');
+        fQueryWindow.meQuery.Lines.Add('-- Removed Functions (UDFs)');
+      end;
+      for i:= 0 to dbRemovedObjectsList[x].Count - 1 do
+      begin
+        ObjName:= dbRemovedObjectsList[x][i];
+        fQueryWindow.meQuery.Lines.Add('drop external function "' + ObjName + '";');
+      end;
+    end
+    else
+    if (x = 8) and cxDomains.Checked then
+    begin
+      if dbRemovedObjectsList[x].Count > 0 then
+      begin
+        fQueryWindow.meQuery.Lines.Add('');
+        fQueryWindow.meQuery.Lines.Add('-- Removed Domains');
+      end;
+      for i:= 0 to dbRemovedObjectsList[x].Count - 1 do
+      begin
+        ObjName:= dbRemovedObjectsList[x][i];
+        fQueryWindow.meQuery.Lines.Add('drop domain ' + ObjName + ';');
+      end;
+    end
+    else
+    if (x = 9) and cxRoles.Checked then
+    begin
+      if dbRemovedObjectsList[x].Count > 0 then
+      begin
+        fQueryWindow.meQuery.Lines.Add('');
+        fQueryWindow.meQuery.Lines.Add('-- Removed Roles');
+      end;
+      for i:= 0 to dbRemovedObjectsList[x].Count - 1 do
+      begin
+        ObjName:= dbRemovedObjectsList[x][i];
+        fQueryWindow.meQuery.Lines.Add('drop role ' + ObjName + ';');
+      end;
+    end
+    else
+    if (x = 12) and cxTables.Checked then // Indices are linked to tables
+    begin
+      if dbRemovedObjectsList[x].Count > 0 then
+      begin
+        fQueryWindow.meQuery.Lines.Add('');
+        fQueryWindow.meQuery.Lines.Add('-- Removed Indices');
+      end;
+      for i:= 0 to dbRemovedObjectsList[x].Count - 1 do
+      begin
+        ObjName:= dbRemovedObjectsList[x][i];
+        TableName:= Copy(ObjName, 1, Pos(',', ObjName) - 1);
+        System.Delete(ObjName, 1, Pos(',', ObjName));
+        IndexName:= ObjName;
+        dmSysTables.GetIndexInfo(cbComparedDatabase.ItemIndex, TableName, IndexName, FieldsList,
+        ConstraintName, Unique, Asc, IsPrimary);
+        if IsPrimary then
+          fQueryWindow.meQuery.Lines.Add('alter table ' + TableName + ' DROP constraint ' + ConstraintName + ';')
+        else
+          fQueryWindow.meQuery.Lines.Add('drop index ' + IndexName + ';');
+      end;
+    end
+    else
+    if (x = 13) and cxTables.Checked then // Constraints are linked to tables
+    begin
+      if dbRemovedObjectsList[x].Count > 0 then
+      begin
+        fQueryWindow.meQuery.Lines.Add('');
+        fQueryWindow.meQuery.Lines.Add('-- Removed Constraints');
+      end;
+      for i:= 0 to dbRemovedObjectsList[x].Count - 1 do
+      begin
+        ObjName:= dbRemovedObjectsList[x][i];
+        TableName:= Copy(ObjName, 1, Pos(',', ObjName) - 1);
+        System.Delete(ObjName, 1, Pos(',', ObjName));
+        ConstraintName:= ObjName;
+        fQueryWindow.meQuery.Lines.Add('alter table ' + TableName + ' DROP constraint ' + ConstraintName + ';');
+      end;
+    end;
+
+
+  end;
+
+  FieldsList.Free;
+
+end;
+
 procedure TfmComparison.Init(dbIndex: Integer);
 var
   i: Integer;
@@ -1174,7 +1511,7 @@ begin
   cxUDFs.Checked:= True;
   cxTriggers.Checked:= True;
   cxRoles.Checked:= True;
-  cxUsers.Checked:= False;
+  cxRemovedObjects.Checked:= False;
 
   laScript.Enabled:= False;
   laComparedDatabase.Caption:= '[]';
@@ -1195,6 +1532,9 @@ begin
   for i:= 1 to High(dbExistingObjectsList) do
     dbExistingObjectsList[i]:= TStringList.Create;
 
+  for i:= 1 to High(dbRemovedObjectsList) do
+    dbRemovedObjectsList[i]:= TStringList.Create;
+
   MissingFieldsList:= TStringList.Create;
 
   ExistFieldsList:= TStringList.Create;
@@ -1234,11 +1574,11 @@ begin
   try
     for i:= 0 to TablesList.Count - 1 do
     begin
-      PrimaryIndexName:= dmSysTables.GetPrimaryKeyIndexName(fdbIndex, TablesList[i], ConstraintName);
+     // PrimaryIndexName:= dmSysTables.GetPrimaryKeyIndexName(fdbIndex, TablesList[i], ConstraintName);
       List.Clear;
-      dmSysTables.GetIndices(fdbIndex, TablesList[i], PrimaryIndexName, List);
+      dmSysTables.GetIndices(fdbIndex, TablesList[i], '', List);
       ComparedList.Clear;
-      if dmSysTables.GetIndices(cbComparedDatabase.ItemIndex, TablesList[i], PrimaryIndexName, ComparedList) then
+      if dmSysTables.GetIndices(cbComparedDatabase.ItemIndex, TablesList[i], '', ComparedList) then
       begin
         for j:= 0 to List.Count - 1 do
           if ComparedList.IndexOf(List[j]) = -1 then // Add to missing indices

+ 0 - 1
newtable.lfm

@@ -105,7 +105,6 @@ object fmNewTable: TfmNewTable
     Width = 328
     Anchors = [akLeft, akBottom]
     Caption = 'Create Auto increment Generator and Trigger'
-    OnClick = cxCreateGenClick
     TabOrder = 4
   end
   object bbClose: TBitBtn

+ 5 - 5
newtable.lrs

@@ -30,9 +30,9 @@ LazarusResources.Add('TfmNewTable','FORMDATA',[
   +'Color'#4#219#242#247#0#7'Default'#9#4'Kind'#7#5'bkYes'#7'OnClick'#7#13'bbSc'
   +'riptClick'#8'TabOrder'#2#3#0#0#9'TCheckBox'#11'cxCreateGen'#4'Left'#2#18#6
   +'Height'#2#24#3'Top'#3#191#1#5'Width'#3'H'#1#7'Anchors'#11#6'akLeft'#8'akBot'
-  +'tom'#0#7'Caption'#6'+Create Auto increment Generator and Trigger'#7'OnClick'
-  +#7#16'cxCreateGenClick'#8'TabOrder'#2#4#0#0#7'TBitBtn'#7'bbClose'#4'Left'#3
-  +'0'#2#6'Height'#2#24#3'Top'#2#0#5'Width'#2#27#7'Anchors'#11#5'akTop'#7'akRig'
-  +'ht'#0#7'Caption'#6#4' X  '#5'Color'#4#219#242#247#0#10'Font.Style'#11#6'fsB'
-  +'old'#0#7'OnClick'#7#12'bbCloseClick'#10'ParentFont'#8#8'TabOrder'#2#5#0#0#0
+  +'tom'#0#7'Caption'#6'+Create Auto increment Generator and Trigger'#8'TabOrde'
+  +'r'#2#4#0#0#7'TBitBtn'#7'bbClose'#4'Left'#3'0'#2#6'Height'#2#24#3'Top'#2#0#5
+  +'Width'#2#27#7'Anchors'#11#5'akTop'#7'akRight'#0#7'Caption'#6#4' X  '#5'Colo'
+  +'r'#4#219#242#247#0#10'Font.Style'#11#6'fsBold'#0#7'OnClick'#7#12'bbCloseCli'
+  +'ck'#10'ParentFont'#8#8'TabOrder'#2#5#0#0#0
 ]);

+ 1 - 14
newtable.pas

@@ -24,9 +24,7 @@ type
     procedure bbCloseClick(Sender: TObject);
     procedure bbScriptClick(Sender: TObject);
     procedure BitBtn2Click(Sender: TObject);
-    procedure cxCreateGenClick(Sender: TObject);
     procedure FormClose(Sender: TObject; var CloseAction: TCloseAction);
-    procedure StringGrid1ChangeBounds(Sender: TObject);
     procedure StringGrid1KeyUp(Sender: TObject; var Key: Word;
       Shift: TShiftState);
     procedure StringGrid1MouseUp(Sender: TObject; Button: TMouseButton;
@@ -101,7 +99,7 @@ begin
   if PKey <> '' then
   begin
     Delete(PKey, Length(PKey), 1);
-    Result:= Result + ', ' + #10 + ' primary key (' + PKey + ') ' + #10;
+    Result:= Result + ', ' + #10 + ' constraint ' + edNewTable.Text + '_pk_1 primary key (' + PKey + ') ' + #10;
   end;
   Result:= Result + ');';
 end;
@@ -183,22 +181,11 @@ begin
   Parent.Free;
 end;
 
-procedure TfmNewTable.cxCreateGenClick(Sender: TObject);
-begin
-  if cxCreateGen.Checked and (StringGrid1.RowCount > 1) then
-    StringGrid1.Cells[3, 1]:= '1';
-end;
-
 procedure TfmNewTable.FormClose(Sender: TObject; var CloseAction: TCloseAction);
 begin
   CloseAction:= caFree;
 end;
 
-procedure TfmNewTable.StringGrid1ChangeBounds(Sender: TObject);
-begin
-
-end;
-
 
 procedure TfmNewTable.StringGrid1KeyUp(Sender: TObject; var Key: Word;
   Shift: TShiftState);

+ 1 - 1
scriptdb.pas

@@ -219,7 +219,7 @@ begin
   if PKeyName <> '' then
   begin
     fmMain.GetConstraintFields(ATableName, PKeyName, PKFieldsList);
-    FieldLine:= 'primary key (';
+    FieldLine:= 'constraint ' + ConstraintName + ' primary key (';
     for i:= 0 to PKFieldsList.Count - 1 do
       FieldLine:= FieldLine + PKFieldsList[i] + ', ';
     if PKFieldsList.Count > 0 then

+ 73 - 5
systables.pas

@@ -29,6 +29,8 @@ type
     function GetTableConstraints(ATableName: string; var SqlQuery: TSQLQuery;
       ConstraintsList: TStringList = nil): Boolean;
 
+    function GetAllConstraints(dbIndex: Integer; ConstraintsList, TablesList: TStringList): Boolean;
+
     function GetConstraintInfo(dbIndex: Integer; ATableName, ConstraintName: string; var KeyName,
         CurrentTableName, CurrentFieldName, OtherTableName, OtherFieldName, UpdateRule, DeleteRule: string): Boolean;
 
@@ -57,10 +59,12 @@ type
     function GetIndices(dbIndex: Integer; ATableName: string; PrimaryIndexName: string;
       var List: TStringList): Boolean;
 
+    function GetAllIndices(dbIndex: Integer; List, TablesList: TStringList): Boolean;
+
     function GetPrimaryKeyIndexName(dbIndex: Integer; ATableName: string; var ConstraintName: string): string;
 
     function GetIndexInfo(dbIndex: Integer; ATableName, AIndexName: string;
-      var FieldsList: TStringList; var Unique, Ascending: Boolean): Boolean;
+      var FieldsList: TStringList; var ConstraintName: string; var Unique, Ascending, IsPrimary: Boolean): Boolean;
 
     procedure GetTableFields(dbIndex: Integer; ATableName: string; FieldsList: TStringList);
 
@@ -293,6 +297,42 @@ begin
 
 end;
 
+function TdmSysTables.GetAllConstraints(dbIndex: Integer; ConstraintsList, TablesList: TStringList): Boolean;
+begin
+  Init(dbIndex);
+  sqQuery.Close;
+  sqQuery.SQL.Text:= 'select Trim(Refc.RDB$Constraint_Name) as ConstName, ' +
+    'Trim(Refc.RDB$CONST_NAME_UQ) as KeyName, ' +
+    'Trim(Ind.RDB$Relation_Name) as CurrentTableName, ' +
+    'Trim(Seg.RDB$Field_name) as CurrentFieldName, ' +
+    'Trim(Con.RDB$Relation_Name) as OtherTableName, ' +
+    'Trim(Ind.RDB$Foreign_key) as OtherFieldName, ' +
+    'RDB$Update_Rule as UpdateRule, RDB$Delete_Rule as DeleteRule ' +
+    'from RDB$RELATION_CONSTRAINTS Con, rdb$REF_Constraints Refc, RDB$INDEX_SEGMENTS Seg, ' +
+    'RDB$INDICES Ind ' +
+    'where Con.RDB$COnstraint_Name = Refc.RDB$Const_Name_UQ ' +
+    '  and Refc.RDB$COnstraint_Name = Ind.RDB$Index_Name' +
+    '  and Refc.RDB$COnstraint_Name = Seg.RDB$Index_Name';
+  sqQuery.Open;
+  Result:= sqQuery.RecordCount > 0;
+  with sqQuery do
+  if Result then
+  begin
+    ConstraintsList.Clear;
+    if Assigned(TablesList) then
+      TablesList.Clear;
+    while not Eof do
+    begin
+      ConstraintsList.Add(FieldByName('ConstName').AsString);
+      if Assigned(TablesList) then
+        TablesList.Add(FieldByName('CurrentTableName').AsString);
+      Next;
+    end;
+  end;
+  sqQuery.Close;
+
+end;
+
 (**********  Get Constraint Info  ********************)
 
 function TdmSysTables.GetConstraintInfo(dbIndex: Integer; ATableName, ConstraintName: string; var KeyName,
@@ -703,6 +743,31 @@ begin
 
 end;
 
+function TdmSysTables.GetAllIndices(dbIndex: Integer; List, TablesList: TStringList): Boolean;
+begin
+  Init(dbIndex);
+  sqQuery.Close;
+  sqQuery.SQL.Text:= 'SELECT * FROM RDB$INDICES WHERE  RDB$FOREIGN_KEY IS NULL ' +
+   'and RDB$system_flag = 0';
+  sqQuery.Open;
+  Result:= sqQuery.RecordCount > 0;
+  List.Clear;
+  if TablesList <> nil then
+    TablesList.Clear;
+  with sqQuery do
+  if Result then
+  begin
+    while not Eof do
+    begin
+      List.Add(Trim(Fields[0].AsString));
+      if TablesList <> nil then
+        TablesList.Add(Trim(FieldByName('RDB$Relation_Name').AsString));
+      Next;
+    end;
+  end;
+  sqQuery.Close
+end;
+
 function TdmSysTables.GetPrimaryKeyIndexName(dbIndex: Integer; ATableName: string; var ConstraintName: string): string;
 begin
   Init(dbIndex);
@@ -721,20 +786,21 @@ begin
 end;
 
 function TdmSysTables.GetIndexInfo(dbIndex: Integer; ATableName, AIndexName: string;
-  var FieldsList: TStringList; var Unique, Ascending: Boolean): Boolean;
+  var FieldsList: TStringList; var ConstraintName: string; var Unique, Ascending, IsPrimary: Boolean): Boolean;
 begin
   Init(dbIndex);
   sqQuery.Close;
   sqQuery.SQL.Text:= 'SELECT RDB$Indices.*, RDB$INDEX_SEGMENTS.RDB$FIELD_NAME AS field_name, ' + #10 +
      'RDB$INDICES.RDB$DESCRIPTION AS description, ' + #10 +
-     '(RDB$INDEX_SEGMENTS.RDB$FIELD_POSITION + 1) AS field_position ' + #10 +
+     '(RDB$INDEX_SEGMENTS.RDB$FIELD_POSITION + 1) AS field_position, ' + #10 +
+     'RDB$RELATION_CONSTRAINTS.RDB$CONSTRAINT_TYPE as IndexType, ' + #10 +
+     'RDB$RELATION_CONSTRAINTS.RDB$CONSTRAINT_Name as ConstraintName' + #10 +
      'FROM RDB$INDEX_SEGMENTS ' + #10 +
      'LEFT JOIN RDB$INDICES ON RDB$INDICES.RDB$INDEX_NAME = RDB$INDEX_SEGMENTS.RDB$INDEX_NAME ' + #10 +
      'LEFT JOIN RDB$RELATION_CONSTRAINTS ON RDB$RELATION_CONSTRAINTS.RDB$INDEX_NAME = RDB$INDEX_SEGMENTS.RDB$INDEX_NAME '
      + #10 +
      ' WHERE UPPER(RDB$INDICES.RDB$RELATION_NAME)=''' + UpperCase(ATablename) + '''         -- table name ' + #10 +
-     '  AND UPPER(RDB$INDICES.RDB$INDEX_NAME)=''' + UpperCase(AIndexName) + ''' -- index name ' + #10 +
-     '--  AND RDB$RELATION_CONSTRAINTS.RDB$CONSTRAINT_TYPE IS NULL ' + #10 +
+     '  AND UPPER(RDB$INDICES.RDB$INDEX_NAME)=''' + UpperCase(AIndexName) + ''' ' + #10 +
      'ORDER BY RDB$INDEX_SEGMENTS.RDB$FIELD_POSITION;';
   sqQuery.Open;
   Result:= sqQuery.FieldCount > 0;
@@ -742,6 +808,8 @@ begin
   begin
     Unique:= sqQuery.FieldByName('RDB$Unique_Flag').AsString = '1';
     Ascending:= sqQuery.FieldByName('RDB$Index_Type').AsString <> '1';
+    IsPrimary:= Trim(sqQuery.FieldByName('IndexType').AsString) = 'PRIMARY KEY';
+    ConstraintName:= Trim(sqQuery.FieldByName('ConstraintName').AsString);
   end;
   FieldsList.Clear;
   if Result then

+ 2 - 2
tablemanage.lfm

@@ -1,7 +1,7 @@
 object fmTableManage: TfmTableManage
-  Left = 214
+  Left = 298
   Height = 448
-  Top = 386
+  Top = 206
   Width = 819
   ActiveControl = PageControl1
   Anchors = [akTop, akLeft, akRight]

+ 40 - 40
tablemanage.lrs

@@ -1,46 +1,46 @@
 { This is an automatically generated lazarus resource file }
 
 LazarusResources.Add('TfmTableManage','FORMDATA',[
-  'TPF0'#14'TfmTableManage'#13'fmTableManage'#4'Left'#3#214#0#6'Height'#3#192#1
-  +#3'Top'#3#130#1#5'Width'#3'3'#3#13'ActiveControl'#7#12'PageControl1'#7'Ancho'
-  +'rs'#11#5'akTop'#6'akLeft'#7'akRight'#0#7'Caption'#6#16'Table Management'#12
-  +'ClientHeight'#3#192#1#11'ClientWidth'#3'3'#3#7'OnClose'#7#9'FormClose'#8'Po'
-  +'sition'#7#14'poScreenCenter'#10'LCLVersion'#6#6'0.9.31'#0#12'TPageControl'
-  +#12'PageControl1'#4'Left'#2#0#6'Height'#3#157#1#3'Top'#2#29#5'Width'#3'1'#3
-  +#10'ActivePage'#7#9'tsIndices'#7'Anchors'#11#5'akTop'#6'akLeft'#7'akRight'#8
-  +'akBottom'#0#6'Images'#7#10'ImageList1'#8'TabIndex'#2#1#8'TabOrder'#2#0#0#9
-  +'TTabSheet'#8'tsFields'#7'Caption'#6#6'Fields'#12'ClientHeight'#3'~'#1#11'Cl'
-  +'ientWidth'#3'-'#3#0#11'TStringGrid'#8'sgFields'#4'Left'#2#0#6'Height'#3'S'#1
-  +#3'Top'#2#0#5'Width'#3'-'#3#5'Align'#7#5'alTop'#7'Anchors'#11#5'akTop'#6'akL'
-  +'eft'#7'akRight'#8'akBottom'#0#8'ColCount'#2#7#7'Columns'#14#1#11'ButtonStyl'
-  +'e'#7#17'cbsCheckboxColumn'#5'Color'#4#234#219#219#0#7'MaxSize'#2'2'#8'ReadO'
-  +'nly'#9#13'Title.Caption'#6#5'P-Key'#16'Title.Font.Color'#4#229'TT'#0#17'Tit'
-  +'le.Font.Height'#2#245#16'Title.Font.Style'#11#6'fsBold'#0#5'Width'#2'2'#0#1
-  +#13'Title.Caption'#6#10'Field Name'#5'Width'#3#130#0#0#1#13'Title.Caption'#6
-  +#9'Data Type'#5'Width'#2'x'#0#1#13'Title.Caption'#6#4'Size'#16'Title.Font.Co'
-  +'lor'#4#21'-'#254#0#16'Title.Font.Style'#11#6'fsBold'#0#0#1#11'ButtonStyle'#7
-  +#17'cbsCheckboxColumn'#13'Title.Caption'#6#10'Allow Null'#5'Width'#2'Z'#0#1
-  +#13'Title.Caption'#6#13'Default Value'#5'Width'#2'x'#0#1#13'Title.Caption'#6
-  +#11'Description'#5'Width'#3#200#0#0#0#10'FixedColor'#4#207#218#221#0#9'Fixed'
-  +'Cols'#2#0#7'Options'#11#15'goFixedVertLine'#15'goFixedHorzLine'#10'goVertLi'
-  +'ne'#10'goHorzLine'#11'goColSizing'#11'goColMoving'#11'goRowSelect'#14'goSmo'
-  +'othScroll'#0#8'RowCount'#2#4#8'TabOrder'#2#0#15'TitleFont.Style'#11#6'fsBol'
-  +'d'#0#14'UseXORFeatures'#9#0#0#7'TBitBtn'#6'bbEdit'#4'Left'#2#14#6'Height'#2
-  +#30#3'Top'#3'X'#1#5'Width'#2'K'#7'Anchors'#11#6'akLeft'#8'akBottom'#0#7'Capt'
-  +'ion'#6#4'Edit'#5'Color'#4#219#242#247#0#7'OnClick'#7#11'bbEditClick'#8'TabO'
-  +'rder'#2#1#0#0#7'TBitBtn'#5'bbNew'#4'Left'#2'h'#6'Height'#2#30#3'Top'#3'X'#1
-  +#5'Width'#2'K'#7'Anchors'#11#6'akLeft'#8'akBottom'#0#7'Caption'#6#3'New'#5'C'
-  +'olor'#4#219#242#247#0#7'OnClick'#7#10'bbNewClick'#8'TabOrder'#2#2#0#0#7'TBi'
-  +'tBtn'#6'edDrop'#4'Left'#3#240#0#6'Height'#2#30#3'Top'#3'X'#1#5'Width'#2'K'#7
-  +'Anchors'#11#6'akLeft'#8'akBottom'#0#7'Caption'#6#4'Drop'#5'Color'#4#219#242
-  +#247#0#4'Kind'#7#8'bkIgnore'#7'OnClick'#7#11'edDropClick'#8'TabOrder'#2#3#0#0
-  +#7'TBitBtn'#9'bbRefresh'#4'Left'#3#207#2#6'Height'#2#30#3'Top'#3'X'#1#5'Widt'
-  +'h'#2'^'#7'Anchors'#11#7'akRight'#8'akBottom'#0#7'Caption'#6#7'Refresh'#5'Co'
-  +'lor'#4#219#242#247#0#4'Kind'#7#7'bkRetry'#7'OnClick'#7#14'bbRefreshClick'#8
-  +'TabOrder'#2#4#0#0#0#9'TTabSheet'#9'tsIndices'#7'Caption'#6#7'Indices'#12'Cl'
-  +'ientHeight'#3'~'#1#11'ClientWidth'#3'-'#3#10'ImageIndex'#2#2#0#7'TBitBtn'#16
-  +'bbRefreshIndices'#4'Left'#3'h'#2#6'Height'#2#30#3'Top'#2#11#5'Width'#2'X'#7
-  +'Anchors'#11#5'akTop'#7'akRight'#0#7'Caption'#6#7'Refresh'#5'Color'#4#219#242
+  'TPF0'#14'TfmTableManage'#13'fmTableManage'#4'Left'#3'*'#1#6'Height'#3#192#1#3
+  +'Top'#3#206#0#5'Width'#3'3'#3#13'ActiveControl'#7#12'PageControl1'#7'Anchors'
+  +#11#5'akTop'#6'akLeft'#7'akRight'#0#7'Caption'#6#16'Table Management'#12'Cli'
+  +'entHeight'#3#192#1#11'ClientWidth'#3'3'#3#7'OnClose'#7#9'FormClose'#8'Posit'
+  +'ion'#7#14'poScreenCenter'#10'LCLVersion'#6#6'0.9.31'#0#12'TPageControl'#12
+  +'PageControl1'#4'Left'#2#0#6'Height'#3#157#1#3'Top'#2#29#5'Width'#3'1'#3#10
+  +'ActivePage'#7#9'tsIndices'#7'Anchors'#11#5'akTop'#6'akLeft'#7'akRight'#8'ak'
+  +'Bottom'#0#6'Images'#7#10'ImageList1'#8'TabIndex'#2#1#8'TabOrder'#2#0#0#9'TT'
+  +'abSheet'#8'tsFields'#7'Caption'#6#6'Fields'#12'ClientHeight'#3'~'#1#11'Clie'
+  +'ntWidth'#3'-'#3#0#11'TStringGrid'#8'sgFields'#4'Left'#2#0#6'Height'#3'S'#1#3
+  +'Top'#2#0#5'Width'#3'-'#3#5'Align'#7#5'alTop'#7'Anchors'#11#5'akTop'#6'akLef'
+  +'t'#7'akRight'#8'akBottom'#0#8'ColCount'#2#7#7'Columns'#14#1#11'ButtonStyle'
+  +#7#17'cbsCheckboxColumn'#5'Color'#4#234#219#219#0#7'MaxSize'#2'2'#8'ReadOnly'
+  +#9#13'Title.Caption'#6#5'P-Key'#16'Title.Font.Color'#4#229'TT'#0#17'Title.Fo'
+  +'nt.Height'#2#245#16'Title.Font.Style'#11#6'fsBold'#0#5'Width'#2'2'#0#1#13'T'
+  +'itle.Caption'#6#10'Field Name'#5'Width'#3#130#0#0#1#13'Title.Caption'#6#9'D'
+  +'ata Type'#5'Width'#2'x'#0#1#13'Title.Caption'#6#4'Size'#16'Title.Font.Color'
+  +#4#21'-'#254#0#16'Title.Font.Style'#11#6'fsBold'#0#0#1#11'ButtonStyle'#7#17
+  +'cbsCheckboxColumn'#13'Title.Caption'#6#10'Allow Null'#5'Width'#2'Z'#0#1#13
+  +'Title.Caption'#6#13'Default Value'#5'Width'#2'x'#0#1#13'Title.Caption'#6#11
+  +'Description'#5'Width'#3#200#0#0#0#10'FixedColor'#4#207#218#221#0#9'FixedCol'
+  +'s'#2#0#7'Options'#11#15'goFixedVertLine'#15'goFixedHorzLine'#10'goVertLine'
+  +#10'goHorzLine'#11'goColSizing'#11'goColMoving'#11'goRowSelect'#14'goSmoothS'
+  +'croll'#0#8'RowCount'#2#4#8'TabOrder'#2#0#15'TitleFont.Style'#11#6'fsBold'#0
+  +#14'UseXORFeatures'#9#0#0#7'TBitBtn'#6'bbEdit'#4'Left'#2#14#6'Height'#2#30#3
+  +'Top'#3'X'#1#5'Width'#2'K'#7'Anchors'#11#6'akLeft'#8'akBottom'#0#7'Caption'#6
+  +#4'Edit'#5'Color'#4#219#242#247#0#7'OnClick'#7#11'bbEditClick'#8'TabOrder'#2
+  +#1#0#0#7'TBitBtn'#5'bbNew'#4'Left'#2'h'#6'Height'#2#30#3'Top'#3'X'#1#5'Width'
+  +#2'K'#7'Anchors'#11#6'akLeft'#8'akBottom'#0#7'Caption'#6#3'New'#5'Color'#4
+  +#219#242#247#0#7'OnClick'#7#10'bbNewClick'#8'TabOrder'#2#2#0#0#7'TBitBtn'#6
+  +'edDrop'#4'Left'#3#240#0#6'Height'#2#30#3'Top'#3'X'#1#5'Width'#2'K'#7'Anchor'
+  +'s'#11#6'akLeft'#8'akBottom'#0#7'Caption'#6#4'Drop'#5'Color'#4#219#242#247#0
+  +#4'Kind'#7#8'bkIgnore'#7'OnClick'#7#11'edDropClick'#8'TabOrder'#2#3#0#0#7'TB'
+  +'itBtn'#9'bbRefresh'#4'Left'#3#207#2#6'Height'#2#30#3'Top'#3'X'#1#5'Width'#2
+  +'^'#7'Anchors'#11#7'akRight'#8'akBottom'#0#7'Caption'#6#7'Refresh'#5'Color'#4
+  +#219#242#247#0#4'Kind'#7#7'bkRetry'#7'OnClick'#7#14'bbRefreshClick'#8'TabOrd'
+  +'er'#2#4#0#0#0#9'TTabSheet'#9'tsIndices'#7'Caption'#6#7'Indices'#12'ClientHe'
+  +'ight'#3'~'#1#11'ClientWidth'#3'-'#3#10'ImageIndex'#2#2#0#7'TBitBtn'#16'bbRe'
+  +'freshIndices'#4'Left'#3'h'#2#6'Height'#2#30#3'Top'#2#11#5'Width'#2'X'#7'Anc'
+  +'hors'#11#5'akTop'#7'akRight'#0#7'Caption'#6#7'Refresh'#5'Color'#4#219#242
   +#247#0#4'Kind'#7#7'bkRetry'#7'OnClick'#7#21'bbRefreshIndicesClick'#8'TabOrde'
   +'r'#2#0#0#0#11'TStringGrid'#9'sgIndices'#4'Left'#2#255#6'Height'#3#139#0#3'T'
   +'op'#2#254#5'Width'#3'^'#2#7'Anchors'#11#5'akTop'#6'akLeft'#7'akRight'#0#7'C'