OSDN Git Service

Add 0.98.
authorBruce Momjian <bruce@momjian.us>
Sat, 30 Oct 1999 16:18:54 +0000 (16:18 +0000)
committerBruce Momjian <bruce@momjian.us>
Sat, 30 Oct 1999 16:18:54 +0000 (16:18 +0000)
188 files changed:
src/bin/pgaccess/README [new file with mode: 0644]
src/bin/pgaccess/copyright.html [new file with mode: 0644]
src/bin/pgaccess/demo/formdemo.sql [new file with mode: 0644]
src/bin/pgaccess/doc/html/a_right.gif [new file with mode: 0644]
src/bin/pgaccess/doc/html/addindex.gif [new file with mode: 0644]
src/bin/pgaccess/doc/html/api.html [new file with mode: 0644]
src/bin/pgaccess/doc/html/ball.gif [new file with mode: 0644]
src/bin/pgaccess/doc/html/contents.html [new file with mode: 0644]
src/bin/pgaccess/doc/html/copyright.html [new file with mode: 0644]
src/bin/pgaccess/doc/html/documentation.html [new file with mode: 0644]
src/bin/pgaccess/doc/html/download.html [new file with mode: 0644]
src/bin/pgaccess/doc/html/faq.html [new file with mode: 0644]
src/bin/pgaccess/doc/html/features.html [new file with mode: 0644]
src/bin/pgaccess/doc/html/formdemo.sql [new file with mode: 0644]
src/bin/pgaccess/doc/html/forms.gif [new file with mode: 0644]
src/bin/pgaccess/doc/html/forms.html [new file with mode: 0644]
src/bin/pgaccess/doc/html/function.gif [new file with mode: 0644]
src/bin/pgaccess/doc/html/help.gif [new file with mode: 0644]
src/bin/pgaccess/doc/html/index.html [new file with mode: 0644]
src/bin/pgaccess/doc/html/irix.html [new file with mode: 0644]
src/bin/pgaccess/doc/html/linux1.gif [new file with mode: 0644]
src/bin/pgaccess/doc/html/maillist.html [new file with mode: 0644]
src/bin/pgaccess/doc/html/main.html [new file with mode: 0644]
src/bin/pgaccess/doc/html/mainwindow.gif [new file with mode: 0644]
src/bin/pgaccess/doc/html/newtable.gif [new file with mode: 0644]
src/bin/pgaccess/doc/html/newuser.gif [new file with mode: 0644]
src/bin/pgaccess/doc/html/old_index.html [new file with mode: 0644]
src/bin/pgaccess/doc/html/permissions.gif [new file with mode: 0644]
src/bin/pgaccess/doc/html/pg93patch.html [new file with mode: 0644]
src/bin/pgaccess/doc/html/pga-rad.html [new file with mode: 0644]
src/bin/pgaccess/doc/html/qbtclet.html [new file with mode: 0644]
src/bin/pgaccess/doc/html/qbtclet.tcl [new file with mode: 0644]
src/bin/pgaccess/doc/html/screenshots.html [new file with mode: 0644]
src/bin/pgaccess/doc/html/specialchars.html [new file with mode: 0644]
src/bin/pgaccess/doc/html/todo.html [new file with mode: 0644]
src/bin/pgaccess/doc/html/tutorial/addref.jpg [new file with mode: 0644]
src/bin/pgaccess/doc/html/tutorial/altern_q.jpg [new file with mode: 0644]
src/bin/pgaccess/doc/html/tutorial/altern_v.jpg [new file with mode: 0644]
src/bin/pgaccess/doc/html/tutorial/copyright.html [new file with mode: 0644]
src/bin/pgaccess/doc/html/tutorial/index.html [new file with mode: 0644]
src/bin/pgaccess/doc/html/tutorial/intro.html [new file with mode: 0644]
src/bin/pgaccess/doc/html/tutorial/irix.html [new file with mode: 0644]
src/bin/pgaccess/doc/html/tutorial/newref.txt [new file with mode: 0644]
src/bin/pgaccess/doc/html/tutorial/newtable.jpg [new file with mode: 0644]
src/bin/pgaccess/doc/html/tutorial/newtable.tga [new file with mode: 0644]
src/bin/pgaccess/doc/html/tutorial/problems.html [new file with mode: 0644]
src/bin/pgaccess/doc/html/tutorial/screen1.jpg [new file with mode: 0644]
src/bin/pgaccess/doc/html/tutorial/sel_tbl.jpg [new file with mode: 0644]
src/bin/pgaccess/doc/html/tutorial/start.html [new file with mode: 0644]
src/bin/pgaccess/doc/html/tutorial/tut.html [new file with mode: 0644]
src/bin/pgaccess/doc/html/tutorial/tut_edit.html [new file with mode: 0644]
src/bin/pgaccess/doc/html/tutorial/tut_new.html [new file with mode: 0644]
src/bin/pgaccess/doc/html/tutorial/tut_sel1.html [new file with mode: 0644]
src/bin/pgaccess/doc/html/tutorial/tut_user.html [new file with mode: 0644]
src/bin/pgaccess/doc/html/vdesigner.gif [new file with mode: 0644]
src/bin/pgaccess/doc/html/whatsnew.html [new file with mode: 0644]
src/bin/pgaccess/doc/html/win32.html [new file with mode: 0644]
src/bin/pgaccess/images/icon_button.gif [new file with mode: 0644]
src/bin/pgaccess/images/icon_checkbutton.gif [new file with mode: 0644]
src/bin/pgaccess/images/icon_entry.gif [new file with mode: 0644]
src/bin/pgaccess/images/icon_frame.gif [new file with mode: 0644]
src/bin/pgaccess/images/icon_label.gif [new file with mode: 0644]
src/bin/pgaccess/images/icon_listbox.gif [new file with mode: 0644]
src/bin/pgaccess/images/icon_query.gif [new file with mode: 0644]
src/bin/pgaccess/images/icon_radiobutton.gif [new file with mode: 0644]
src/bin/pgaccess/images/icon_text.gif [new file with mode: 0644]
src/bin/pgaccess/lib/database.tcl [new file with mode: 0644]
src/bin/pgaccess/lib/forms.tcl [new file with mode: 0644]
src/bin/pgaccess/lib/functions.tcl [new file with mode: 0644]
src/bin/pgaccess/lib/help.tcl [new file with mode: 0644]
src/bin/pgaccess/lib/help/abort.hlp [new file with mode: 0644]
src/bin/pgaccess/lib/help/add_records.hlp [new file with mode: 0644]
src/bin/pgaccess/lib/help/alter_table.hlp [new file with mode: 0644]
src/bin/pgaccess/lib/help/alter_user.hlp [new file with mode: 0644]
src/bin/pgaccess/lib/help/author.hlp [new file with mode: 0644]
src/bin/pgaccess/lib/help/begin.hlp [new file with mode: 0644]
src/bin/pgaccess/lib/help/close.hlp [new file with mode: 0644]
src/bin/pgaccess/lib/help/cluster.hlp [new file with mode: 0644]
src/bin/pgaccess/lib/help/commit.hlp [new file with mode: 0644]
src/bin/pgaccess/lib/help/copy.hlp [new file with mode: 0644]
src/bin/pgaccess/lib/help/copyrights.hlp [new file with mode: 0644]
src/bin/pgaccess/lib/help/create_aggregate.hlp [new file with mode: 0644]
src/bin/pgaccess/lib/help/create_database.hlp [new file with mode: 0644]
src/bin/pgaccess/lib/help/create_function.hlp [new file with mode: 0644]
src/bin/pgaccess/lib/help/create_index.hlp [new file with mode: 0644]
src/bin/pgaccess/lib/help/create_language.hlp [new file with mode: 0644]
src/bin/pgaccess/lib/help/create_operator.hlp [new file with mode: 0644]
src/bin/pgaccess/lib/help/create_rule.hlp [new file with mode: 0644]
src/bin/pgaccess/lib/help/create_sequence.hlp [new file with mode: 0644]
src/bin/pgaccess/lib/help/create_table.hlp [new file with mode: 0644]
src/bin/pgaccess/lib/help/create_table_as.hlp [new file with mode: 0644]
src/bin/pgaccess/lib/help/create_trigger.hlp [new file with mode: 0644]
src/bin/pgaccess/lib/help/create_type.hlp [new file with mode: 0644]
src/bin/pgaccess/lib/help/create_user.hlp [new file with mode: 0644]
src/bin/pgaccess/lib/help/create_view.hlp [new file with mode: 0644]
src/bin/pgaccess/lib/help/data_types.hlp [new file with mode: 0644]
src/bin/pgaccess/lib/help/datefunc.hlp [new file with mode: 0644]
src/bin/pgaccess/lib/help/declare.hlp [new file with mode: 0644]
src/bin/pgaccess/lib/help/delete.hlp [new file with mode: 0644]
src/bin/pgaccess/lib/help/drop_aggregate.hlp [new file with mode: 0644]
src/bin/pgaccess/lib/help/drop_database.hlp [new file with mode: 0644]
src/bin/pgaccess/lib/help/drop_function.hlp [new file with mode: 0644]
src/bin/pgaccess/lib/help/drop_index.hlp [new file with mode: 0644]
src/bin/pgaccess/lib/help/drop_language.hlp [new file with mode: 0644]
src/bin/pgaccess/lib/help/drop_operator.hlp [new file with mode: 0644]
src/bin/pgaccess/lib/help/drop_rule.hlp [new file with mode: 0644]
src/bin/pgaccess/lib/help/drop_sequence.hlp [new file with mode: 0644]
src/bin/pgaccess/lib/help/drop_table.hlp [new file with mode: 0644]
src/bin/pgaccess/lib/help/drop_trigger.hlp [new file with mode: 0644]
src/bin/pgaccess/lib/help/drop_type.hlp [new file with mode: 0644]
src/bin/pgaccess/lib/help/drop_user.hlp [new file with mode: 0644]
src/bin/pgaccess/lib/help/drop_view.hlp [new file with mode: 0644]
src/bin/pgaccess/lib/help/explain.hlp [new file with mode: 0644]
src/bin/pgaccess/lib/help/fetch.hlp [new file with mode: 0644]
src/bin/pgaccess/lib/help/form_design.hlp [new file with mode: 0644]
src/bin/pgaccess/lib/help/forms.hlp [new file with mode: 0644]
src/bin/pgaccess/lib/help/functions.hlp [new file with mode: 0644]
src/bin/pgaccess/lib/help/geomfunc.hlp [new file with mode: 0644]
src/bin/pgaccess/lib/help/grant.hlp [new file with mode: 0644]
src/bin/pgaccess/lib/help/history.hlp [new file with mode: 0644]
src/bin/pgaccess/lib/help/index.hlp [new file with mode: 0644]
src/bin/pgaccess/lib/help/inheritance.hlp [new file with mode: 0644]
src/bin/pgaccess/lib/help/insert.hlp [new file with mode: 0644]
src/bin/pgaccess/lib/help/ipv4func.hlp [new file with mode: 0644]
src/bin/pgaccess/lib/help/isolation.hlp [new file with mode: 0644]
src/bin/pgaccess/lib/help/keywords.hlp [new file with mode: 0644]
src/bin/pgaccess/lib/help/listen.hlp [new file with mode: 0644]
src/bin/pgaccess/lib/help/load.hlp [new file with mode: 0644]
src/bin/pgaccess/lib/help/lock.hlp [new file with mode: 0644]
src/bin/pgaccess/lib/help/mathfunc.hlp [new file with mode: 0644]
src/bin/pgaccess/lib/help/move.hlp [new file with mode: 0644]
src/bin/pgaccess/lib/help/mvcc.hlp [new file with mode: 0644]
src/bin/pgaccess/lib/help/new_query.hlp [new file with mode: 0644]
src/bin/pgaccess/lib/help/new_table.hlp [new file with mode: 0644]
src/bin/pgaccess/lib/help/notify.hlp [new file with mode: 0644]
src/bin/pgaccess/lib/help/open_query.hlp [new file with mode: 0644]
src/bin/pgaccess/lib/help/open_table.hlp [new file with mode: 0644]
src/bin/pgaccess/lib/help/pgfunctions.hlp [new file with mode: 0644]
src/bin/pgaccess/lib/help/postgresql.hlp [new file with mode: 0644]
src/bin/pgaccess/lib/help/queries.hlp [new file with mode: 0644]
src/bin/pgaccess/lib/help/reports.hlp [new file with mode: 0644]
src/bin/pgaccess/lib/help/reset.hlp [new file with mode: 0644]
src/bin/pgaccess/lib/help/revoke.hlp [new file with mode: 0644]
src/bin/pgaccess/lib/help/rollback.hlp [new file with mode: 0644]
src/bin/pgaccess/lib/help/schema.hlp [new file with mode: 0644]
src/bin/pgaccess/lib/help/scripts.hlp [new file with mode: 0644]
src/bin/pgaccess/lib/help/select.hlp [new file with mode: 0644]
src/bin/pgaccess/lib/help/select_into.hlp [new file with mode: 0644]
src/bin/pgaccess/lib/help/sequences.hlp [new file with mode: 0644]
src/bin/pgaccess/lib/help/set.hlp [new file with mode: 0644]
src/bin/pgaccess/lib/help/show.hlp [new file with mode: 0644]
src/bin/pgaccess/lib/help/sql_guide.hlp [new file with mode: 0644]
src/bin/pgaccess/lib/help/sqlfunc.hlp [new file with mode: 0644]
src/bin/pgaccess/lib/help/stringfunc.hlp [new file with mode: 0644]
src/bin/pgaccess/lib/help/tables.hlp [new file with mode: 0644]
src/bin/pgaccess/lib/help/unlisten.hlp [new file with mode: 0644]
src/bin/pgaccess/lib/help/update.hlp [new file with mode: 0644]
src/bin/pgaccess/lib/help/users.hlp [new file with mode: 0644]
src/bin/pgaccess/lib/help/vacuum.hlp [new file with mode: 0644]
src/bin/pgaccess/lib/help/view_table_structure.hlp [new file with mode: 0644]
src/bin/pgaccess/lib/help/views.hlp [new file with mode: 0644]
src/bin/pgaccess/lib/help/visual_designer.hlp [new file with mode: 0644]
src/bin/pgaccess/lib/help/y2k.hlp [new file with mode: 0644]
src/bin/pgaccess/lib/languages/deutsch [new file with mode: 0644]
src/bin/pgaccess/lib/languages/francais [new file with mode: 0644]
src/bin/pgaccess/lib/languages/italiano [new file with mode: 0644]
src/bin/pgaccess/lib/languages/magyar [new file with mode: 0644]
src/bin/pgaccess/lib/languages/romana [new file with mode: 0644]
src/bin/pgaccess/lib/mainlib.tcl [new file with mode: 0644]
src/bin/pgaccess/lib/preferences.tcl [new file with mode: 0644]
src/bin/pgaccess/lib/qed [new file with mode: 0755]
src/bin/pgaccess/lib/queries.tcl [new file with mode: 0644]
src/bin/pgaccess/lib/reports.tcl [new file with mode: 0644]
src/bin/pgaccess/lib/schema.tcl [new file with mode: 0644]
src/bin/pgaccess/lib/scripts.tcl [new file with mode: 0644]
src/bin/pgaccess/lib/sequences.tcl [new file with mode: 0644]
src/bin/pgaccess/lib/tables.tcl [new file with mode: 0644]
src/bin/pgaccess/lib/users.tcl [new file with mode: 0644]
src/bin/pgaccess/lib/views.tcl [new file with mode: 0644]
src/bin/pgaccess/lib/visualqb.tcl [new file with mode: 0644]
src/bin/pgaccess/main.tcl [new file with mode: 0644]
src/bin/pgaccess/pgaccess [new file with mode: 0755]
src/bin/pgaccess/win32/dll/libpgtcl80.dll-6.4.2 [new file with mode: 0644]
src/bin/pgaccess/win32/dll/libpgtcl80.dll-6.5.1 [new file with mode: 0644]
src/bin/pgaccess/win32/dll/libpgtcl81.dll-6.5.1 [new file with mode: 0644]
src/bin/pgaccess/win32/dll/libpgtcl82.dll-6.5.1 [new file with mode: 0644]
src/bin/pgaccess/win32/dll/libpq.dll-6.4.2 [new file with mode: 0644]
src/bin/pgaccess/win32/dll/libpq.dll-6.5.1 [new file with mode: 0644]

diff --git a/src/bin/pgaccess/README b/src/bin/pgaccess/README
new file mode 100644 (file)
index 0000000..69a920a
--- /dev/null
@@ -0,0 +1,82 @@
+---------------------------------------------------------------------------
+
+Copyright (c) 1994-7 Regents of the University of California
+
+Permission to use, copy, modify, and distribute this software and its
+documentation for any purpose, without fee, and without a written agreement
+is hereby granted, provided that the above copyright notice and this
+paragraph and the following two paragraphs appear in all copies.
+
+IN NO EVENT SHALL THE UNIVERSITY OF CALIFORNIA BE LIABLE TO ANY PARTY FOR
+DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES, INCLUDING
+LOST PROFITS, ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS
+DOCUMENTATION, EVEN IF THE UNIVERSITY OF CALIFORNIA HAS BEEN ADVISED OF THE
+POSSIBILITY OF SUCH DAMAGE.
+
+THE UNIVERSITY OF CALIFORNIA SPECIFICALLY DISCLAIMS ANY WARRANTIES,
+INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
+AND FITNESS FOR A PARTICULAR PURPOSE.  THE SOFTWARE PROVIDED HEREUNDER IS
+ON AN "AS IS" BASIS, AND THE UNIVERSITY OF CALIFORNIA HAS NO OBLIGATIONS TO
+PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
+
+---------------------------------------------------------------------------
+
+
+PGACCESS 0.98 29 August 1999
+================================
+I dedicate this program to my little daughters Ana-Maria and Emilia and to my
+wife for their understanding. I hope they will forgive me for spending so many
+time far from them.
+
+
+
+1. How to INSTALL ?
+
+You will need a Tcl/Tk package, at least Tcl 7.6 and Tk 4.2, recommended
+Tcl/Tk 8.x
+
+For Unix users, unpack the pgaccess-xxx.tar.gz archieve in you preferred
+directory (usually /usr/local).
+
+Check where your "wish" program is and modify (if needed) the file
+/usr/local/pgaccess/pgaccess and set variables PGACCESS_HOME and 
+PATH_TO_WISH to the appropriate directories.
+
+Include the /usr/local/pgaccess directory into your PATH or make a
+symbolic link to it wherever you want (in PATH directories).
+Example:
+
+$ ln -s /usr/local/pgaccess/pgaccess /usr/bin/pgaccess
+
+You will find also some documentation and FAQ in the doc directory.
+
+
+
+2. Usage
+
+You run it with the command:
+
+        pgaccess [database]
+
+[database] is optional.
+
+
+
+3. Bug reporting
+
+First of all : operating system, PostgreSQL version,Tcl/Tk version.
+A more detailed story of what have you done when error occurred.
+Tcl/Tk stops usually with a error message and there is a button there
+"Stack Trace" and if you press it, you will see a detailed information
+about the procedure containing the error. Please send it to me.
+Some information about table structure, no. of fields, records would
+be also good.
+
+===========================================================================
+You would find always the latest version at   http://www.flex.ro/pgaccess
+
+Please feel free to e-mail me with any suggestion or bug description
+that will help to improve it.
+
+Constantin Teodorescu <teo@flex.ro>
+
diff --git a/src/bin/pgaccess/copyright.html b/src/bin/pgaccess/copyright.html
new file mode 100644 (file)
index 0000000..d67654b
--- /dev/null
@@ -0,0 +1,39 @@
+<HTML>
+<HEAD>
+   <META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=iso-8859-1">
+   <META NAME="GENERATOR" CONTENT="Mozilla/4.03 [en] (X11; I; Linux 2.0.30 i586) [Netscape]">
+   <TITLE>PgAccess - Copyright notice</TITLE>
+</HEAD>
+<BODY BGCOLOR="#FFFFFF">
+<TT>---------------------------------------------------------------------------</TT>
+<BR><TT></TT>&nbsp;
+<BR><TT></TT>&nbsp;<TT></TT>
+
+<P><TT>Copyright (c) 1994-7 Regents of the University of California</TT><TT></TT>
+
+<P><TT>Permission to use, copy, modify, and distribute this software and
+its</TT>
+<BR><TT>documentation for any purpose, without fee, and without a written
+agreement</TT>
+<BR><TT>is hereby granted, provided that the above copyright notice and
+this</TT>
+<BR><TT>paragraph and the following two paragraphs appear in all copies.</TT><TT></TT>
+
+<P><TT>IN NO EVENT SHALL THE UNIVERSITY OF CALIFORNIA BE LIABLE TO ANY
+PARTY FOR</TT>
+<BR><TT>DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES,
+INCLUDING</TT>
+<BR><TT>LOST PROFITS, ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS</TT>
+<BR><TT>DOCUMENTATION, EVEN IF THE UNIVERSITY OF CALIFORNIA HAS BEEN ADVISED
+OF THE</TT>
+<BR><TT>POSSIBILITY OF SUCH DAMAGE.</TT><TT></TT>
+
+<P><TT>THE UNIVERSITY OF CALIFORNIA SPECIFICALLY DISCLAIMS ANY WARRANTIES,</TT>
+<BR><TT>INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY</TT>
+<BR><TT>AND FITNESS FOR A PARTICULAR PURPOSE. THE SOFTWARE PROVIDED HEREUNDER
+IS</TT>
+<BR><TT>ON AN "AS IS" BASIS, AND THE UNIVERSITY OF CALIFORNIA HAS NO OBLIGATIONS
+TO</TT>
+<BR><TT>PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.</TT>
+</BODY>
+</HTML>
diff --git a/src/bin/pgaccess/demo/formdemo.sql b/src/bin/pgaccess/demo/formdemo.sql
new file mode 100644 (file)
index 0000000..6062c0d
--- /dev/null
@@ -0,0 +1,233 @@
+CREATE SEQUENCE "cities_id_seq" start 7 increment 1 maxvalue 2147483647 minvalue 1  cache 1 ;
+SELECT nextval ('cities_id_seq');
+CREATE TABLE "pga_queries" (
+       "queryname" character varying(64),
+       "querytype" character,
+       "querycommand" text,
+       "querytables" text,
+       "querylinks" text,
+       "queryresults" text,
+       "querycomments" text);
+CREATE TABLE "pga_forms" (
+       "formname" character varying(64),
+       "formsource" text);
+CREATE TABLE "pga_scripts" (
+       "scriptname" character varying(64),
+       "scriptsource" text);
+CREATE TABLE "pga_reports" (
+       "reportname" character varying(64),
+       "reportsource" text,
+       "reportbody" text,
+       "reportprocs" text,
+       "reportoptions" text);
+CREATE TABLE "phonebook" (
+       "name" character varying(32),
+       "phone_nr" character varying(16),
+       "city" character varying(32),
+       "company" bool,
+       "continent" character varying(16));
+CREATE TABLE "pga_layout" (
+       "tablename" character varying(64),
+       "nrcols" int2,
+       "colnames" text,
+       "colwidth" text);
+CREATE TABLE "pga_schema" (
+       "schemaname" character varying(64),
+       "schematables" text,
+       "schemalinks" text);
+REVOKE ALL on "pga_schema" from PUBLIC;
+GRANT ALL on "pga_schema" to PUBLIC;
+CREATE TABLE "cities" (
+       "id" int4 DEFAULT nextval('"cities_id_seq"') NOT NULL,
+       "name" character varying(32) NOT NULL,
+       "prefix" character varying(16) NOT NULL);
+REVOKE ALL on "cities" from PUBLIC;
+GRANT UPDATE,DELETE,SELECT,RULE on "cities" to "fane";
+GRANT ALL on "cities" to "liviu";
+CREATE FUNCTION "getcityprefix" (int4 ) RETURNS varchar AS 'select prefix from cities where id = $1 ' LANGUAGE 'SQL';
+COPY "pga_queries" FROM stdin;
+Query that can be saved as view        S       select * from phonebook where continent='usa'           \N      \N      \N      \N
+\.
+COPY "pga_forms" FROM stdin;
+Phone book     pb 28 {FS {}} 444x307+284+246 {label label1 {33 10 68 28} {} Name {} label1 flat #000000 #d9d9d9 1 n} {entry name_entry {87 9 227 27} {} entry2 DataSet(.pb.qs,name) name_entry sunken #000000 #fefefe 1 n} {label label3 {33 37 73 52} {} Phone {} label3 flat #000000 #d9d9d9 1 n} {entry entry4 {87 36 195 54} {} entry4 DataSet(.pb.qs,phone_nr) entry4 sunken #000000 #fefefe 1 n} {label label5 {33 64 78 82} {} City {} label5 flat #000000 #d9d9d9 1 n} {entry entry6 {87 63 195 81} {} entry6 DataSet(.pb.qs,city) entry6 sunken #000000 #fefefe 1 n} {query qs {3 6 33 33} {} query7 {} qs flat {} {} 1 n} {button button8 {174 177 246 203} {namespace eval DataControl(.pb.qs) {\
+\      setSQL "select oid,* from phonebook where name ~* '$what' order by name"\
+\      open\
+\      set nrecs [getRowCount]\
+\      updateDataSet\
+\      fill .pb.allnames name\
+\      bind .pb.allnames <ButtonRelease-1> {\
+\         set ancr [.pb.allnames curselection]\
+\         if {$ancr!=""} {\
+\      \       DataControl(.pb.qs)::moveTo $ancr\
+\      \       DataControl(.pb.qs)::updateDataSet\
+\         }\
+\      }\
+}} {Start search} {} button8 raised #000000 #d9d9d9 1 n} {button button9 {363 276 433 300} {DataControl(.pb.qs)::close\
+DataControl(.pb.qs)::clearDataSet\
+set nrecs {}\
+set what {}\
+destroy .pb\
+} Exit {} button9 raised #000000 #d9d9d9 2 n} {button button10 {291 237 313 257} {namespace eval DataControl(.pb.qs) {\
+\      moveFirst\
+\      updateDataSet\
+}\
+} |< {} button10 ridge #000092 #d9d9d9 2 n} {button button11 {324 237 346 257} {namespace eval DataControl(.pb.qs) {\
+\      movePrevious\
+\      updateDataSet\
+}\
+} << {} button11 ridge #000000 #d9d9d9 2 n} {button button12 {348 237 370 257} {namespace eval DataControl(.pb.qs) {\
+\      moveNext\
+\      updateDataSet\
+}} >> {} button12 ridge #000000 #d9d9d9 2 n} {button button13 {381 237 403 257} {namespace eval DataControl(.pb.qs) {\
+\      moveLast\
+\      updateDataSet\
+}\
+} >| {} button13 ridge #000088 #d9d9d9 2 n} {checkbox checkbox14 {33 87 126 105} {} {Is it a company ?} DataSet(.pb.qs,company) checkbox14 flat #000000 #d9d9d9 1 n} {radio usa {63 108 201 120} {} U.S.A. DataSet(.pb.qs,continent) usa flat #000000 #d9d9d9 1 n} {radio europe {63 126 204 141} {} Europe DataSet(.pb.qs,continent) europe flat #000000 #d9d9d9 1 n} {radio africa {63 144 210 159} {} Africa DataSet(.pb.qs,continent) africa flat #000000 #d9d9d9 1 n} {entry entry18 {129 180 169 198} {} entry18 what entry18 sunken #000000 #fefefe 1 n} {label label19 {108 219 188 234} {} {records found} {} label19 flat #000000 #d9d9d9 1 n} {label label20 {90 219 105 234} {} { } nrecs label20 flat #000000 #d9d9d9 1 n} {label label21 {3 252 33 267} {} OID= {} label21 flat #000000 #d9d9d9 1 n} {label label22 {39 252 87 267} {} { } pbqs(oid) label22 flat #000000 #d9d9d9 1 n} {button button23 {9 276 79 300} {set oid {}\
+catch {set oid $DataSet(.pb.qs,oid)}\
+if {[string trim $oid]!=""} {\
+   sql_exec noquiet "update phonebook set name='$DataSet(.pb.qs,name)', phone_nr='$DataSet(.pb.qs,phone_nr)',city='$DataSet(.pb.qs,city)',company='$DataSet(.pb.qs,company)',continent='$DataSet(.pb.qs,continent)' where oid=$oid"\
+} else {\
+  tk_messageBox -title Error -message "No record is displayed!"\
+}\
+\
+} Update {} button23 raised #000000 #d9d9d9 1 n} {button button24 {210 276 280 300} {set thisname $DataSet(.pb.qs,name)\
+if {[string trim $thisname] != ""} {\
+\      sql_exec noquiet "insert into phonebook values (\
+\      \       '$DataSet(.pb.qs,name)',\
+\      \       '$DataSet(.pb.qs,phone_nr)',\
+\      \       '$DataSet(.pb.qs,city)',\
+\      \       '$DataSet(.pb.qs,company)',\
+\      \       '$DataSet(.pb.qs,continent)'\
+\      )"\
+\      tk_messageBox -title Information -message "A new record has been added!"\
+} else {\
+\      tk_messageBox -title Error -message "This one doesn't have a name?"\
+}\
+\
+} {Add record} {} button24 raised #000000 #d9d9d9 1 n} {button button25 {141 276 204 300} {DataControl(.pb.qs)::clearDataSet\
+# clearcontrols stillinitialise\
+# incorectly booleans controls to {}\
+# so I force it to 'f' (false)\
+set DataSet(.pb.qs,company) f\
+focus .pb.name_entry} {Clear all} {} button25 raised #000000 #d9d9d9 1 n} {listbox allnames {249 6 435 231} {} listbox26 {} allnames sunken #000000 #fefefe 1 n} {label label27 {33 252 90 267} {} {} DataSet(.pb.qs,oid) label27 flat #000000 #d9d9d9 1 n} {label label28 {3 182 128 197} {} {Find name containing} {} {} flat #000000 #d9d9d9 1 n}
+Full featured form     full 21 {FS {set entrydemo {nice}\
+set color {no color selected}}} 377x418+50+130 {label label1 {3 396 165 411} {} {Status line} {} {} sunken #000000 #d9d9d9 2 n} {label label2 {171 396 369 411} {} {Grooved status line} {} {} groove #000098 #d9d9d9 2 f} {label label3 {108 9 270 31} {} {     Full featured form} {} {} ridge #000000 #d9d9d9 4 {Times 16 bold italic}} {button button4 {15 210 144 243} {.full.lb insert end {it's} a nice demo form} {Java style button} {} {} groove #6161b6 #d9d9d9 2 b} {label label5 {15 42 115 58} {} {Java style label} {} {} flat #6161b6 #d9d9d9 1 b} {entry entry6 {123 39 279 60} {} entry6 entrydemo {} groove #000000 #fefefe 2 {Courier 13}} {listbox lb {12 69 147 201} {} listbox8 {} {} ridge #000000 #ffffc8 2 n} {button button9 {18 264 39 282} {} 1 {} {} flat #000000 #d9d9d9 1 n} {button button10 {48 264 68 282} {} 2 {} {} flat #000000 #d9d9d9 1 n} {button button11 {78 264 234 282} {} {and other hidden buttons} {} {} flat #000000 #d9d9d9 1 n} {text txt {153 69 372 201} {} text12 {} {} sunken #000000 #d4ffff 1 n} {button button13 {150 210 369 243} {.full.txt tag configure bold -font {Helvetica 12 bold}\
+.full.txt tag configure italic -font {Helvetica 12 italic}\
+.full.txt tag configure large -font {Helvetica -14 bold}\
+.full.txt tag configure title -font {Helvetica 12 bold italic} -justify center\
+.full.txt tag configure link -font {Helvetica -12 underline} -foreground #000080\
+.full.txt tag configure code -font {Courier 13}\
+.full.txt tag configure warning -font {Helvetica 12 bold} -foreground #800000\
+\
+# That't the way help files are written\
+\
+.full.txt delete 1.0 end\
+.full.txt insert end {Centered title} {title} "\
+\
+You can make different " {} "portions of text bold" {bold} " or italic " {italic} ".\
+Some parts of them can be written as follows" {} "\
+SELECT * FROM PHONEBOOK" {code} "\
+You can also change " {} "colors for some words " {warning} "or underline them" {link} } {Old style button} {} {} raised #000000 #d9d9d9 2 n} {checkbox checkbox14 {48 297 153 309} {} different {} {} flat #00009c #d9d9d9 1 b} {checkbox checkbox15 {48 321 156 336} {} {fonts and} {} {} flat #cc0000 #d9d9d9 1 i} {checkbox checkbox16 {48 345 156 360} {} colors {} {} flat #00b600 #dfb2df 1 f} {radio radio17 {207 297 330 315} {} {red , rosu , rouge} color red flat #9c0000 #d9d9d9 1 n} {radio radio18 {207 321 324 333} {} {green , verde , vert} color green flat #009000 #d9d9d9 1 n} {radio radio19 {207 345 327 363} {} {blue , albastru, bleu} color blue flat #000000 #d9d9d9 1 n} {label selcolor {210 369 345 384} {} {} color {} flat #000000 #d9d9d9 1 n} {button button21 {285 258 363 285} {destroy .full} Exit {} {} raised #7c0000 #dfdbb8 1 b}
+Working with Tables namespace  f3 13 {3 4 5 6 7 9 10 11 12 13} 377x263+59+127 {radio usa {36 24 138 36} {} USA selcont} {radio europe {36 45 141 60} {} Europe selcont} {radio africa {36 66 147 81} {} Africa selcont} {label label6 {9 99 339 114} {} {Select one of the above continents and press} {}} {button button7 {270 93 354 117} {Tables::open phonebook "continent='$selcont'" $selorder} {Show them} {}} {button button9 {66 189 312 213} {Tables::design phonebook} {Show me the phonebook table structure} {}} {button button10 {141 228 240 252} {destroy .f3} {Close the form} {}} {button button11 {93 141 282 165} {Tables::open phonebook "company=true"} {Show me only the companies} {}} {radio name {183 24 261 36} {} {Order by name} selorder} {radio phone_nr {183 45 267 57} {} {Order by phone number} selorder}
+The simplest form      mf 5 {FS {set thename {}}} 306x136+82+146 {label label {42 45 99 60} {} Name {} label flat #000000 #d9d9d9 1 {Helvetica 12 bold italic}} {entry ename {120 42 219 63} {} entry2 thename ename sunken #000000 #fefefe 1 n} {button button3 {6 96 108 129} {set thename Teo} {Set the name} {} button3 raised #000000 #d9d9d9 1 n} {button button4 {192 96 300 129} {destroy .mf} {Close the form} {} button4 raised #000000 #d9d9d9 1 n} {button button5 {114 96 186 129} {set thename {}} {Clear it} {} button5 raised #000000 #d9d9d9 1 n}
+A simple demo form     asdf 14 {FS {set color none}} 370x310+50+75 {label label1 {15 36 99 57} {} {Selected color} {} label1 flat #000000 #d9d9d9 1} {entry entry2 {111 36 225 54} {} entry2 color entry2 sunken #000000 #fefefe 1} {radio red {249 21 342 36} {} {Red as cherry} color red flat #900000 #d9d9d9 1} {radio green {249 45 342 60} {} {Green as a melon} color green flat #008800 #d9d9d9 1} {radio blue {249 69 342 84} {} {Blue as the sky} color blue flat #00008c #d9d9d9 1} {button button6 {45 69 198 99} {set color spooky} {Set a weird color} {} button6 ridge #0000b0 #dfbcdf 2} {label label7 {24 129 149 145} {} {The checkbox's value} {} label7 flat #000000 #d9d9d9 1} {entry entry8 {162 127 172 145} {} entry8 cbvalue entry8 sunken #000000 #fefefe 1} {checkbox checkbox9 {180 126 279 150} {} {Check me :-)} cbvalue checkbox9 flat #000000 #d9d9d9 1} {button button10 {219 273 366 303} {destroy .asdf} {Close that simple form} {} button10 raised #000000 #d9d9d9 1} {button button11 {219 237 366 267} {Forms::open "Phone book"} {Open my phone book} {} button11 raised #000000 #d9d9d9 1} {listbox lb {12 192 162 267} {} listbox12 {} lb sunken #000000 #fefefe 1} {button button13 {12 156 162 186} {.asdf.lb insert end red green blue cyan white navy black purple maroon violet} {Add some information} {} button13 raised #000000 #d9d9d9 1} {button button14 {12 273 162 303} {.asdf.lb delete 0 end} {Clear this listbox} {} button14 raised #000000 #d9d9d9 1}
+Working with listboxes f2 5 {FS {set thestudent ""}} 257x263+139+147 {listbox lb {6 6 246 186} {} listbox1 {} lb sunken #000000 #ffffd4 1} {button button2 {9 234 124 258} {# Populate the listbox with some data\
+#\
+\
+foreach student {John Bill Doe Gigi} {\
+\      .f2.lb insert end $student\
+}\
+\
+\
+\
+# Binding the event left button release to the\
+# list box\
+\
+bind .f2.lb <ButtonRelease-1> {\
+\      set idsel [.f2.lb curselection]\
+\      if {$idsel!=""} {\
+\      \       set thestudent [.f2.lb get $idsel]\
+\      }\
+}\
+\
+# Cleaning the variable thestudent\
+\
+set thestudent {}} {Show students} {} button2 groove #000000 #d9d9d9 2} {button button3 {132 234 247 258} {destroy .f2} {Close the form} {} button3 groove #000000 #d9d9d9 1} {label label4 {9 213 119 228} {} {You have selected} {} label4 flat #000000 #d9d9d9 1} {label label5 {129 213 219 228} {} {} thestudent label5 flat #00009a #d9d9d9 1}
+Invoices       inv 0 {FS {frame .inv.f\
+place .inv.f -x 5 -y 100 -width 500 -height 300\
+set wn [Tables::getNewWindowName]\
+Tables::createWindow .inv.f\
+set PgAcVar(mw,.inv.f,updatable) 0\
+set PgAcVar(mw,.inv.f,layout_found) 0\
+set PgAcVar(mw,.inv.f,layout_name) ""\
+Tables::selectRecords .inv.f "select * from cities"\
+}} 631x439+87+84
+\.
+COPY "pga_scripts" FROM stdin;
+How are forms keeped inside ?  Tables::open pga_forms\
+\
+\
+\
+
+Opening a table with filters   Tables::open phonebook "name ~* 'e'" "name desc"\
+\
+\
+
+Autoexec       Mainlib::tab_click Forms\
+Forms::open {Full featured form}\
+\
+\
+
+\.
+COPY "pga_reports" FROM stdin;
+My phone book  phonebook       set PgAcVar(report,tablename) "phonebook" ; set PgAcVar(report,y_rpthdr) 21 ; set PgAcVar(report,y_pghdr) 47 ; set PgAcVar(report,y_detail) 66 ; set PgAcVar(report,y_pgfoo) 96 ; set PgAcVar(report,y_rptfoo) 126 ; .pgaw:ReportBuilder.c create text 10 35 -font -Adobe-Helvetica-Bold-R-Normal--*-120-*-*-*-*-*-* -anchor nw -text {name} -tags {t_l mov ro} ; .pgaw:ReportBuilder.c create text 10 52 -font -Adobe-Helvetica-Medium-R-Normal-*-*-120-*-*-*-*-* -anchor nw -text {name} -tags {f-name t_f rg_detail mov ro} ; .pgaw:ReportBuilder.c create text 141 36 -font -Adobe-Helvetica-Bold-R-Normal--*-120-*-*-*-*-*-* -anchor nw -text {city} -tags {t_l mov ro} ; .pgaw:ReportBuilder.c create text 141 51 -font -Adobe-Helvetica-Medium-R-Normal-*-*-120-*-*-*-*-* -anchor nw -text {city} -tags {f-city t_f rg_detail mov ro} ; .pgaw:ReportBuilder.c create text 231 35 -font -Adobe-Helvetica-Bold-R-Normal--*-120-*-*-*-*-*-* -anchor nw -text {phone_nr} -tags {t_l mov ro} ; .pgaw:ReportBuilder.c create text 231 51 -font -Adobe-Helvetica-Medium-R-Normal-*-*-120-*-*-*-*-* -anchor nw -text {phone_nr} -tags {f-phone_nr t_f rg_detail mov ro}  \N      \N
+\.
+COPY "phonebook" FROM stdin;
+FIAT   623463445               t       europe
+Gelu Voican    01-32234        Bucuresti       f       europe
+Radu Vasile    01-5523423      Bucuresti       f       europe
+MUGADUMBU SRL  +92 534662634   Cairo   t       africa
+Jimmy Page     66323452                f       europe
+IBM    623346234       \N      t       usa
+John Doe       +44 35 2993825  Washington      f       usa
+Bill Clinton   +44 35 9283845  New York        f       usa
+Monica Levintchi       +44 38 5234526  Dallas  f       usa
+Bill Gates     +42 64 4523454  Los Angeles     f       usa
+COMPAQ 623462345       \N      t       usa
+SUN    784563253       \N      t       usa
+DIGITAL        922644516       \N      t       usa
+Frank Zappa    6734567 Montreal        f       usa
+Constantin Teodorescu  +40 39 611820   Braila  f       europe
+Ngbendu Wazabanga      34577345                f       africa
+Mugabe Kandalam        7635745         f       africa
+Vasile Lupu    52345623        Bucuresti       f       europe
+Gica Farafrica +42 64 4523454  Los Angeles     f       usa
+Victor Ciorbea 634567  Bucuresti       f       europe
+\.
+COPY "pga_layout" FROM stdin;
+pga_forms      2       formname formsource     82 713
+Usaisti        5       name phone_nr city company continent    150 150 150 150 150
+q1     5       name phone_nr city company continent    150 150 150 150 150
+view_saved_from_that_query     5       name phone_nr city company continent    150 150 150 150 150
+phonebook      5       name phone_nr city company continent    150 105 80 66 104
+Query that can be saved as view        5       name phone_nr city company continent    150 150 150 150 150
+pg_database    4       datname datdba encoding datpath 150 150 150 150
+pg_language    5       lanname lanispl lanpltrusted lanplcallfoid lancompiler  150 150 150 150 150
+cities 3       id name prefix  60 150 150
+       3       id name prefix  125 150 150
+       3       id name prefix  150 150 150
+       3       id name prefix  150 150 150
+       3       id name prefix  150 150 150
+\.
+COPY "pga_schema" FROM stdin;
+Simple schema  cities 10 10 phonebook 201.0 84.0       {cities name phonebook city}
+\.
+COPY "cities" FROM stdin;
+3      Braila  4039
+4      Galati  4036
+5      Dallas  5362
+6      Cairo   9352
+1      Bucuresti       4013
+7      Montreal        5325
+\.
+CREATE UNIQUE INDEX "cities_id_key" on "cities" using btree ( "id" "int4_ops" );
diff --git a/src/bin/pgaccess/doc/html/a_right.gif b/src/bin/pgaccess/doc/html/a_right.gif
new file mode 100644 (file)
index 0000000..386e27c
Binary files /dev/null and b/src/bin/pgaccess/doc/html/a_right.gif differ
diff --git a/src/bin/pgaccess/doc/html/addindex.gif b/src/bin/pgaccess/doc/html/addindex.gif
new file mode 100644 (file)
index 0000000..2ff0aa2
Binary files /dev/null and b/src/bin/pgaccess/doc/html/addindex.gif differ
diff --git a/src/bin/pgaccess/doc/html/api.html b/src/bin/pgaccess/doc/html/api.html
new file mode 100644 (file)
index 0000000..7630fd2
--- /dev/null
@@ -0,0 +1,232 @@
+<!doctype html public "-//w3c//dtd html 4.0 transitional//en">
+<html>
+<head>
+   <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
+   <meta name="GENERATOR" content="Mozilla/4.61 [en] (X11; I; Linux 2.2.11 i586) [Netscape]">
+</head>
+<body bgcolor="#FEFEDF">
+
+<h2>
+PgAccess developer API</h2>
+
+<hr>
+<br>Starting with PgAccess 0.98 I am planning to make available a complete
+API for the PgAccess developers. I plan to make PgAccess not just an administrative
+tool, but also a tool for easy build of small applications.
+<p>That's why PgAccess 0.98 has been internally restructured, every main
+module of PgAccess has became a namespace (see Tcl namespaces) in order&nbsp;
+to hide the variables and internal procedures to the user. Also, all the
+global variables that have been used before were grouped under a single
+big associative array called <b>PgAcVar</b> (PgAccess variables) so they
+should not interfere with user defined global variables.
+<br>&nbsp;
+<br>&nbsp;
+<p><b><font size=+1>Global variables available</font></b>
+<br>&nbsp;
+<center><table BORDER=0 WIDTH="100%" NOSAVE >
+<tr NOSAVE>
+<td ALIGN=LEFT VALIGN=TOP NOSAVE><b>PgAcVar</b></td>
+
+<td>The main global associative array that hold together various information
+needed by PgAccess. User should <b><font color="#FF0000">NOT</font></b>
+alter it under any circumstances.</td>
+</tr>
+
+<tr NOSAVE>
+<td VALIGN=TOP NOSAVE><b>CurrentDB</b></td>
+
+<td>The handler of the current opened database. Can be used for database
+operations as selects or command execution.</td>
+</tr>
+
+<tr NOSAVE>
+<td ALIGN=LEFT VALIGN=TOP NOSAVE><b>Messages</b></td>
+
+<td NOSAVE>The associative array that holds the translation for the current
+language. Loaded from the appropriate language file from lib/languages
+directory</td>
+</tr>
+
+<tr NOSAVE>
+<td ALIGN=LEFT VALIGN=TOP NOSAVE><b>PGACCESS_HOME</b></td>
+
+<td>Keep the system directory of PgAccess root installation</td>
+</tr>
+</table></center>
+
+<br>&nbsp;
+<p><b><font size=+1>Window naming convention</font></b>
+<p>Every toplevel window defined by PgAccess has the following naming convention.
+Every window name starts with <tt>.pgaw</tt> (PgAccess window) followed
+by a colon and a name. <i>Example:</i>
+<blockquote><tt>.pgaw:User , .pgaw:About , .pgaw:ImportExport</tt></blockquote>
+<b><font size=+1>Namespaces available</font></b>
+<p>For every tab from the main database window there is a namespace defined
+(Tables, Queries, Views, Functions, Sequences, Reports, Forms, Scripts,
+Users, Schema). Every namespace has by default the following&nbsp; procedures:
+<ul>
+<li>
+<tt>new</tt>&nbsp; , no parameter needed</li>
+
+<li>
+<tt>open</tt> , need a single parameter, the object name</li>
+
+<li>
+<tt>design</tt> , need a single parameter, the object name</li>
+</ul>
+You can use these procedures if you want to produce the same efects as
+clicking on the desired tab and then on the "New", "Open" or "Design" buttons
+from the main database window.
+<br><i>Example:</i>
+<blockquote><tt>Tables::open "customers"</tt>
+<br><tt>Queries::open "Invoices received"</tt>
+<br><tt>Forms::open "Add new invoice"</tt></blockquote>
+The <tt>Tables::open</tt> procedure accepts two optional parameters, filter
+and order.
+<br><i>Example:</i>
+<blockquote><tt>Tables::open "phonebook" "name ~* 'joe'" "age desc"</tt></blockquote>
+will open a table view window with predefined filter "name ~* 'joe'" and
+ordered by descending age.
+<p>There is also a special namespace called Database.&nbsp; Here are some
+procedures and functions defined for this namespace available to the user:
+<br>&nbsp;
+<table BORDER NOSAVE >
+<tr BGCOLOR="#FFCCFF" NOSAVE>
+<td NOSAVE><b>Name</b></td>
+
+<td NOSAVE><b>Parameters</b></td>
+
+<td><b>Type</b></td>
+
+<td><b>Returns</b></td>
+
+<td NOSAVE><b>Description</b></td>
+</tr>
+
+<tr>
+<td><b>vacuum</b></td>
+
+<td>none</td>
+
+<td>procedure</td>
+
+<td>nothing</td>
+
+<td>vacuums the current database</td>
+</tr>
+
+<tr ALIGN=LEFT VALIGN=TOP NOSAVE>
+<td><b>getTablesList</b></td>
+
+<td>none</td>
+
+<td>function</td>
+
+<td>list</td>
+
+<td NOSAVE>returns the list of tables from the current database</td>
+</tr>
+
+<tr ALIGN=LEFT VALIGN=TOP NOSAVE>
+<td><b>executeUpdate</b></td>
+
+<td>sqlcmd</td>
+
+<td>function</td>
+
+<td>integer</td>
+
+<td NOSAVE>execute the sqlcmd command on the current database returning
+1 if no errors ocurred or 0 if the command failed</td>
+</tr>
+</table>
+
+<p><b><font size=+1>Global functions available</font></b>
+<br>&nbsp;
+<table BORDER NOSAVE >
+<tr BGCOLOR="#99FFCC" NOSAVE>
+<td><b>Name</b></td>
+
+<td><b>Parameters</b></td>
+
+<td NOSAVE><b>Description</b></td>
+</tr>
+
+<tr ALIGN=LEFT VALIGN=TOP NOSAVE>
+<td><b>setCursor</b></td>
+
+<td>type</td>
+
+<td NOSAVE>Set the cursor for all PgAccess windows, type of cursor can
+be WAIT or CLOCK or WATCH for the hourglass , anything else (or none) to
+return to the normal cursor shape</td>
+</tr>
+
+<tr ALIGN=LEFT VALIGN=TOP NOSAVE>
+<td><b>parameter</b></td>
+
+<td>msg</td>
+
+<td NOSAVE>Shows a modal input dialog with the msg message, wait for user
+to enter the data and returns it as a string</td>
+</tr>
+
+<tr>
+<td><b>showError</b></td>
+
+<td>msg</td>
+
+<td>Shows a modal dialog window with an error message</td>
+</tr>
+
+<tr>
+<td></td>
+
+<td></td>
+
+<td></td>
+</tr>
+
+<tr>
+<td></td>
+
+<td></td>
+
+<td></td>
+</tr>
+
+<tr>
+<td></td>
+
+<td></td>
+
+<td></td>
+</tr>
+
+<tr>
+<td></td>
+
+<td></td>
+
+<td></td>
+</tr>
+
+<tr>
+<td></td>
+
+<td></td>
+
+<td></td>
+</tr>
+
+<tr>
+<td></td>
+
+<td></td>
+
+<td></td>
+</tr>
+</table>
+
+</body>
+</html>
diff --git a/src/bin/pgaccess/doc/html/ball.gif b/src/bin/pgaccess/doc/html/ball.gif
new file mode 100644 (file)
index 0000000..02d2034
Binary files /dev/null and b/src/bin/pgaccess/doc/html/ball.gif differ
diff --git a/src/bin/pgaccess/doc/html/contents.html b/src/bin/pgaccess/doc/html/contents.html
new file mode 100644 (file)
index 0000000..971f3f4
--- /dev/null
@@ -0,0 +1,29 @@
+<!doctype html public "-//w3c//dtd html 4.0 transitional//en">
+<html>
+<head>
+   <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
+   <meta name="GENERATOR" content="Mozilla/4.61 [en] (X11; I; Linux 2.2.11 i586) [Netscape]">
+   <base target="right">
+</head>
+<body bgcolor="#00FFFF">
+<img SRC="ball.gif" ><a href="main.html">What is PgAccess?</a>
+<br><img SRC="ball.gif" ><a href="whatsnew.html">What's new?</a>
+<br><img SRC="ball.gif" ><a href="features.html">Features</a>
+<br><img SRC="ball.gif" ><a href="screenshots.html">Screenshots</a>
+<br><img SRC="ball.gif" ><a href="faq.html">FAQ</a>
+<br><img SRC="ball.gif" ><a href="documentation.html">Documentation</a>
+<br><img SRC="ball.gif" ><a href="todo.html">To-Do list</a>
+<br><img SRC="ball.gif" ><a href="download.html">Download</a>
+<br>&nbsp;
+<p><br>
+<center>
+<p><a href="http://www.linux.org"><img SRC="linux1.gif" BORDER=0 ></a></center>
+
+<p><b>Other links</b>
+<br><img SRC="ball.gif" ><a href="http://www.postgresql.org">PostgreSQL</a>
+<br><img SRC="ball.gif" ><a href="http://www.neuron.com/stewart/vtcl/index.html">Visual Tcl</a>
+<br><img SRC="ball.gif" ><a href="http://www.scriptics.com">Tcl/Tk</a>
+<br><img SRC="ball.gif" ><a href="http://www.linux.org">Linux</a>
+<br><img SRC="ball.gif" ><a href="http://www.java.ro/vtclava/index.html">vTcLava</a>
+</body>
+</html>
diff --git a/src/bin/pgaccess/doc/html/copyright.html b/src/bin/pgaccess/doc/html/copyright.html
new file mode 100644 (file)
index 0000000..d67654b
--- /dev/null
@@ -0,0 +1,39 @@
+<HTML>
+<HEAD>
+   <META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=iso-8859-1">
+   <META NAME="GENERATOR" CONTENT="Mozilla/4.03 [en] (X11; I; Linux 2.0.30 i586) [Netscape]">
+   <TITLE>PgAccess - Copyright notice</TITLE>
+</HEAD>
+<BODY BGCOLOR="#FFFFFF">
+<TT>---------------------------------------------------------------------------</TT>
+<BR><TT></TT>&nbsp;
+<BR><TT></TT>&nbsp;<TT></TT>
+
+<P><TT>Copyright (c) 1994-7 Regents of the University of California</TT><TT></TT>
+
+<P><TT>Permission to use, copy, modify, and distribute this software and
+its</TT>
+<BR><TT>documentation for any purpose, without fee, and without a written
+agreement</TT>
+<BR><TT>is hereby granted, provided that the above copyright notice and
+this</TT>
+<BR><TT>paragraph and the following two paragraphs appear in all copies.</TT><TT></TT>
+
+<P><TT>IN NO EVENT SHALL THE UNIVERSITY OF CALIFORNIA BE LIABLE TO ANY
+PARTY FOR</TT>
+<BR><TT>DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES,
+INCLUDING</TT>
+<BR><TT>LOST PROFITS, ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS</TT>
+<BR><TT>DOCUMENTATION, EVEN IF THE UNIVERSITY OF CALIFORNIA HAS BEEN ADVISED
+OF THE</TT>
+<BR><TT>POSSIBILITY OF SUCH DAMAGE.</TT><TT></TT>
+
+<P><TT>THE UNIVERSITY OF CALIFORNIA SPECIFICALLY DISCLAIMS ANY WARRANTIES,</TT>
+<BR><TT>INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY</TT>
+<BR><TT>AND FITNESS FOR A PARTICULAR PURPOSE. THE SOFTWARE PROVIDED HEREUNDER
+IS</TT>
+<BR><TT>ON AN "AS IS" BASIS, AND THE UNIVERSITY OF CALIFORNIA HAS NO OBLIGATIONS
+TO</TT>
+<BR><TT>PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.</TT>
+</BODY>
+</HTML>
diff --git a/src/bin/pgaccess/doc/html/documentation.html b/src/bin/pgaccess/doc/html/documentation.html
new file mode 100644 (file)
index 0000000..48d3fa5
--- /dev/null
@@ -0,0 +1,19 @@
+<!doctype html public "-//w3c//dtd html 4.0 transitional//en">
+<html>
+<head>
+   <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
+   <meta name="GENERATOR" content="Mozilla/4.61 [en] (X11; I; Linux 2.2.11 i586) [Netscape]">
+</head>
+<body bgcolor="#FEFEDF">
+
+<h2>
+Documentation</h2>
+
+<hr WIDTH="100%">
+<p>Still need to be written. Some information can be found in the help
+included in the main program.
+<p>Jim Lemon &lt;Jim.Lemon@uts.EDU.AU> has started writing a <a href="tutorial/index.html">tutorial</a>.
+Thought it is based on earlier versions than 0.98 it is a beginning after
+all, isn't it ?
+</body>
+</html>
diff --git a/src/bin/pgaccess/doc/html/download.html b/src/bin/pgaccess/doc/html/download.html
new file mode 100644 (file)
index 0000000..efbe7bf
--- /dev/null
@@ -0,0 +1,42 @@
+<!doctype html public "-//w3c//dtd html 4.0 transitional//en">
+<html>
+<head>
+   <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
+   <meta name="GENERATOR" content="Mozilla/4.61 [en] (X11; I; Linux 2.2.11 i586) [Netscape]">
+</head>
+<body bgcolor="#FEFEDF">
+
+<h2>
+Download</h2>
+
+<hr>
+<br>The primary site for PgAccess downloads is:
+<ul><a href="ftp://ftp.flex.ro/pub/pgaccess">ftp://ftp.flex.ro/pub/pgaccess</a>
+<ul>
+<li>
+<a href="ftp://ftp.flex.ro/pub/pgaccess/pgaccess-0.98.tar.gz">Unix tar.gz
+file</a></li>
+
+<li>
+<a href="ftp://ftp.flex.ro/pub/pgaccess/pgaccess-0.98.zip">Windows .zip
+file</a></li>
+</ul>
+</ul>
+
+<p>Another one (just with a little bit faster, try this one first) would
+be :
+<ul><a href="ftp://speedy.flex.ro/pub/pgaccess">ftp://speedy.flex.ro/pub/pgaccess</a>
+<ul>
+<li>
+<a href="ftp://speedy.flex.ro/pub/pgaccess/pgaccess-0.98.tar.gz">Unix tar.gz
+file</a></li>
+
+<li>
+<a href="ftp://speedy.flex.ro/pub/pgaccess/pgaccess-0.98.zip">Windows .zip
+file</a></li>
+</ul>
+</ul>
+
+<br>&nbsp;
+</body>
+</html>
diff --git a/src/bin/pgaccess/doc/html/faq.html b/src/bin/pgaccess/doc/html/faq.html
new file mode 100644 (file)
index 0000000..f66dd83
--- /dev/null
@@ -0,0 +1,85 @@
+<!doctype html public "-//w3c//dtd html 4.0 transitional//en">
+<html>
+<head>
+   <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
+   <meta name="GENERATOR" content="Mozilla/4.61 [en] (X11; I; Linux 2.2.12 i586) [Netscape]">
+</head>
+<body bgcolor="#FEFEDF">
+
+<h2>
+PgAccess - FAQ</h2>
+
+<hr>
+<br><b>1. When I run PgAccess I got a message complaining about the crypt
+library! What should I do?</b>
+<blockquote>Versions of PostgreSQL prior to 6.5.1 couldn't reliably detect
+the presence of the crypt library on RedHat 5.x systems. That's why the
+libpgtcl library does not include reference to crypt. You will need to
+get a proper copy of libpgtcl.so library or to compile one. Go to the postgresql
+source directory into src/interfaces/libpgtcl and edit Makefile adding
+-lcrypt to the end of the line SHLIB_LINKS. Make clean and make again.
+Your libpgtcl.so is now prepare to run PgAccess. I strongly recommend you
+to upgrade to PostgreSQL 6.5.1 where this problem has been solved.</blockquote>
+<b>2. I cannot connect to a database from another machine</b>
+<blockquote>There may be two problems here. First of all, PgAccess running
+on the localhost is using two PostgreSQL dependent libraries, libpq and
+libpgtcl. Each of them are compiled for a specific PostgreSQL version.
+If the PostgreSQL version running on your server is different you might
+experience problems. The other problem is related to access rights. On
+the PostgreSQL server, in data directory there is a file pg_hba.conf that
+will grant access rights to users based on host authentication. Ask your
+database administrator to check if your workstation is listed there with
+the appropriate access rights. Try for the beginning the 'trust' mode,
+allowing full access to the databases.</blockquote>
+<b>3. I am experiencing core dumps when trying to run PgAccess. Is PgAccess
+broken?</b>
+<blockquote>No. There were NEVER reported crashes because of PgAccess.
+All of them were related to bad libraries usage. The most frequent was
+the installing of a new PostgreSQL on a RedHat 5.x server where the postgresql-clients
+rpm still exists. So, PgAccess was trying to use the old libpgtcl.so library
+suitable for an older version of PostgreSQL. Before installing a new PostgreSQL
+(either by compiling it ot by rpm packages) remove ANY TRACE of old PostgreSQL.
+PgAccess is fully relying on libpgtcl library in order to get access to
+the database so when you are experiencing that kind of problems, double-check
+libpq and libpgtcl libraries.</blockquote>
+<b>4. When I try to run PgAccess I get the following error : Application
+initialization failed: couldn't connect to display ""</b>
+<blockquote>That kind of error was reported on some Linux RedHat 5.x systems
+when user has su - to root and tried to run PgAccess. Some unknown errors
+in login scripts are not defining the DISPLAY environment and the wish
+application cannot connect to the X display. Try typing <tt>export DISPLAY=localhost:0.0</tt>
+and run PgAccess again.</blockquote>
+<b>5. Cannot run PgAccess on a Windows machine.</b>
+<blockquote>In order to use PgAccess on Windows you must have installed
+two libraries libpq.dll and libpgtcl.dll suitable for your Tcl/Tk package
+and your PostgreSQL server. Note that libraries that work with Tcl/Tk 8.0.x
+won't work with Tcl/Tk 8.1.x and libraries that work with 6.4.2 backend
+won't work with 6.5.x. So, you must properly identify your Tcl/Tk package
+version and your PostgreSQL version and download from the Downloads section
+(or pick from the win32/dll directory of PgAccess distribution) the right
+files. Copy them into your Windows/System directory and try again. Also,
+you should be able to access over the network the machine running the PostgreSQL
+server (try ping-ing it) and have the proper access rights to the database.</blockquote>
+<b>6. How much costs PgAccess?</b>
+<blockquote>PgAccess is a free tool. You won't have to pay anything in
+order to use it. It is protected by the following <a href="copyright.html">copyright</a>
+as PostgreSQL is. I cannot guarantee technical support but I will try to
+answer to your questions as much as I can.</blockquote>
+<b>7. I want to translate PgAccess messages for xxx language. What should
+I do?</b>
+<blockquote>In the PgAccess distribution in lib/languages directory there
+are files with messages translated for different languages. Copy one of
+them and name it after your native language and then start editing it translating
+all the messages. Save it into the same directory and that's all. Don't
+forget to send me a copy in order to include it into the standard distribution.</blockquote>
+
+<p><br><b>8. I am receiving the following error: <tt>message invalid command
+name "namespace" while executing "namespace eval Mainlib</tt>&nbsp; ..."</b>
+<blockquote>That means 100% that you have an older version of Tcl/Tk that
+don't recognize namespaces command. Please upgrade to Tcl/Tk 8.0.x minimum</blockquote>
+
+<br>&nbsp;
+<br>&nbsp;
+<br>&nbsp;
+</body>
+</html>
diff --git a/src/bin/pgaccess/doc/html/features.html b/src/bin/pgaccess/doc/html/features.html
new file mode 100644 (file)
index 0000000..4531663
--- /dev/null
@@ -0,0 +1,52 @@
+<!doctype html public "-//w3c//dtd html 4.0 transitional//en">
+<html>
+<head>
+   <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
+   <meta name="GENERATOR" content="Mozilla/4.61 [en] (X11; I; Linux 2.2.11 i586) [Netscape]">
+</head>
+<body bgcolor="#FEFEDF">
+<b>Tables</b>
+<br>- opening multiple tables for viewing, max. n records (changed by preferences
+menu)
+<br>- column resizing, dragging the vertical grid line (better in table
+space rather than in the table header)
+<br>- text wrap in cells - layout saved for every table
+<br>- import/export to external files (SDF,CSV)
+<br>- filter capabilities (enter filter like (price>3.14)
+<br>- sort order capabilities (enter manually the sort field(s))
+<br>- editing in place
+<br>- improved table generator assistant
+<br>- improved field editing
+<br><b>Queries</b>
+<br>- define , edit and stores "user defined queries"
+<br>- store queries as views
+<br>- execution of queries with optional user input parameters ( select
+* from invoices where year=[parameter "Year of selection"] )
+<br>- viewing of select type queries result
+<br>- query deleting and renaming
+<br>- visual query builder with drag &amp; drop capabilities. For any of
+you who had installed the Tcl/Tk plugin for Netscape Navigator, you can
+see it at work <a href="qbtclet.html">clicking here</a>
+<br><b>Sequences</b>
+<br>- defines sequences, delete them and inspect them
+<br><b>Functions</b>
+<br>- define, inspect and delete functions in SQL, plpgsql and pgtcl languages
+<br><b>Reports</b>
+<br>- design and display simple reports from tables
+<br>- fields and labels, font changing, style and size
+<br>- saves and loads report description from database
+<br>- show report previews, sample postscript output file
+<br><b>Forms</b>
+<br>- open user defined forms
+<br>- form design module available
+<br>- query widget available, controls bound to query results
+<br>- <a href="forms.html">click here</a> for a description of forms and
+how they can be used
+<br><b>Scripts</b>
+<br>- define, modify and call user defined scripts
+<br><b>Users</b>
+<br>- define and modify user information
+<p><b><a href="api.html">PgAccess API</a></b> for developing small applications
+<br>&nbsp;
+</body>
+</html>
diff --git a/src/bin/pgaccess/doc/html/formdemo.sql b/src/bin/pgaccess/doc/html/formdemo.sql
new file mode 100644 (file)
index 0000000..73bf1c5
--- /dev/null
@@ -0,0 +1,216 @@
+\connect - teo
+CREATE SEQUENCE "cities_id_seq" start 7 increment 1 maxvalue 2147483647 minvalue 1  cache 1 ;
+SELECT nextval ('cities_id_seq');
+CREATE TABLE "pga_queries" (
+       "queryname" character varying(64),
+       "querytype" character,
+       "querycommand" text,
+       "querytables" text,
+       "querylinks" text,
+       "queryresults" text,
+       "querycomments" text);
+CREATE TABLE "pga_forms" (
+       "formname" character varying(64),
+       "formsource" text);
+CREATE TABLE "pga_scripts" (
+       "scriptname" character varying(64),
+       "scriptsource" text);
+CREATE TABLE "pga_reports" (
+       "reportname" character varying(64),
+       "reportsource" text,
+       "reportbody" text,
+       "reportprocs" text,
+       "reportoptions" text);
+CREATE TABLE "phonebook" (
+       "name" character varying(32),
+       "phone_nr" character varying(16),
+       "city" character varying(32),
+       "company" bool,
+       "continent" character varying(16));
+CREATE TABLE "pga_layout" (
+       "tablename" character varying(64),
+       "nrcols" int2,
+       "colnames" text,
+       "colwidth" text);
+CREATE TABLE "pga_schema" (
+       "schemaname" character varying(64),
+       "schematables" text,
+       "schemalinks" text);
+REVOKE ALL on "pga_schema" from PUBLIC;
+GRANT ALL on "pga_schema" to PUBLIC;
+CREATE TABLE "cities" (
+       "id" int4 DEFAULT nextval('"cities_id_seq"') NOT NULL,
+       "name" character varying(32) NOT NULL,
+       "prefix" character varying(16) NOT NULL);
+CREATE FUNCTION "getcityprefix" (int4 ) RETURNS varchar AS 'select prefix from cities where id = $1 ' LANGUAGE 'SQL';
+COPY "pga_queries" FROM stdin;
+Query that can be saved as view        S       select * from phonebook where continent='usa'           \N      \N      \N      \N
+\.
+COPY "pga_forms" FROM stdin;
+Working with Tables namespace  f3 13 {3 4 5 6 7 9 10 11 12 13} 377x263+59+127 {radio usa {36 24 138 36} {} USA selcont} {radio europe {36 45 141 60} {} Europe selcont} {radio africa {36 66 147 81} {} Africa selcont} {label label6 {9 99 339 114} {} {Select one of the above continents and press} {}} {button button7 {270 93 354 117} {Tables::open phonebook "continent='$selcont'" $selorder} {Show them} {}} {button button9 {66 189 312 213} {Tables::design phonebook} {Show me the phonebook table structure} {}} {button button10 {141 228 240 252} {destroy .f3} {Close the form} {}} {button button11 {93 141 282 165} {Tables::open phonebook "company=true"} {Show me only the companies} {}} {radio name {183 24 261 36} {} {Order by name} selorder} {radio phone_nr {183 45 267 57} {} {Order by phone number} selorder}
+A simple demo form     asdf 14 {FS {set color none}} 370x310+50+75 {label label1 {15 36 99 57} {} {Selected color} {} label1 flat #000000 #d9d9d9 1} {entry entry2 {111 36 225 54} {} entry2 color entry2 sunken #000000 #fefefe 1} {radio red {249 21 342 36} {} {Red as cherry} color red flat #900000 #d9d9d9 1} {radio green {249 45 342 60} {} {Green as a melon} color green flat #008800 #d9d9d9 1} {radio blue {249 69 342 84} {} {Blue as the sky} color blue flat #00008c #d9d9d9 1} {button button6 {45 69 198 99} {set color spooky} {Set a weird color} {} button6 ridge #0000b0 #dfbcdf 2} {label label7 {24 129 149 145} {} {The checkbox's value} {} label7 flat #000000 #d9d9d9 1} {entry entry8 {162 127 172 145} {} entry8 cbvalue entry8 sunken #000000 #fefefe 1} {checkbox checkbox9 {180 126 279 150} {} {Check me :-)} cbvalue checkbox9 flat #000000 #d9d9d9 1} {button button10 {219 273 366 303} {destroy .asdf} {Close that simple form} {} button10 raised #000000 #d9d9d9 1} {button button11 {219 237 366 267} {Forms::open "Phone book"} {Open my phone book} {} button11 raised #000000 #d9d9d9 1} {listbox lb {12 192 162 267} {} listbox12 {} lb sunken #000000 #fefefe 1} {button button13 {12 156 162 186} {.asdf.lb insert end red green blue cyan white navy black purple maroon violet} {Add some information} {} button13 raised #000000 #d9d9d9 1} {button button14 {12 273 162 303} {.asdf.lb delete 0 end} {Clear this listbox} {} button14 raised #000000 #d9d9d9 1}
+Working with listboxes f2 5 {FS {set thestudent ""}} 257x263+139+147 {listbox lb {6 6 246 186} {} listbox1 {} lb sunken #000000 #ffffd4 1} {button button2 {9 234 124 258} {# Populate the listbox with some data\
+#\
+\
+foreach student {John Bill Doe Gigi} {\
+\      .f2.lb insert end $student\
+}\
+\
+\
+\
+# Binding the event left button release to the\
+# list box\
+\
+bind .f2.lb <ButtonRelease-1> {\
+\      set idsel [.f2.lb curselection]\
+\      if {$idsel!=""} {\
+\      \       set thestudent [.f2.lb get $idsel]\
+\      }\
+}\
+\
+# Cleaning the variable thestudent\
+\
+set thestudent {}} {Show students} {} button2 groove #000000 #d9d9d9 2} {button button3 {132 234 247 258} {destroy .f2} {Close the form} {} button3 groove #000000 #d9d9d9 1} {label label4 {9 213 119 228} {} {You have selected} {} label4 flat #000000 #d9d9d9 1} {label label5 {129 213 219 228} {} {} thestudent label5 flat #00009a #d9d9d9 1}
+The simplest form      mf 5 {FS {set thename {}}} 306x136+82+146 {label label {42 45 99 60} {} Name {} label flat #000000 #d9d9d9 1 {Helvetica 12 bold italic}} {entry ename {120 42 219 63} {} entry2 thename ename sunken #000000 #fefefe 1 n} {button button3 {6 96 108 129} {set thename Teo} {Set the name} {} button3 raised #000000 #d9d9d9 1 n} {button button4 {192 96 300 129} {destroy .mf} {Close the form} {} button4 raised #000000 #d9d9d9 1 n} {button button5 {114 96 186 129} {set thename {}} {Clear it} {} button5 raised #000000 #d9d9d9 1 n}
+Full featured form     full 21 {FS {set entrydemo {nice}\
+set color {no color selected}}} 377x418+50+130 {label label1 {3 396 165 411} {} {Status line} {} {} sunken #000000 #d9d9d9 2 n} {label label2 {171 396 369 411} {} {Grooved status line} {} {} groove #000098 #d9d9d9 2 f} {label label3 {108 9 270 31} {} {     Full featured form} {} {} ridge #000000 #d9d9d9 4 {Times 16 bold italic}} {button button4 {15 210 144 243} {.full.lb insert end {it's} a nice demo form} {Java style button} {} {} groove #6161b6 #d9d9d9 2 b} {label label5 {15 42 115 58} {} {Java style label} {} {} flat #6161b6 #d9d9d9 1 b} {entry entry6 {123 39 279 60} {} entry6 entrydemo {} groove #000000 #fefefe 2 {Courier 13}} {listbox lb {12 69 147 201} {} listbox8 {} {} ridge #000000 #ffffc8 2 n} {button button9 {18 264 39 282} {} 1 {} {} flat #000000 #d9d9d9 1 n} {button button10 {48 264 68 282} {} 2 {} {} flat #000000 #d9d9d9 1 n} {button button11 {78 264 234 282} {} {and other hidden buttons} {} {} flat #000000 #d9d9d9 1 n} {text txt {153 69 372 201} {} text12 {} {} sunken #000000 #d4ffff 1 n} {button button13 {150 210 369 243} {.full.txt tag configure bold -font {Helvetica 12 bold}\
+.full.txt tag configure italic -font {Helvetica 12 italic}\
+.full.txt tag configure large -font {Helvetica -14 bold}\
+.full.txt tag configure title -font {Helvetica 12 bold italic} -justify center\
+.full.txt tag configure link -font {Helvetica -12 underline} -foreground #000080\
+.full.txt tag configure code -font {Courier 13}\
+.full.txt tag configure warning -font {Helvetica 12 bold} -foreground #800000\
+\
+# That't the way help files are written\
+\
+.full.txt delete 1.0 end\
+.full.txt insert end {Centered title} {title} "\
+\
+You can make different " {} "portions of text bold" {bold} " or italic " {italic} ".\
+Some parts of them can be written as follows" {} "\
+SELECT * FROM PHONEBOOK" {code} "\
+You can also change " {} "colors for some words " {warning} "or underline them" {link} } {Old style button} {} {} raised #000000 #d9d9d9 2 n} {checkbox checkbox14 {48 297 153 309} {} different {} {} flat #00009c #d9d9d9 1 b} {checkbox checkbox15 {48 321 156 336} {} {fonts and} {} {} flat #cc0000 #d9d9d9 1 i} {checkbox checkbox16 {48 345 156 360} {} colors {} {} flat #00b600 #dfb2df 1 f} {radio radio17 {207 297 330 315} {} {red , rosu , rouge} color red flat #9c0000 #d9d9d9 1 n} {radio radio18 {207 321 324 333} {} {green , verde , vert} color green flat #009000 #d9d9d9 1 n} {radio radio19 {207 345 327 363} {} {blue , albastru, bleu} color blue flat #000000 #d9d9d9 1 n} {label selcolor {210 369 345 384} {} {} color {} flat #000000 #d9d9d9 1 n} {button button21 {285 258 363 285} {destroy .full} Exit {} {} raised #7c0000 #dfdbb8 1 b}
+Phone book     pb 28 {FS {}} 444x307+284+246 {label label1 {33 10 68 28} {} Name {} label1 flat #000000 #d9d9d9 1 n} {entry name_entry {87 9 227 27} {} entry2 DataSet(.pb.qs,name) name_entry sunken #000000 #fefefe 1 n} {label label3 {33 37 73 52} {} Phone {} label3 flat #000000 #d9d9d9 1 n} {entry entry4 {87 36 195 54} {} entry4 DataSet(.pb.qs,phone_nr) entry4 sunken #000000 #fefefe 1 n} {label label5 {33 64 78 82} {} City {} label5 flat #000000 #d9d9d9 1 n} {entry entry6 {87 63 195 81} {} entry6 DataSet(.pb.qs,city) entry6 sunken #000000 #fefefe 1 n} {query qs {3 6 33 33} {} query7 {} qs flat {} {} 1 n} {button button8 {174 177 246 203} {namespace eval DataControl(.pb.qs) {\
+\      setSQL "select oid,* from phonebook where name ~* '$what' order by name"\
+\      open\
+\      set nrecs [getRowCount]\
+\      updateDataSet\
+\      fill .pb.allnames name\
+\      bind .pb.allnames <ButtonRelease-1> {\
+\         set ancr [.pb.allnames curselection]\
+\         if {$ancr!=""} {\
+\      \       DataControl(.pb.qs)::moveTo $ancr\
+\      \       DataControl(.pb.qs)::updateDataSet\
+\         }\
+\      }\
+}} {Start search} {} button8 raised #000000 #d9d9d9 1 n} {button button9 {363 276 433 300} {DataControl(.pb.qs)::close\
+DataControl(.pb.qs)::clearDataSet\
+set nrecs {}\
+set what {}\
+destroy .pb\
+} Exit {} button9 raised #000000 #d9d9d9 2 n} {button button10 {291 237 313 257} {namespace eval DataControl(.pb.qs) {\
+\      moveFirst\
+\      updateDataSet\
+}\
+} |< {} button10 ridge #000092 #d9d9d9 2 n} {button button11 {324 237 346 257} {namespace eval DataControl(.pb.qs) {\
+\      movePrevious\
+\      updateDataSet\
+}\
+} << {} button11 ridge #000000 #d9d9d9 2 n} {button button12 {348 237 370 257} {namespace eval DataControl(.pb.qs) {\
+\      moveNext\
+\      updateDataSet\
+}} >> {} button12 ridge #000000 #d9d9d9 2 n} {button button13 {381 237 403 257} {namespace eval DataControl(.pb.qs) {\
+\      moveLast\
+\      updateDataSet\
+}\
+} >| {} button13 ridge #000088 #d9d9d9 2 n} {checkbox checkbox14 {33 87 126 105} {} {Is it a company ?} DataSet(.pb.qs,company) checkbox14 flat #000000 #d9d9d9 1 n} {radio usa {63 108 201 120} {} U.S.A. DataSet(.pb.qs,continent) usa flat #000000 #d9d9d9 1 n} {radio europe {63 126 204 141} {} Europe DataSet(.pb.qs,continent) europe flat #000000 #d9d9d9 1 n} {radio africa {63 144 210 159} {} Africa DataSet(.pb.qs,continent) africa flat #000000 #d9d9d9 1 n} {entry entry18 {129 180 169 198} {} entry18 what entry18 sunken #000000 #fefefe 1 n} {label label19 {108 219 188 234} {} {records found} {} label19 flat #000000 #d9d9d9 1 n} {label label20 {90 219 105 234} {} { } nrecs label20 flat #000000 #d9d9d9 1 n} {label label21 {3 252 33 267} {} OID= {} label21 flat #000000 #d9d9d9 1 n} {label label22 {39 252 87 267} {} { } pbqs(oid) label22 flat #000000 #d9d9d9 1 n} {button button23 {9 276 79 300} {set oid {}\
+catch {set oid $DataSet(.pb.qs,oid)}\
+if {[string trim $oid]!=""} {\
+   sql_exec noquiet "update phonebook set name='$DataSet(.pb.qs,name)', phone_nr='$DataSet(.pb.qs,phone_nr)',city='$DataSet(.pb.qs,city)',company='$DataSet(.pb.qs,company)',continent='$DataSet(.pb.qs,continent)' where oid=$oid"\
+} else {\
+  tk_messageBox -title Error -message "No record is displayed!"\
+}\
+\
+} Update {} button23 raised #000000 #d9d9d9 1 n} {button button24 {210 276 280 300} {set thisname $DataSet(.pb.qs,name)\
+if {[string trim $thisname] != ""} {\
+\      sql_exec noquiet "insert into phonebook values (\
+\      \       '$DataSet(.pb.qs,name)',\
+\      \       '$DataSet(.pb.qs,phone_nr)',\
+\      \       '$DataSet(.pb.qs,city)',\
+\      \       '$DataSet(.pb.qs,company)',\
+\      \       '$DataSet(.pb.qs,continent)'\
+\      )"\
+\      tk_messageBox -title Information -message "A new record has been added!"\
+} else {\
+\      tk_messageBox -title Error -message "This one doesn't have a name?"\
+}\
+\
+} {Add record} {} button24 raised #000000 #d9d9d9 1 n} {button button25 {141 276 204 300} {DataControl(.pb.qs)::clearDataSet\
+# clearcontrols stillinitialise\
+# incorectly booleans controls to {}\
+# so I force it to 'f' (false)\
+set DataSet(.pb.qs,company) f\
+focus .pb.name_entry} {Clear all} {} button25 raised #000000 #d9d9d9 1 n} {listbox allnames {249 6 435 231} {} listbox26 {} allnames sunken #000000 #fefefe 1 n} {label label27 {33 252 90 267} {} {} DataSet(.pb.qs,oid) label27 flat #000000 #d9d9d9 1 n} {label label28 {3 182 128 197} {} {Find name containing} {} {} flat #000000 #d9d9d9 1 n}
+\.
+COPY "pga_scripts" FROM stdin;
+How are forms keeped inside ?  Tables::open pga_forms\
+\
+\
+\
+
+Opening a table with filters   Tables::open phonebook "name ~* 'e'" "name desc"\
+\
+\
+
+Autoexec       Mainlib::tab_click Forms\
+Forms::open {Full featured form}\
+\
+\
+
+\.
+COPY "pga_reports" FROM stdin;
+My phone book  phonebook       set PgAcVar(report,tablename) "phonebook" ; set PgAcVar(report,y_rpthdr) 21 ; set PgAcVar(report,y_pghdr) 47 ; set PgAcVar(report,y_detail) 66 ; set PgAcVar(report,y_pgfoo) 96 ; set PgAcVar(report,y_rptfoo) 126 ; .pgaw:ReportBuilder.c create text 10 35 -font -Adobe-Helvetica-Bold-R-Normal--*-120-*-*-*-*-*-* -anchor nw -text {name} -tags {t_l mov ro} ; .pgaw:ReportBuilder.c create text 10 52 -font -Adobe-Helvetica-Medium-R-Normal-*-*-120-*-*-*-*-* -anchor nw -text {name} -tags {f-name t_f rg_detail mov ro} ; .pgaw:ReportBuilder.c create text 141 36 -font -Adobe-Helvetica-Bold-R-Normal--*-120-*-*-*-*-*-* -anchor nw -text {city} -tags {t_l mov ro} ; .pgaw:ReportBuilder.c create text 141 51 -font -Adobe-Helvetica-Medium-R-Normal-*-*-120-*-*-*-*-* -anchor nw -text {city} -tags {f-city t_f rg_detail mov ro} ; .pgaw:ReportBuilder.c create text 231 35 -font -Adobe-Helvetica-Bold-R-Normal--*-120-*-*-*-*-*-* -anchor nw -text {phone_nr} -tags {t_l mov ro} ; .pgaw:ReportBuilder.c create text 231 51 -font -Adobe-Helvetica-Medium-R-Normal-*-*-120-*-*-*-*-* -anchor nw -text {phone_nr} -tags {f-phone_nr t_f rg_detail mov ro}  \N      \N
+\.
+COPY "phonebook" FROM stdin;
+FIAT   623463445               t       europe
+Gelu Voican    01-32234        Bucuresti       f       europe
+Radu Vasile    01-5523423      Bucuresti       f       europe
+MUGADUMBU SRL  +92 534662634   Cairo   t       africa
+Jimmy Page     66323452                f       europe
+IBM    623346234       \N      t       usa
+John Doe       +44 35 2993825  Washington      f       usa
+Bill Clinton   +44 35 9283845  New York        f       usa
+Monica Levintchi       +44 38 5234526  Dallas  f       usa
+Bill Gates     +42 64 4523454  Los Angeles     f       usa
+COMPAQ 623462345       \N      t       usa
+SUN    784563253       \N      t       usa
+DIGITAL        922644516       \N      t       usa
+Frank Zappa    6734567 Montreal        f       usa
+Constantin Teodorescu  +40 39 611820   Braila  f       europe
+Ngbendu Wazabanga      34577345                f       africa
+Mugabe Kandalam        7635745         f       africa
+Vasile Lupu    52345623        Bucuresti       f       europe
+Gica Farafrica +42 64 4523454  Los Angeles     f       usa
+Victor Ciorbea 634567  Bucuresti       f       europe
+\.
+COPY "pga_layout" FROM stdin;
+pga_forms      2       formname formsource     82 713
+Usaisti        5       name phone_nr city company continent    150 150 150 150 150
+q1     5       name phone_nr city company continent    150 150 150 150 150
+view_saved_from_that_query     5       name phone_nr city company continent    150 150 150 150 150
+phonebook      5       name phone_nr city company continent    150 105 80 66 104
+Query that can be saved as view        5       name phone_nr city company continent    150 150 150 150 150
+cities 3       id name prefix  150 150 150
+\.
+COPY "pga_schema" FROM stdin;
+Simple schema  cities 10 10 phonebook 201.0 84.0       {cities name phonebook city}
+\.
+COPY "cities" FROM stdin;
+3      Braila  4039
+4      Galati  4036
+5      Dallas  5362
+6      Cairo   9352
+1      Bucuresti       4013
+7      Montreal        5325
+\.
+CREATE UNIQUE INDEX "cities_id_key" on "cities" using btree ( "id" "int4_ops" );
diff --git a/src/bin/pgaccess/doc/html/forms.gif b/src/bin/pgaccess/doc/html/forms.gif
new file mode 100644 (file)
index 0000000..947d920
Binary files /dev/null and b/src/bin/pgaccess/doc/html/forms.gif differ
diff --git a/src/bin/pgaccess/doc/html/forms.html b/src/bin/pgaccess/doc/html/forms.html
new file mode 100644 (file)
index 0000000..57ecff5
--- /dev/null
@@ -0,0 +1,203 @@
+<!doctype html public "-//w3c//dtd html 4.0 transitional//en">
+<html>
+<head>
+   <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
+   <meta name="GENERATOR" content="Mozilla/4.61 [en] (X11; I; Linux 2.2.11 i586) [Netscape]">
+</head>
+<body text="#000000" bgcolor="#FEFEDF" link="#0000EF" vlink="#51188E" alink="#FF0000">
+
+<h1>
+FORMS</h1>
+
+<hr WIDTH="100%">
+<p>This version (0.97) of PgAccess has changed the form API : variable
+handling, query results interface and control bindings naming convention.
+Please read it carefully, download the database demo and practice a while
+before trying to design your own forms.
+<p>For the moment, it has only some basic widgets : labels, entries, buttons
+, listboxes , checkboxes and radiobuttons.
+<p>Also there is a pseudo data control widget that allows you yo have access
+to a query results.
+<p><b>How do you generate widgets :</b>
+<ol>
+<li>
+select a widget from the toolbox by clicking the appropriate radiobutton</li>
+
+<li>
+move to the canvas , point with the mouse at the desired location and click
+the mouse button to begin</li>
+
+<li>
+keeping the mouse-button pressed move the mouse in order to draw a rectangle
+that will hold the widget</li>
+
+<li>
+release the mouse-button</li>
+</ol>
+In the rectangle that you have designed it will appear the selected object.
+<br>Move now to the attribute window to change some of its properties.
+<p>Renaming, resizing items are possible (for the moment) only by modifying
+appropriate parameters in attribute window. You <b>must </b>press Enter
+in the edit field after changing a value in order to be accepted.
+<p>You can also move items by dragging them or delete them by pressing
+Del key after selecting them.
+<p>In attribute window, there are some fields named <b><tt><font size=+1>Command
+</font></tt></b>and
+<b><tt><font size=+1>Variable</font></tt></b>.
+<p>The field <b><tt><font size=+1>Command </font></tt></b>have meaning
+only for Button widgets and holds the command that will be invoked when
+the button is pressed.
+<p>&nbsp;&nbsp;&nbsp; The field <b><tt><font size=+1>Variable </font></tt></b>have
+meaning only for EditField , Label widgets , checkboxes and radiobuttons
+and it is the name of the global variable that will hold the value for
+that widget. For checkboxes the values are <b>t</b> and <b>f</b> (from
+true and false) in order to simplify binding to logical data fields (PgAccess
+0.82 used 0 and 1).
+<p>&nbsp;&nbsp;&nbsp; For radiobuttons, it is usual to assign the same
+variable to the same radiobuttons within the same group. That variable
+will contain the name of the widget of the radiobutton that has been pressed.
+Let's presume that you have entered 3 radiobuttons named red, green and
+blue, all of them having the same variable named color. If you will press
+them, they will assign their names to global variable.
+<p>&nbsp;&nbsp;&nbsp; In order to make a simple test, put an entry field
+and set it's variable to <b>v1</b> and a button who's command is "set v1
+whisky". Press the button "Test form" and click on the button. In that
+entry should appear whisky.
+<br>Another test is defining in Script module a script called "My first
+script" having the following commands:
+<br><tt><font size=+1>tk_messageBox -title Warning -message "This is my
+first message!"</font></tt>
+<br>and then define a button who's command is <b><tt><font size=+1>execute_script
+"My first script"</font></tt></b>.
+<br>&nbsp;
+<h2>
+Database manipulation</h2>
+Let's presume that our form have the internal name <b><tt>mf </tt></b>(<b>m</b>y
+<b>f</b>orm). Don't forget that the Tk window names could not start with
+an uppercase letter.
+<br>The window will be referred inside the Tcl/Tk source as <b><tt>.mf</tt></b>
+<br>If you want to close the form in run-time you have to issue the command
+<b><tt>destroy
+.mf</tt></b>
+<p>Also, any widget created inside this window (form) will have the name
+prefixed by <b><tt>.mf ,</tt></b>so we will have <b><tt>.mf.button1</tt></b>
+or <b><tt>.mf.listbox1</tt></b> .
+<p>We can name the data control widget <b><tt>dc</tt></b> for example.
+The fully qualified name for that "virtual widget" will be <b><tt>.mf.dc</tt></b>
+then. A new namespace called <b><tt>DataControl(.mf.dc)</tt></b> will be
+automatically defined.
+<br>The <b><tt>Command </tt></b>property of the data control widget must
+contain the SQL command that will be executed.
+<br>When the form will be in run-time, automatically you will have access
+to the following procedures and functions from the namespace:
+<p><b><tt>open</tt></b> - opens the connection and execute the query (returns
+nothing)
+<br><b><tt>setSQL newsql</tt></b> - set the command query that will be
+executed at the next <b><tt>open</tt></b>
+<br><b><tt>getRowCount</tt></b> - returns the number of records of the
+result set
+<br><b><tt>getRowIndex </tt></b>- returns the current record number inside
+the result set
+<br><b><tt>getFieldList</tt></b> - returns a Tcl list containing the fields
+names from the current result set
+<br><b><tt>moveFirst</tt></b> - move the cursor to the first record in
+the recordset
+<br><b><tt>moveLast</tt></b><tt> , <b>moveNext</b> , <b>movePrevious</b></tt>-
+moves the cursor there
+<br><b><tt>moveTo newrecno</tt></b> - move the cursor to that new record
+number (first is 0)
+<br><b><tt>updateDataSet</tt></b> - update the variables inside the designed
+form that have a particular name (I'll explain later)
+<br><b><tt>clearDataSet</tt></b> - clear the associated DataSet variables
+<br><tt><b>fill listbox field</b> </tt>- fill the named listbox (whole
+widget name as <b><tt>.mf.listbox1</tt></b>) with the all the values of
+that field from the current result set
+<br><b><tt>close</tt></b> - close the result set (<b><font color="#FF0000">if
+you don't close it, you will loose some memory</font></b>)
+<p>These procedures and functions should be called in the normal Tcl namespace
+mode as in the following example:
+<p><tt>DataControl(.mf.dc)::setSQL "select * from phonebook"</tt>
+<br><tt>DataControl(.mf.dc)::open</tt>
+<br><tt>set nrecs [DataControl(.mf.dc)::getRowCount]</tt>
+<p>If you complaint about writting to many DataControl(...) you can include
+many commands into a single namespace eval as in the following example
+:
+<p><tt>namespace eval DataControl(.mf.dc) {</tt>
+<br><tt>&nbsp;&nbsp;&nbsp; setSQL "select * from phonebook"</tt>
+<br><tt>&nbsp;&nbsp;&nbsp; open</tt>
+<br><tt>&nbsp;&nbsp;&nbsp; set nrecs [getRowCount]</tt>
+<br><tt>&nbsp;&nbsp;&nbsp; moveLast</tt>
+<br><tt>&nbsp;&nbsp;&nbsp; updateDataSet</tt>
+<br><tt>}</tt>
+<p>It's no need to close a query-result set if you want to assign it a
+new SQL command and open it again. That will be done automatically releasing
+the memory used for the last result set.
+<br>Opening a new <b>DataControl</b> will automatically position the current
+row index of the result set on the first row (index 0) and will define
+a new global associative array named <b>DataSet</b> that will hold data
+from the current row. The key into that array will be the fully qualified
+name of the data control widget followed by a comma and the name of every
+field in the selected rows.
+<p><i>Example:</i>
+<br><tt>DataSet(.mf.dc,name)</tt>
+<br><tt>DataSet(.mf.dc,city)</tt>
+<p>If you want to bound some controls to the fields of the recordset, you
+will have to name their associate variable like that :
+<p><b><tt>DataSet(.mf.dc,salary)</tt></b> to get the "salary" field , or
+<b><tt>DataSet(.mf.dc,name)</tt></b> to get the "name" field. Using the
+data control procedures <b><tt>DataControl(.mf.dc)::moveNext</tt></b> or
+movePrevious will automatically update the <b><tt>DataSet(.mf.dc,...)</tt></b>
+array so the database information from entries in the form will be refreshed.
+<br>&nbsp;
+<p>Here it is a dumped <b><a href="formdemo.sql">sample database</a></b>
+that contains a demo database. What should you do ?
+<br>Shift-click the above URL in order to download that tiny file (4 Kb).
+Create a empty database and <b><tt>psql yourdatabase &lt;formdemo.sql</tt></b>
+<p>You should find a single table called "phonebook" a form called "Phone
+book" and another "A simple demo form".
+<p>First of all enter and view the phonebook table in table view. Note
+the fields and their values.
+<br>Open the "Phone book" form and enter a letter (a, e or i) in the field
+to the left of "Find" button then press Find. It's fine to enter one letter
+in order to get more records in query result. You will get information
+about the number of records selected, in the listbox you will see all the
+values of field "name" from the current data set. Use buttons to move to
+first, next, previous or last record within the record set.
+<p>In order to add a new record, press the "New" button in order to get
+new, clean entries. Fill them with your data and press "Add new" button.
+A new phonebook record will be added. Also, if you want to update a record,
+change it's values in the displayed fields after finding it and press "Update"
+button. The values will be updated in the database BUT NOT IN THE CURRENT
+QUERY RESULT . If you want to see them modified, make a new query trying
+to find it again.
+<p><font color="#000080">Before using the results from a query you should
+know that the information that has been retrieved could be found only in
+your computer client memory. It has <b>no live connection</b> to the data
+from the database. That's why it isn't possible to develop a simple update
+function as interface to that query-result widget. More than that : a query
+result could be obtained from a SQL command that return a non-updatable
+data set !!! For example fields gathered from multiple tables or summary
+fields. It isn't just simple to make an automatic update procedure. The
+programmer must know how to make the update or the append procedure, sometimes
+using key fields to point to the desired record or an OID. There are examples
+in the demo database in "Phone book" form. It may be possible that in the
+future, I will develop another pseudo-widget describing a table. It would
+be more simple than to implement an update or append or even a delete procedure.</font>
+<p>There is in the demo database also another simple form called "A simple
+demo form". It will show you how to handle variables from checkboxes, radiobuttons,
+how to use listboxes, open another forms and so on. I think they will help
+you.
+<p>In order to avoid naming user defined forms with&nbsp; a particular
+name of another PgAccess form, I would recommend naming them as udf0, udf1
+(user defined form 0 , 1 )
+<p>
+<hr WIDTH="25%">
+<p>Please feel free to send me your opinion at <b>teo@flex.ro</b> on forms
+designing and usage.
+<p><b><font size=+1>KEEP IN MIND !&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
+THE FORM API MAY CHANGE IN ORDER TO BE MORE SIMPLE AND BETTER!</font></b>
+<br><b><font size=+1>SEND ME YOUR WISHES, YOUR IDEAS, YOUR OPINIONS !</font></b>
+<br><b><font size=+1>ALSO ... DON'T BLAME ME IF YOU WILL HAVE TO RE-DESIGN
+YOUR OLD FORMS DUE TO SOME INCOMPATIBILITIES WITH NEWER PGACCESS VERSIONS.</font></b>
+</body>
+</html>
diff --git a/src/bin/pgaccess/doc/html/function.gif b/src/bin/pgaccess/doc/html/function.gif
new file mode 100644 (file)
index 0000000..51634e5
Binary files /dev/null and b/src/bin/pgaccess/doc/html/function.gif differ
diff --git a/src/bin/pgaccess/doc/html/help.gif b/src/bin/pgaccess/doc/html/help.gif
new file mode 100644 (file)
index 0000000..f08fee8
Binary files /dev/null and b/src/bin/pgaccess/doc/html/help.gif differ
diff --git a/src/bin/pgaccess/doc/html/index.html b/src/bin/pgaccess/doc/html/index.html
new file mode 100644 (file)
index 0000000..7ccda19
--- /dev/null
@@ -0,0 +1,11 @@
+<HTML>
+<HEAD>
+<TITLE>PgAccess</TITLE>
+
+<FRAMESET COLS="200,*" border=0 framespacing=0 frameborder=no>
+       <FRAME NAME="left" scrolling="none" src="contents.html">
+       <FRAME NAME="right" scrolling="nonw" src="main.html">
+</FRAMESET>
+
+</HTML>
+
diff --git a/src/bin/pgaccess/doc/html/irix.html b/src/bin/pgaccess/doc/html/irix.html
new file mode 100644 (file)
index 0000000..b678458
--- /dev/null
@@ -0,0 +1,133 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2//EN">
+<HTML>
+<HEAD>
+   <TITLE>PgAccess on Irix</TITLE>
+   <META NAME="GENERATOR" CONTENT="Mozilla/3.04Gold (X11; I; Linux 2.0.33 i586) [Netscape]">
+</HEAD>
+<BODY TEXT="#000000" BGCOLOR="#FFFFFF" LINK="#0000EF" VLINK="#51188E" ALINK="#FF0000">
+
+<H1>INSTALLING PgAccess UNDER IRIX 5.3.
+<HR WIDTH="100%"></H1>
+
+<P><B><FONT COLOR="#000080">This HOWO-TO make PgAccess working under Irix
+is written by Stuart Rison</FONT></B></P>
+
+<P>These are the steps that I had to follow to get pgaccess to run on an
+INDIGO2 running postgreSQL 6.3.2 under IRIX 5.3. I make no guarantee whatsoever
+that the same step will work for others but at least it should point you
+in the right direction. Also, I am a biologist by training so I only got
+pgaccess working by fudging (that is, trial and error) this means that
+some of the steps may be unnecessary (e.g. compiling $postgreSQL_source/src/interfaces/libpgtcl
+as both a shared and static library) and they certainly haven't been optimised
+(I know nothing about compiler switches etc.).</P>
+
+<P><B>1) Requirements:</B></P>
+
+<UL>
+<P>You will need:</P>
+
+<UL>
+<LI>postgreSQL source (http://www.postgresql.org)</LI>
+
+<LI>tcl8.0 source (http://www.tclconsortium.org/)</LI>
+
+<LI>tk8.0 source (http://www.tclconsortium.org/)</LI>
+
+<LI>pgaccess source (http://www.flex.ro/pgaccess)</LI>
+</UL>
+</UL>
+
+<P><B>2) Installation:</B></P>
+
+<P>a) tcl/tk:</P>
+
+<UL>
+<P>You must first install tcl and then tk (in that order). I just used
+./configure, no switches and gmake. Their installation should be trouble
+free. Then you must move headers and libraries to the right places so:</P>
+
+<P>Header files: both tcl and tk have a header file (tcl.h and tk.h). The
+tcl.h file is in $tcl_source_dir/generic and the tk.h file is in $tk_source_dir/generic;
+both should be copied to /usr/local/include.</P>
+
+<P>Libraries: compilation (with cc) of tcl and tk yield libraries libtcl8.0.a
+and libtk8.0.a in $source_dir/unix. Both should be copied to /usr/local/lib.</P>
+</UL>
+
+<P>b) postgreSQL:</P>
+
+<UL>
+<P>Make sure you have a fully patched postgreSQL source. If your ./configure
+says it can't load 'IRIX' settings then you most probably will need to
+patch ./configure.</P>
+
+<P>Configure using ./configure with the following switches: ./configure
+--with-includes=/usr/local/include</P>
+
+<P>--with-libraries=/usr/local/lib --with-tcl [this and previous line as
+one]</P>
+
+<P>Then make, make install as usual</P>
+</UL>
+
+<P>c) Compiling libpgtcl:</P>
+
+<UL>
+<P>The source for libpgtcl is in $postgreSQL_directory/src/interfaces/libpgsql.</P>
+
+<P>I do this twice. Once with just gmake. This produces a static library
+libpgtcl.a which I leave where it is (I don't know what to do with it but
+it may just come in handy). The I modify Makefile manually with a text
+editor. Essentially I modify two line:</P>
+
+<P>before:</P>
+
+<P># Shared library stuff</P>
+
+<P>install-shlib-dep := shlib :=</P>
+
+<P>after:</P>
+
+<P># Shared library stuff</P>
+
+<P>install-shlib-dep := install-shlib shlib := libpgtcl.so.1</P>
+
+<P>Then gmake -f Makefile_modified. This creates two shared (.so) libraries:
+libpgtcl.so and libpgtcl.so.1. I can't tell the difference between them
+so I copied them both to /usr/lib/.</P>
+</UL>
+
+<P>d) running pgaccess:</P>
+
+<UL>
+<P>Uncompress pgaccess (usually with gunzip and tar). So long as 'wish'
+(a binary produced when compiling tk8.0) is somewhere in your path, you
+should be able to run pgaccess with:</P>
+
+<P>wish -f $pgaccess_dir/pgaccess.tcl [postgreSQL_database_name]</P>
+</UL>
+
+<P>e) et voila!</P>
+
+<P><B>3) Concluding remarks:</B></P>
+
+<UL>
+<P>As I stated at the start of this document, following the procedure indicated
+above worked for me. I am sure, however, that a few of the steps are unnecessary/non-optimised/stupid
+etc. If any Unix (IRIX) boffin is reading this and you spot anything you
+would like to comment/correct etc. please e-mail me (stuart@ludwig.ucl.ac.uk).
+Also, if you just have questions and think I might help, please contact
+me at the same e-mail.</P>
+
+<P>Finally, I can accept no responsibility if these steps don't work for
+you or if it all goes horribly wrong and you 'damage' your computer trying
+them. Let common sense prevail!</P>
+</UL>
+
+<P>Good luck</P>
+
+<P>Stuart Rison LICR University College London London W1P 8BT<BR>
+<A HREF="mailto:stuart@ludwig.ucl.ac.uk">stuart@ludwig.ucl.ac.uk</A></P>
+
+</BODY>
+</HTML>
diff --git a/src/bin/pgaccess/doc/html/linux1.gif b/src/bin/pgaccess/doc/html/linux1.gif
new file mode 100644 (file)
index 0000000..b98ac02
Binary files /dev/null and b/src/bin/pgaccess/doc/html/linux1.gif differ
diff --git a/src/bin/pgaccess/doc/html/maillist.html b/src/bin/pgaccess/doc/html/maillist.html
new file mode 100644 (file)
index 0000000..4e0ce85
--- /dev/null
@@ -0,0 +1,43 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2//EN">
+<HTML>
+<HEAD>
+   <TITLE></TITLE>
+   <META NAME="GENERATOR" CONTENT="Mozilla/3.04Gold (X11; I; Linux 2.0.32 i586) [Netscape]">
+</HEAD>
+<BODY TEXT="#000000" BGCOLOR="#FFFFFF" LINK="#0000EF" VLINK="#51188E" ALINK="#FF0000">
+
+<P>The mailing list for PgAccess is : &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<B><TT>pgsql-interfaces@postgresql.org</TT></B></P>
+
+<P>If you have some questions regarding PgAccess you should mail to this
+address. I will also answer to messages addresed directly to me but it
+would be better to post your messages here because it might be possible
+to get an answer quickly from another user of PgAccess.</P>
+
+<P>
+<HR WIDTH="100%"></P>
+
+<P>To subscribe please send a mail message to&nbsp;:</P>
+
+<P>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<B><TT><FONT SIZE=+1>pgsql-interfaces-request@postgresql.org
+</FONT></TT></B>&nbsp;</P>
+
+<P>having a single line in the body message :&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<B><TT><FONT SIZE=+1>subscribe</FONT></TT></B></P>
+
+<P>In a couple of minutes , if everything is ok, you must receive something
+like that :</P>
+
+<P>
+<HR WIDTH="100%"></P>
+
+<P><TT>Welcome to the pgsql-interfaces mailing list!</TT></P>
+
+<P><TT>Please save this message for future reference. Thank you.</TT></P>
+
+<P><TT>If you ever want to remove yourself from this mailing list, you
+can send mail to &lt;Majordomo@hub.org&gt; with the following command in
+the body of your email message:</TT></P>
+
+<P><TT>unsubscribe pgsql-interfaces yourname@yourdomain</TT></P>
+<TT></TT>
+</BODY>
+</HTML>
diff --git a/src/bin/pgaccess/doc/html/main.html b/src/bin/pgaccess/doc/html/main.html
new file mode 100644 (file)
index 0000000..2bddfd6
--- /dev/null
@@ -0,0 +1,34 @@
+<!doctype html public "-//w3c//dtd html 4.0 transitional//en">
+<html>
+<head>
+   <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
+   <meta name="GENERATOR" content="Mozilla/4.61 [en] (X11; I; Linux 2.2.12 i586) [Netscape]">
+</head>
+<body bgcolor="#FEFEDF">
+
+<h1>
+PgAccess
+<hr WIDTH="100%"></h1>
+A free graphical database management tool for <a href="http://www.postgresql.org">PostgreSQL</a>.
+PgAccess has been written by <a href="mailto:teo@flex.ro">Constantin Teodorescu</a>
+using Visual Tcl, the best tool for developing Tcl/Tk applications I've
+ever seen.
+<p><b>Last version</b>
+<br>Last stable version is 0.98 , released on 29 August 1999. Read <a href="whatsnew.html">what's
+new</a> in 0.98.
+<p><b>Portability issues</b>
+<br>PgAccess is available for every platform where PostgreSQL was ported
+and where a Tcl/Tk package is available. PgAccess has been reported running
+on :
+<br>- Linux
+<br>- FreeBSD
+<br>- Solaris
+<br>- HPUX
+<br>- Irix
+<br>- Windows 95,98,NT
+<p>PgAccess needs Tcl/Tk versions 8.0.x and higher thought PgAccess. For
+win32 platforms there are some special DLL's that have to be downloaded
+and installed, more information <a href="win32.html">here</a>.
+<p>PgAccess is protected by the following <a href="copyright.html">copyright</a>.
+</body>
+</html>
diff --git a/src/bin/pgaccess/doc/html/mainwindow.gif b/src/bin/pgaccess/doc/html/mainwindow.gif
new file mode 100644 (file)
index 0000000..6a48792
Binary files /dev/null and b/src/bin/pgaccess/doc/html/mainwindow.gif differ
diff --git a/src/bin/pgaccess/doc/html/newtable.gif b/src/bin/pgaccess/doc/html/newtable.gif
new file mode 100644 (file)
index 0000000..891d056
Binary files /dev/null and b/src/bin/pgaccess/doc/html/newtable.gif differ
diff --git a/src/bin/pgaccess/doc/html/newuser.gif b/src/bin/pgaccess/doc/html/newuser.gif
new file mode 100644 (file)
index 0000000..5c56c9a
Binary files /dev/null and b/src/bin/pgaccess/doc/html/newuser.gif differ
diff --git a/src/bin/pgaccess/doc/html/old_index.html b/src/bin/pgaccess/doc/html/old_index.html
new file mode 100644 (file)
index 0000000..4bbf11f
--- /dev/null
@@ -0,0 +1,143 @@
+<!doctype html public "-//w3c//dtd html 4.0 transitional//en">
+<html>
+<head>
+   <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
+   <meta name="GENERATOR" content="Mozilla/4.61 [en] (X11; I; Linux 2.2.11 i586) [Netscape]">
+   <title>PgAccess - a Tcl/Tk PostgreSQL interface</title>
+</head>
+<body bgcolor="#FFFFFF">
+
+<h1>
+PgAccess - a free database management tool for <a href="http://www.postgreSQL.org">PostgreSQL</a></h1>
+
+<hr>
+<li>
+Download the last version of PgAccess <a href="pgaccess-0.96.tar.gz">(press
+shift and click this link) (tar.gz file)</a>&nbsp; or&nbsp;&nbsp; <a href="pgaccess.zip">this
+one (zip file for Windows)</a></li>
+
+<center>
+<p><br>Latest stable version of PgAccess is 0.97 , released 16 August 1999
+!
+<p><font size=+2>PgAccess 0.93 and higher will not work from the beginning
+with PostgreSQL 6.3.x !!</font>
+<br><font size=+2>Read <a href="pg93patch.html">here</a> how to apply a
+simple patch in order to make it work !</font></center>
+<b><font color="#000000"><font size=+2></font></font></b>
+<center><table BORDER=2 NOSAVE >
+<tr NOSAVE>
+<td NOSAVE><b><font color="#FF0000"><font size=+2>NEW</font></font></b></td>
+
+<td NOSAVE><b><font color="#000000"><font size=+2>International version
+(english, french, italian, romanian)</font></font></b></td>
+</tr>
+
+<tr NOSAVE>
+<td NOSAVE><b><font color="#FF0000"><font size=+2>NEW</font></font></b></td>
+
+<td><b><font size=+2>Context sensitive Help</font></b></td>
+</tr>
+</table></center>
+
+<center>
+<p>Precompiled libpgtcl and libpq binaries and dll's for i386 are <a href="ftp://ftp.flex.ro/pub/pgaccess">here
+</a>!!!</center>
+
+<h3>
+<font color="#000080">Installation problems</font></h3>
+
+<ul>
+<li>
+Some problems related with locale special characters could be solved by
+this <a href="specialchars.html">simple patch</a></li>
+
+<li>
+I think that there were some problems loading libpgtcl library. I invite
+you to read a <a href="index.html#libpgtcl">special section concerning
+libpgtcl</a></li>
+
+<li>
+For Silicon Graphics Indigo computers, Irix operating system, there is
+a <a href="irix.html">HOWTO make PgAccess to work</a></li>
+</ul>
+
+<h3>
+<font color="#191970">What does PgAccess now!</font></h3>
+Here are some screenshots from PgAccess windows : <a href="pic-pga-1.gif">Main
+window </a>, <a href="pic-pga-2.gif">table builder </a>, <a href="pic-pga-4.gif">table(query)
+view </a>, <a href="pic-pga-3.gif">visual query builder </a>.
+<p><b>Tables</b>
+<br>- opening multiple tables for viewing, max. n records (changed by preferences
+menu)
+<br>- column resizing, dragging the vertical grid line (better in table
+space rather than in the table header)
+<br>- text wrap in cells - layout saved for every table
+<br>- import/export to external files (SDF,CSV)
+<br>- filter capabilities (enter filter like (price>3.14)
+<br>- sort order capabilities (enter manually the sort field(s))
+<br>- editing in place
+<br>- improved table generator assistant
+<br>- improved field editing
+<br><b>Queries</b>
+<br>- define , edit and stores "user defined queries"
+<br>- store queries as views
+<br>- execution of queries with optional user input parameters ( select
+* from invoices where year=[parameter "Year of selection"] )
+<br>- viewing of select type queries result
+<br>- query deleting and renaming
+<br>- visual query builder with drag &amp; drop capabilities. For any of
+you who had installed the Tcl/Tk plugin for Netscape Navigator, you can
+see it at work <a href="qbtclet.html">clicking here</a>
+<br><b>Sequences</b>
+<br>- defines sequences, delete them and inspect them
+<br><b>Functions</b>
+<br>- define, inspect and delete functions in SQL, plpgsql and pgtcl languages
+<br><b>Reports</b>
+<br>- design and display simple reports from tables
+<br>- fields and labels, font changing, style and size
+<br>- saves and loads report description from database
+<br>- show report previews, sample postscript output file
+<br><b>Forms</b>
+<br>- open user defined forms
+<br>- form design module available
+<br>- query widget available, controls bound to query results
+<br>- <a href="forms.html">click here</a> for a description of forms and
+how they can be used
+<br><b>Scripts</b>
+<br>- define, modify and call user defined scripts
+<br><b>Users</b>
+<br>- define and modify user information
+<p>Here is <a href="pga-rad.html">a special section concerning forms and
+scripts</a> .
+<p>This program is protected by the following <a href="copyright.html">copyright</a>
+<p>If you have any comment, suggestion for improvements, please feel free
+to e-mail to : <a href="mailto:teo@flex.ro">teo@flex.ro</a>
+<p><b><font color="#FF1493"><font size=+2>Mailing list for PgAccess </font></font></b><a href="maillist.html">Here
+you will find how to subscribe to this mailing list</a>.
+<p>
+<hr>
+<h1>
+More information about libpgtcl - downloads</h1>
+&nbsp;&nbsp;&nbsp;&nbsp; Also, you will need the PostgreSQL to Tcl interface
+library, lined as a Tcl/Tk 'load'-able module. It is called libpgtcl and
+the source is located in the PostgreSQL directory /src/interfaces/libpgtcl.
+Specifically, you will need a libpgtcl library that is 'load'-able from
+Tcl/Tk.&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; This is technically different from
+an ordinary PostgreSQL loadable object file, because libpgtcl is a collection
+of object files. Under Linux, this is called libpgtcl.so.
+<p>&nbsp;&nbsp;&nbsp;&nbsp; One of the solutions is to remove from the
+source the line containing <b>load libpgtcl.so </b>and to load pgaccess.tcl
+not with wish, but with pgwish (or wishpg) that wish that was linked with
+libpgtcl library! I do not recommend this one.
+<p>&nbsp;&nbsp;&nbsp;&nbsp; If you have installed RedHat 5.x, you should
+get the last distribution kit of PostgreSQL and compile it from scratch.
+RedHat 5.x is using some new versions of libraries and you have to compile
+and install again at least <b>libpq </b>and <b><tt>libpgtcl </tt></b>libraries.
+<p>&nbsp;&nbsp;&nbsp; PostgreSQL 6.4 release has a minor bug. I does not
+include by default the crypt lib when compiling libpgtcl. So, you will
+need to manually add a -lcrypt to SHLIB line in Makefile in src/interfaces/libpgtcl
+and then make clean and make again. The new libpgtcl.so library is properly
+configured to run pgaccess.
+<br>&nbsp;
+</body>
+</html>
diff --git a/src/bin/pgaccess/doc/html/permissions.gif b/src/bin/pgaccess/doc/html/permissions.gif
new file mode 100644 (file)
index 0000000..06c4349
Binary files /dev/null and b/src/bin/pgaccess/doc/html/permissions.gif differ
diff --git a/src/bin/pgaccess/doc/html/pg93patch.html b/src/bin/pgaccess/doc/html/pg93patch.html
new file mode 100644 (file)
index 0000000..4c77bfa
--- /dev/null
@@ -0,0 +1,25 @@
+<!doctype html public "-//w3c//dtd html 4.0 transitional//en">
+<html>
+<head>
+   <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
+   <meta name="GENERATOR" content="Mozilla/4.5 [en] (X11; I; Linux 2.0.36 i586) [Netscape]">
+</head>
+<body text="#000000" bgcolor="#FFFFFF" link="#0000FF" vlink="#FF0000" alink="#000088">
+
+<h1>
+PgAccess 0.93 patch to make it work with PostgreSQL 6.3.x
+<hr WIDTH="100%"></h1>
+
+<p><br>PgAccess 0.93 is working fine with PostgreSQL 6.4.x due to some
+changes in libpgtcl !
+<p>There is a small patch that you have to make in order to make it work
+with 6.3.x !
+<p>Replace in procedure <tt>wpg_exec</tt> the following line:
+<p><tt>set pgsql(errmsg) [pg_result $pgsql(res) -error]</tt>
+<p>with this one :
+<p><tt>set pgsql(errmsg) "NO ERROR INFORMATION SUPPLIED"</tt>
+<p>And it will work fine! In some error cases, you will not get the appropriate
+error message from libpgtcl.
+<p>&nbsp;<a href="index.html">Back</a>
+</body>
+</html>
diff --git a/src/bin/pgaccess/doc/html/pga-rad.html b/src/bin/pgaccess/doc/html/pga-rad.html
new file mode 100644 (file)
index 0000000..7564cf7
--- /dev/null
@@ -0,0 +1,65 @@
+<HTML>
+<HEAD>
+   <META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=iso-8859-1">
+   <META NAME="GENERATOR" CONTENT="Mozilla/4.04 [en] (X11; I; Linux 2.0.32 i586) [Netscape]">
+</HEAD>
+<BODY TEXT="#000000" BGCOLOR="#FFFFFF" LINK="#0000EF" VLINK="#51188E" ALINK="#FF0000">
+
+<H1>
+PgAccess - Scripts and Forms&nbsp;
+<HR WIDTH="100%"></H1>
+Beginning with 0.70 version, I have introduced in PgAccess two new modules
+for operating with scripts and forms.
+
+<P>&nbsp;&nbsp; This would give to PgAccess the power of creating application
+directly into PgAccess, defining new modules, procedures, forms and possibly
+making it a rapid development tool for PostgreSQL. The "scripts" and "forms"
+modules are using two new tables called pga_forms and pga_scripts. PgAccess
+take care of creating them if user is opening a new database and grant
+ALL permissions on them to PUBLIC.
+<BR>&nbsp;
+<BR>&nbsp;&nbsp; Of course, when Designing a script, a simple text editor
+is opened and text is saved as is in pga_scripts table. When "designing"
+a form, a "form editor" that would be very similar with "Visual Tcl" is
+invoked.
+
+<P>&nbsp;&nbsp; This mechanism and the extremely versatile scripting mode
+of Tcl/Tk would give PgAccess a great power for creating end user application
+using PostgreSQL. The most important thing is that the user could call
+procedures and functions that I have used for building up PgAccess !
+<H3>
+Forms</H3>
+&nbsp;&nbsp; Forms are used for creating windows and placing widgets inside
+it. When PgAccess interpret them, a new window appear, with buttons as
+defined that could call "user defined scripts", "user defined procedures"
+or "internal PgAccess procedures".
+<BR>&nbsp;&nbsp; Forms can hold all the widgets allowed in Tcl/Tk , buttons,
+check-boxes, radio-buttons, list-boxes, frames, canvases, etc. With these
+forms, you can control your application so PgAccess would become just a
+"shell", a startup point for you applications. See the&nbsp; <A HREF="forms.html">special
+section concerning forms.</A>
+<H3>
+Scripts</H3>
+&nbsp;&nbsp; Scripts are normal Tcl/Tk code that is interpreted by Tcl/Tk.
+You can define your own procedures inside a script called "Library" for
+example. You can call your procedures from within another script, from
+another procedure.
+<BR>&nbsp;&nbsp; The most important thing is that you have total access
+to the PgAccess core of functions and procedures used by me in building
+PgAccess as an application. Just write <B><TT><FONT COLOR="#000080">open_table
+"Your sample table"</FONT></TT></B> and you'll see the result.
+<BR>&nbsp;&nbsp; If you are writing a script called "Autoexec" then it
+will be executed every time the database is opened. You can put inside
+different commands that you want to be executed such as : running scripts
+that would define your own procedures such as <B><TT><FONT COLOR="#000080">execute_script
+"My own procedure library"</FONT></TT></B> or open a form with <B><TT><FONT COLOR="#000080">open_form
+"Main window with menu buttons"</FONT></TT></B> , and so on.
+
+<P>
+<HR WIDTH="100%">
+<BR>Remember : I'm waiting your messages at <A HREF="mailto:teo@flex.ro">teo@flex.ro</A>
+
+<P>
+<HR WIDTH="50%">
+</BODY>
+</HTML>
diff --git a/src/bin/pgaccess/doc/html/qbtclet.html b/src/bin/pgaccess/doc/html/qbtclet.html
new file mode 100644 (file)
index 0000000..b990c0f
--- /dev/null
@@ -0,0 +1,45 @@
+<html>
+
+<title> Visual Query Builder in Tcl/Tk </title>
+<body bgcolor=white>
+<h1> Visual Query Builder</h1>
+<hr>
+This visual query builder is included in <a href='http://www.flex.ro/pgaccess'>
+PgAccess</a>, a visual interface to 
+<a href='http://www.postgreSQL.org'> PostgreSQL</a> written entirely in 
+vTcl , (Visual Tcl).
+
+
+<p align="center">
+
+<embed src="qbtclet.tcl"  width=590 height=485>
+
+</p>
+
+<br>
+
+
+Visual Query Designer demo<br>
+Click <a href='qbtclet.tar.gz'>here</a> to download the source </a>
+created by Constantin Teodorescu with vTcl (visual Tcl), teo@flex.ro
+<hr>
+Facitilies<br>
+ - drag and drop selection of fields<br>
+ - drag and drop fields from a table to another do create links<br>
+ - move table position by dragging<br>
+ - point and click any link or table then press delete to delete them<br>
+ - modify sort order by clicking on (unsorted)<br>
+ - enter filter conditions as criteria (>2000 , ='item')<br>
+ - easy panning of table and result panels<br>
+ - show SQL command<br>
+<br>
+If you want to use it for your database, modify ql_read_struct in order to read
+ your table structure.
+<br>
+Feel free to use, modify or copy this software for non-commercial purposes.<br>
+In any other case, please contact me.
+<br>
+FLEX Consulting Braila, ROMANIA is able to deliver high end interfaces 
+and any other commercial products written in Tcl/Tk just like that you have seen.
+</body>
+</html>
diff --git a/src/bin/pgaccess/doc/html/qbtclet.tcl b/src/bin/pgaccess/doc/html/qbtclet.tcl
new file mode 100644 (file)
index 0000000..9d086a3
--- /dev/null
@@ -0,0 +1,529 @@
+#################################
+# GLOBAL VARIABLES
+#
+global qlvar; 
+global widget; 
+
+#################################
+# USER DEFINED PROCEDURES
+#
+proc init {argc argv} {
+global qlvar
+set qlvar(yoffs) 360
+set qlvar(xoffs) 50
+set qlvar(reswidth) 150
+}
+
+init $argc $argv
+
+proc main {argc argv} {
+
+}
+
+proc show_message {usrmsg} {
+global msg
+set msg $usrmsg
+after 2000 {set msg {}}
+}
+
+proc ql_delete_object {} {
+global qlvar
+# Checking if there 
+set obj [.c find withtag hili]
+if {$obj==""} return
+if {[ql_get_tag_info $obj link]=="s"} {
+#    if {[tk_messageBox -title WARNING -icon question -message "Remove link ?" -type yesno -default no]=="no"} return
+       show_message "Deleting the link from tables ..."
+    set linkid [ql_get_tag_info $obj lkid]
+    set qlvar(links) [lreplace $qlvar(links) $linkid $linkid]
+    .c delete links
+    ql_draw_links
+} else {
+    set tablename [ql_get_tag_info $obj tab]
+    if {$tablename==""} return
+#    if {[tk_messageBox -title WARNING -icon question -message "Remove table $tablename from query ?" -type yesno -default no]=="no"} return
+       show_message "Deleting table from query ..."
+    for {set i [expr [llength $qlvar(restables)]-1]} {$i>=0} {incr i -1} {
+        if {$tablename==[lindex $qlvar(restables) $i]} {
+            set qlvar(resfields) [lreplace $qlvar(resfields) $i $i]
+            set qlvar(restables) [lreplace $qlvar(restables) $i $i]
+            set qlvar(rescriteria) [lreplace $qlvar(rescriteria) $i $i]
+        }
+    }
+    for {set i [expr [llength $qlvar(links)]-1]} {$i>=0} {incr i -1} {
+        set thelink [lindex $qlvar(links) $i]
+        if {($tablename==[lindex $thelink 0]) || ($tablename==[lindex $thelink 2])} {
+            set qlvar(links) [lreplace $qlvar(links) $i $i]
+        }
+    }
+    .c delete tab$tablename
+    .c delete links
+    ql_draw_links
+    ql_draw_res_panel
+}
+}
+
+proc ql_dragit {w x y} {
+global draginfo
+if {"$draginfo(obj)" != ""} {
+    set dx [expr $x - $draginfo(x)]
+    set dy [expr $y - $draginfo(y)]
+    if {$draginfo(is_a_table)} {
+        set taglist [.c gettags $draginfo(obj)]
+        set tabletag [lindex $taglist [lsearch -regexp $taglist "^tab"]]
+        $w move $tabletag $dx $dy
+        ql_draw_links
+    } else {
+        $w move $draginfo(obj) $dx $dy
+    }
+    set draginfo(x) $x
+    set draginfo(y) $y
+}
+}
+
+proc ql_dragstart {w x y} {
+global draginfo
+catch {unset draginfo}
+set draginfo(obj) [$w find closest $x $y]
+if {[ql_get_tag_info $draginfo(obj) r]=="ect"} {
+    # If it'a a rectangle, exit
+    set draginfo(obj) {}
+    return
+}
+. configure -cursor hand1
+.c raise $draginfo(obj)
+set draginfo(table) 0
+if {[ql_get_tag_info $draginfo(obj) table]=="header"} {
+    set draginfo(is_a_table) 1
+    .c itemconfigure [.c find withtag hili] -fill black
+    .c dtag [.c find withtag hili] hili
+    .c addtag hili withtag $draginfo(obj)
+    .c itemconfigure hili -fill blue
+} else {
+    set draginfo(is_a_table) 0
+}
+set draginfo(x) $x
+set draginfo(y) $y
+set draginfo(sx) $x
+set draginfo(sy) $y
+}
+
+proc ql_dragstop {x y} {
+global draginfo qlvar
+. configure -cursor top_left_arrow
+set este {}
+catch {set este $draginfo(obj)}
+if {$este==""} return
+# Re-establish the normal paint order so
+# information won't be overlapped by table rectangles
+# or link linkes
+.c lower $draginfo(obj)
+.c lower rect
+.c lower links
+set qlvar(panstarted) 0
+if {$draginfo(is_a_table)} {
+    set draginfo(obj) {}
+    .c delete links
+    ql_draw_links
+    return
+}
+.c move $draginfo(obj) [expr $draginfo(sx)-$x] [expr $draginfo(sy)-$y]
+if {($y>$qlvar(yoffs)) && ($x>$qlvar(xoffs))} {
+    # Drop position : inside the result panel
+    # Compute the offset of the result panel due to panning
+    set resoffset [expr [lindex [.c bbox resmarker] 0]-$qlvar(xoffs)]
+    set newfld [.c itemcget $draginfo(obj) -text]
+    set tabtag [ql_get_tag_info $draginfo(obj) tab]
+    set col [expr int(($x-$qlvar(xoffs)-$resoffset)/$qlvar(reswidth))]
+    set qlvar(resfields) [linsert $qlvar(resfields) $col $newfld]
+    set qlvar(ressort) [linsert $qlvar(ressort) $col unsorted]
+    set qlvar(rescriteria) [linsert $qlvar(rescriteria) $col {}]
+    set qlvar(restables) [linsert $qlvar(restables) $col $tabtag]
+    ql_draw_res_panel    
+} else {
+    # Drop position : in the table panel
+    set droptarget [.c find overlapping $x $y $x $y]
+    set targettable {}
+    foreach item $droptarget {
+        set targettable [ql_get_tag_info $item tab]
+        set targetfield [ql_get_tag_info $item f-]
+        if {($targettable!="") && ($targetfield!="")} {
+            set droptarget $item
+            break
+        }
+    }
+    # check if target object isn't a rectangle
+    if {[ql_get_tag_info $droptarget rec]=="t"} {set targettable {}}
+    if {$targettable!=""} {
+        # Target has a table
+        # See about originate table
+        set sourcetable [ql_get_tag_info $draginfo(obj) tab]
+        if {$sourcetable!=""} {
+            # Source has also a tab .. tag
+            set sourcefield [ql_get_tag_info $draginfo(obj) f-]
+            if {$sourcetable!=$targettable} {
+                lappend qlvar(links) [list $sourcetable $sourcefield $targettable $targetfield $draginfo(obj) $droptarget]
+                ql_draw_links
+            }
+        }
+    }
+}
+# Erase information about onbject beeing dragged
+set draginfo(obj) {}
+}
+
+proc ql_draw_links {} {
+global qlvar
+.c delete links
+set i 0
+foreach link $qlvar(links) {
+    # Compute the source and destination right edge
+    set sre [lindex [.c bbox tab[lindex $link 0]] 2]
+    set dre [lindex [.c bbox tab[lindex $link 2]] 2]
+    # Compute field bound boxes
+    set sbbox [.c bbox [lindex $link 4]]
+    set dbbox [.c bbox [lindex $link 5]]
+    # Compute the auxiliary lines
+    if {[lindex $sbbox 2] < [lindex $dbbox 0]} {
+        # Source object is on the left of target object
+        set x1 $sre
+        set y1 [expr ([lindex $sbbox 1]+[lindex $sbbox 3])/2]
+        .c create line $x1 $y1 [expr $x1+10] $y1 -tags [subst {links lkid$i}] -width 3
+        set x2 [lindex $dbbox 0]
+        set y2 [expr ([lindex $dbbox 1]+[lindex $dbbox 3])/2]
+        .c create line [expr $x2-10] $y2 $x2 $y2 -tags {links} -width 3
+        .c create line [expr $x1+10] $y1 [expr $x2-10] $y2 -tags [subst {links lkid$i}] -width 2
+    } else {
+        # source object is on the right of target object
+        set x1 [lindex $sbbox 0]
+        set y1 [expr ([lindex $sbbox 1]+[lindex $sbbox 3])/2]
+        .c create line $x1 $y1 [expr $x1-10] $y1 -tags [subst {links lkid$i}] -width 3
+        set x2 $dre
+        set y2 [expr ([lindex $dbbox 1]+[lindex $dbbox 3])/2]
+        .c create line $x2 $y2 [expr $x2+10] $y2 -width 3 -tags [subst {links lkid$i}]
+        .c create line [expr $x1-10] $y1 [expr $x2+10] $y2 -tags [subst {links lkid$i}] -width 2
+    }
+    incr i
+}
+.c lower links
+.c bind links <Button-1> {ql_link_click %x %y}
+}
+
+proc ql_draw_lizzard {} {
+global qlvar
+ql_read_struct
+.c delete all
+set posx 20
+for {set it 0} {$it<$qlvar(ntables)} {incr it} {
+    ql_draw_table $it
+#    set posy 10
+#    set tablename $qlvar(tablename$it)
+#    .c create text $posx $posy -text $tablename -anchor nw -tags [subst {tab$tablename f-oid mov tableheader}] -font -Adobe-Helvetica-Bold-R-Normal-*-*-120-*-*-*-*-*
+#    incr posy 16
+#    foreach fld $qlvar(tablestruct$it) {
+#        .c create text $posx $posy -text $fld -anchor nw -tags [subst {f-$fld tab$tablename mov}] -font -Adobe-Helvetica-Medium-R-Normal-*-*-120-*-*-*-*-*
+#        incr posy 14
+#    }
+#    set reg [.c bbox tab$tablename]
+#    .c create rectangle [lindex $reg 0] [lindex $reg 1] [lindex $reg 2] [lindex $reg 3] -fill #EEEEEE -tags [subst {rect tab$tablename}]
+#    .c create line [lindex $reg 0] [expr [lindex $reg 1]+15] [lindex $reg 2] [expr [lindex $reg 1]+15] -tags [subst {rect tab$tablename}]
+#    set posx [expr $posx+40+[lindex $reg 2]-[lindex $reg 0]]
+}
+.c lower rect
+.c create line 0 $qlvar(yoffs) 10000 $qlvar(yoffs) -width 3
+.c create rectangle 0 $qlvar(yoffs) 10000 5000 -fill #FFFFFF
+for {set i [expr 15+$qlvar(yoffs)]} {$i<500} {incr i 15} {
+    .c create line $qlvar(xoffs) $i 10000 $i -fill #CCCCCC -tags {resgrid}
+}    
+for {set i $qlvar(xoffs)} {$i<10000} {incr i $qlvar(reswidth)} {
+    .c create line $i [expr 1+$qlvar(yoffs)] $i 10000 -fill #cccccc -tags {resgrid}
+}
+# Make a marker for result panel offset calculations (due to panning)
+.c create line $qlvar(xoffs) $qlvar(yoffs) $qlvar(xoffs) 500 -tags {resmarker resgrid}
+.c create rectangle 0 $qlvar(yoffs) $qlvar(xoffs) 5000 -fill #EEEEEE -tags {reshdr}
+.c create text 5 [expr 1+$qlvar(yoffs)] -text Field: -anchor nw -font -Adobe-Helvetica-Medium-R-Normal-*-*-120-*-*-*-*-* -tags {reshdr}
+.c create text 5 [expr 16+$qlvar(yoffs)] -text Table: -anchor nw -font -Adobe-Helvetica-Medium-R-Normal-*-*-120-*-*-*-*-* -tags {reshdr}
+.c create text 5 [expr 31+$qlvar(yoffs)] -text Sort: -anchor nw -font -Adobe-Helvetica-Medium-R-Normal-*-*-120-*-*-*-*-* -tags {reshdr}
+.c create text 5 [expr 46+$qlvar(yoffs)] -text Criteria: -anchor nw -font -Adobe-Helvetica-Medium-R-Normal-*-*-120-*-*-*-*-* -tags {reshdr}
+.c bind mov <Button-1> {ql_dragstart %W %x %y}
+.c bind mov <B1-Motion> {ql_dragit %W %x %y}
+bind . <ButtonRelease-1> {ql_dragstop %x %y}
+bind . <Button-1> {qlc_click %x %y %W}
+bind . <B1-Motion> {ql_pan %x %y}
+bind . <Key-Delete> {ql_delete_object}
+set qlvar(resfields) {}
+set qlvar(ressort) {}
+set qlvar(rescriteria) {}
+set qlvar(restables) {}
+set qlvar(critedit) 0
+set qlvar(links) {}
+set qlvar(linktodelete) {}
+}
+
+proc ql_draw_res_panel {} {
+global qlvar
+# Compute the offset of the result panel due to panning
+set resoffset [expr [lindex [.c bbox resmarker] 0]-$qlvar(xoffs)]
+    .c delete resp
+    for {set i 0} {$i<[llength $qlvar(resfields)]} {incr i} {
+        .c create text [expr $resoffset+4+$qlvar(xoffs)+$i*$qlvar(reswidth)] [expr 1+$qlvar(yoffs)] -text [lindex $qlvar(resfields) $i] -anchor nw -fill navy -tags {resf resp} -font -Adobe-Helvetica-Medium-R-Normal-*-*-120-*-*-*-*-*
+        .c create text [expr $resoffset+4+$qlvar(xoffs)+$i*$qlvar(reswidth)] [expr 16+$qlvar(yoffs)] -text [lindex $qlvar(restables) $i] -anchor nw -tags {resp rest} -font -Adobe-Helvetica-Medium-R-Normal-*-*-120-*-*-*-*-*
+        .c create text [expr $resoffset+4+$qlvar(xoffs)+$i*$qlvar(reswidth)] [expr 31+$qlvar(yoffs)] -text [lindex $qlvar(ressort) $i] -anchor nw -tags {resp sort} -font -Adobe-Helvetica-Medium-R-Normal-*-*-120-*-*-*-*-*
+        if {[lindex $qlvar(rescriteria) $i]!=""} {
+            .c create text [expr $resoffset+4+$qlvar(xoffs)+$i*$qlvar(reswidth)]  [expr $qlvar(yoffs)+46+15*0] -anchor nw -text [lindex $qlvar(rescriteria) $i]  -font -Adobe-Helvetica-Medium-R-Normal-*-*-120-*-*-*-*-*  -tags [subst {resp cr-c$i-r0}]
+        }
+    }
+    .c raise reshdr
+    .c bind sort <Button-1> {ql_swap_sort %W %x %y}
+}
+
+proc ql_draw_table {it} {
+global qlvar
+
+set posy 10
+set allbox [.c bbox rect]
+if {$allbox==""} {set posx 10} else {set posx [expr 20+[lindex $allbox 2]]}
+set tablename $qlvar(tablename$it)
+.c create text $posx $posy -text $tablename -anchor nw -tags [subst {tab$tablename f-oid mov tableheader}] -font -Adobe-Helvetica-Bold-R-Normal-*-*-120-*-*-*-*-*
+incr posy 16
+foreach fld $qlvar(tablestruct$it) {
+   .c create text $posx $posy -text $fld -anchor nw -tags [subst {f-$fld tab$tablename mov}] -font -Adobe-Helvetica-Medium-R-Normal-*-*-120-*-*-*-*-*
+   incr posy 14
+}
+set reg [.c bbox tab$tablename]
+.c create rectangle [lindex $reg 0] [lindex $reg 1] [lindex $reg 2] [lindex $reg 3] -fill #EEEEEE -tags [subst {rect tab$tablename}]
+.c create line [lindex $reg 0] [expr [lindex $reg 1]+15] [lindex $reg 2] [expr [lindex $reg 1]+15] -tags [subst {rect tab$tablename}]
+}
+
+proc ql_get_tag_info {obj prefix} {
+set taglist [.c gettags $obj]
+set tagpos [lsearch -regexp $taglist "^$prefix"]
+if {$tagpos==-1} {return ""}
+set thattag [lindex $taglist $tagpos]
+return [string range $thattag [string length $prefix] end]
+}
+
+proc ql_link_click {x y} {
+global qlvar
+
+set obj [.c find closest $x $y 1 links]
+if {[ql_get_tag_info $obj link]!="s"} return
+.c itemconfigure [.c find withtag hili] -fill black
+.c dtag [.c find withtag hili] hili
+.c addtag hili withtag $obj
+.c itemconfigure $obj -fill blue
+}
+
+proc ql_pan {x y} {
+global qlvar
+set panstarted 0
+catch {set panstarted $qlvar(panstarted) }
+if {!$panstarted} return
+set dx [expr $x-$qlvar(panstartx)]
+set dy [expr $y-$qlvar(panstarty)]
+set qlvar(panstartx) $x
+set qlvar(panstarty) $y
+if {$qlvar(panobject)=="tables"} {
+    .c move mov $dx $dy
+    .c move links $dx $dy
+    .c move rect $dx $dy
+} else {
+    .c move resp $dx 0
+    .c move resgrid $dx 0
+    .c raise reshdr
+}
+}
+
+proc ql_read_struct {} {
+global qlvar
+
+set qlvar(ntables) 3
+set qlvar(tablename0) Facturi
+set qlvar(tablename1) Nommat
+set qlvar(tablename2) Incasari
+set qlvar(tablestruct0) [list factura client valoare tva]
+set qlvar(tablestruct1) [list cod denumire pret greutate procent_tva]
+set qlvar(tablestruct2) [list data valoare nrdoc referinta]
+}
+
+proc ql_show_sql {} {
+global qlvar
+
+set sqlcmd "select "
+for {set i 0} {$i<[llength $qlvar(resfields)]} {incr i} {
+    if {$sqlcmd!="select "} {set sqlcmd "$sqlcmd, "}
+    set sqlcmd "$sqlcmd[lindex $qlvar(restables) $i].[lindex $qlvar(resfields) $i]"
+}
+set tables {}
+for {set i 0} {$i<$qlvar(ntables)} {incr i} {
+    lappend tables $qlvar(tablename$i)    
+}
+set sqlcmd "$sqlcmd from [join $tables ,] "
+set sup1 {}
+if {[llength $qlvar(links)]>0} {
+    set sup1 "where "
+    foreach link $qlvar(links) {
+        if {$sup1!="where "} {set sup1 "$sup1 and "}
+        set sup1 "$sup1 ([lindex $link 0].[lindex $link 1]=[lindex $link 2].[lindex $link 3])"
+    }
+}
+for {set i 0} {$i<[llength $qlvar(resfields)]} {incr i} {
+    set crit [lindex $qlvar(rescriteria) $i]
+    if {$crit!=""} {
+        if {$sup1==""} {set sup1 "where "}
+        if {[string range $sup1 0 4]=="where"} {set sup1 "$sup1 and "}
+        set sup1 "$sup1 ([lindex $qlvar(restables) $i].[lindex $qlvar(resfields) $i]$crit) "        
+    }        
+}
+set sqlcmd "$sqlcmd $sup1"
+set sup2 {}
+for {set i 0} {$i<[llength $qlvar(ressort)]} {incr i} {
+    set how [lindex $qlvar(ressort) $i]
+    if {$how!="unsorted"} {
+        if {$how=="Ascending"} {set how asc} else {set how desc}
+        if {$sup2==""} {set sup2 " order by "} else {set sup2 "$sup2,"}
+        set sup2 "$sup2 [lindex $qlvar(resfields) $i] $how "
+    }
+}
+set sqlcmd "$sqlcmd $sup2"
+set qlvar(sql) $sqlcmd
+#tk_messageBox -message $sqlcmd
+.c delete sqlpage
+.c create rectangle 0 0 2000 [expr $qlvar(yoffs)-1] -fill #ffffff -tags {sqlpage}
+.c create text 10 10 -text $sqlcmd -anchor nw -width 550 -tags {sqlpage} -font -Adobe-Helvetica-Medium-R-Normal-*-*-120-*-*-*-*-*
+.c bind sqlpage <Button-1> {.c delete sqlpage}
+}
+
+proc ql_swap_sort {w x y} {
+global qlvar
+set obj [$w find closest $x $y]
+set taglist [.c gettags $obj]
+if {[lsearch $taglist sort]==-1} return
+set cum [.c itemcget $obj -text]
+if {$cum=="unsorted"} {
+    set cum Ascending
+} elseif {$cum=="Ascending"} {
+    set cum Descending
+} else {
+    set cum unsorted
+}
+set col [expr int(($x-$qlvar(xoffs))/$qlvar(reswidth))]
+set qlvar(ressort) [lreplace $qlvar(ressort) $col $col $cum]
+.c itemconfigure $obj -text $cum
+}
+
+proc qlc_click {x y w} {
+global qlvar
+set qlvar(panstarted) 0
+if {$w==".c"} {
+    set canpan 1
+    if {$y<$qlvar(yoffs)} {
+        if {[llength [.c find overlapping $x $y $x $y]]!=0} {set canpan 0}
+            set qlvar(panobject) tables
+    } else {
+        set qlvar(panobject) result
+    }
+    if {$canpan} {
+        . configure -cursor hand1
+        set qlvar(panstartx) $x
+        set qlvar(panstarty) $y
+        set qlvar(panstarted) 1
+    }
+}
+set isedit 0
+catch {set isedit $qlvar(critedit)}
+# Compute the offset of the result panel due to panning
+set resoffset [expr [lindex [.c bbox resmarker] 0]-$qlvar(xoffs)]
+if {$isedit} {
+    set qlvar(rescriteria) [lreplace $qlvar(rescriteria) $qlvar(critcol) $qlvar(critcol) $qlvar(critval)]
+    .c delete cr-c$qlvar(critcol)-r$qlvar(critrow)
+    .c create text [expr $resoffset+4+$qlvar(xoffs)+$qlvar(critcol)*$qlvar(reswidth)] [expr $qlvar(yoffs)+46+15*$qlvar(critrow)] -anchor nw -text $qlvar(critval) -font -Adobe-Helvetica-Medium-R-Normal-*-*-120-*-*-*-*-* -tags [subst {resp cr-c$qlvar(critcol)-r$qlvar(critrow)}]
+    set qlvar(critedit) 0
+}
+catch {destroy .entc}
+if {$y<[expr $qlvar(yoffs)+46]} return
+if {$x<[expr $qlvar(xoffs)+5]} return
+set col [expr int(($x-$qlvar(xoffs)-$resoffset)/$qlvar(reswidth))]
+if {$col>=[llength $qlvar(resfields)]} return
+set nx [expr $col*$qlvar(reswidth)+8+$qlvar(xoffs)+$resoffset]
+set ny [expr $qlvar(yoffs)+76]
+# Get the old criteria value
+set qlvar(critval) [lindex $qlvar(rescriteria) $col]
+entry .entc -textvar qlvar(critval) -borderwidth 0 -background #FFFFFF -highlightthickness 0 -selectborderwidth 0  -font -Adobe-Helvetica-Medium-R-Normal-*-*-120-*-*-*-*-*
+place .entc -x $nx -y $ny -height 14
+focus .entc
+bind .entc <Button-1> {set qlvar(panstarted) 0}
+set qlvar(critcol) $col
+set qlvar(critrow) 0
+set qlvar(critedit) 1
+}
+
+proc Window {args} {
+global vTcl
+    set cmd [lindex $args 0]
+    set name [lindex $args 1]
+    set newname [lindex $args 2]
+    set rest [lrange $args 3 end]
+    if {$name == "" || $cmd == ""} {return}
+    if {$newname == ""} {
+        set newname $name
+    }
+    set exists [winfo exists $newname]
+    switch $cmd {
+        show {
+            if {$exists == "1" && $name != "."} {wm deiconify $name; return}
+            if {[info procs vTclWindow(pre)$name] != ""} {
+                eval "vTclWindow(pre)$name $newname $rest"
+            }
+            if {[info procs vTclWindow$name] != ""} {
+                eval "vTclWindow$name $newname $rest"
+            }
+            if {[info procs vTclWindow(post)$name] != ""} {
+                eval "vTclWindow(post)$name $newname $rest"
+            }
+        }
+        hide    { if $exists {wm withdraw $newname; return} }
+        iconify { if $exists {wm iconify $newname; return} }
+        destroy { if $exists {destroy $newname; return} }
+    }
+}
+
+
+       set base ""
+    bind $base <B1-Motion> {
+        ql_pan %x %y
+    }
+    bind $base <Button-1> {
+        qlc_click %x %y %W
+    }
+    bind $base <ButtonRelease-1> {
+        ql_dragstop %x %y
+    }
+    bind $base <Key-Delete> {
+        ql_delete_object
+    }
+    canvas $base.c \
+        -background #fefefe -borderwidth 2 -height 207 -relief ridge \
+        -takefocus 0 -width 295 
+    label $base.msg -textvar msg -borderwidth 1 -relief sunken
+    button $base.b2 \
+        -borderwidth 1 -command ql_draw_lizzard \
+        -font -Adobe-Helvetica-Medium-R-Normal-*-*-120-*-*-*-*-* -padx 9 \
+        -pady 3 -text {Paint demo tables} 
+    button $base.showbtn \
+        -borderwidth 1 -command ql_show_sql \
+        -font -Adobe-Helvetica-Medium-R-Normal-*-*-120-*-*-*-*-* -padx 9 \
+        -pady 3 -text {Show SQL} 
+    ###################
+    # SETTING GEOMETRY
+    ###################
+    place $base.c \
+        -x 5 -y 30 -width 578 -height 425 -anchor nw -bordermode ignore 
+    place $base.b2 \
+        -x 5 -y 5 -height 26 -anchor nw -bordermode ignore 
+    place $base.showbtn \
+        -x 130 -y 5 -height 26 -anchor nw -bordermode ignore 
+       place $base.msg \
+               -x 5 -y 460 -width 578 -anchor nw
+
+main $argc $argv
diff --git a/src/bin/pgaccess/doc/html/screenshots.html b/src/bin/pgaccess/doc/html/screenshots.html
new file mode 100644 (file)
index 0000000..0cf3ac6
--- /dev/null
@@ -0,0 +1,43 @@
+<!doctype html public "-//w3c//dtd html 4.0 transitional//en">
+<html>
+<head>
+   <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
+   <meta name="GENERATOR" content="Mozilla/4.61 [en] (X11; I; Linux 2.2.12 i586) [Netscape]">
+</head>
+<body bgcolor="#FEFEDF">
+
+<h3>
+Image gallery
+<hr WIDTH="100%"></h3>
+
+<ul>
+<li>
+&nbsp;<a href="mainwindow.gif">Main window</a> 9 Kb</li>
+
+<li>
+&nbsp;<a href="newtable.gif">Creating a new table</a> 9 Kb</li>
+
+<li>
+&nbsp;<a href="permissions.gif">Table access control</a> 10 Kb</li>
+
+<li>
+&nbsp;<a href="addindex.gif">Adding a new index</a> 12 Kb</li>
+
+<li>
+&nbsp;<a href="vdesigner.gif">The visual query designer</a> 16 Kb</li>
+
+<li>
+&nbsp;<a href="function.gif">Working with functions</a> 10 Kb</li>
+
+<li>
+&nbsp;<a href="forms.gif">Form designer</a> 19 Kb</li>
+
+<li>
+&nbsp;<a href="newuser.gif">User management</a> 4 Kb</li>
+
+<li>
+&nbsp;<a href="help.gif">Help</a> 7 Kb</li>
+</ul>
+
+</body>
+</html>
diff --git a/src/bin/pgaccess/doc/html/specialchars.html b/src/bin/pgaccess/doc/html/specialchars.html
new file mode 100644 (file)
index 0000000..b6b82f2
--- /dev/null
@@ -0,0 +1,47 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2//EN">
+<HTML>
+<HEAD>
+   <TITLE>Special locale characters</TITLE>
+   <META NAME="GENERATOR" CONTENT="Mozilla/3.04Gold (X11; I; Linux 2.0.32 i586) [Netscape]">
+</HEAD>
+<BODY TEXT="#000000" BGCOLOR="#FFFFFF" LINK="#0000EF" VLINK="#51188E" ALINK="#FF0000">
+
+<H1>Special locale characters and PgAccess 
+<HR WIDTH="100%"></H1>
+
+<P>The problem is related with some special characters used in different
+countries because PgAccess did not use fonts with `-ISO8859-1' encoding
+-- </P>
+
+<P>The sollution was proposed by H.P.Heidinger ( hph@hphbbs.ruhr.de) and
+it's very simple.</P>
+
+<P>If you look into PgAccess, you will find fonts declared as follows :</P>
+
+<P><TT>$ grep -e '-font' -i pgaccess.tcl<BR>
+-font -Adobe-Helvetica-Medium-R-Normal--*-120-*-*-*-*-*-* \<BR>
+-font -Adobe-Helvetica-Medium-R-Normal--*-120-*-*-*-*-*-* \<BR>
+-font -Adobe-Helvetica-Medium-R-Normal--*-120-*-*-*-*-*-* \<BR>
+-font -Adobe-Helvetica-Medium-R-Normal--*-120-*-*-*-*-*-* \</TT></P>
+
+<P>It should be something like: -adobe-helvetica-medium-r-normal-*-*-120-*-*-*-*-iso8859-1</P>
+
+<P>You can achieve this by running the following script :</P>
+
+<P><TT>#!/bin/sh<BR>
+cp pgaccess.tcl pgaccess.tcl-org<BR>
+cat pgaccess.tcl |\<BR>
+sed -e's/\-\*\-\*\ /\-iso8859\-1\ /g' |\<BR>
+sed -e's/\-\*\-\*\}/\-iso8859\-1}/g' |\<BR>
+sed -e's/\-\*\-\*\]/\-iso8859\-1]/g' |\<BR>
+sed -e's/\-\*\-\*$/\-iso8859\-1/g' |\<BR>
+sed -e's/\-Clean\-/\-Fixed\-/g' |\<BR>
+sed -e's/clean/fixed/g' &gt;pgaccess.iso<BR>
+mv pgaccess.iso pgaccess.tcl<BR>
+chmod +x pgaccess.tcl</TT></P>
+
+<P>The final version of PgAccess (1.0) will let the user decide what fonts
+will be used through a &quot;preferences&quot; dialog window.</P>
+
+</BODY>
+</HTML>
diff --git a/src/bin/pgaccess/doc/html/todo.html b/src/bin/pgaccess/doc/html/todo.html
new file mode 100644 (file)
index 0000000..f19b61a
--- /dev/null
@@ -0,0 +1,11 @@
+<html>
+<body bgcolor="#FEFEDF">
+<h2>ToDo List</h2><hr>
+ - Finish the report generator module<br>
+ - Enhance the form designer<br>
+ - Enhance the scripts module<br>
+ - Translations in other languages<br>
+<br>
+Please send any suggestions by mail to <a href="mailto:teo@flex.ro">Constantin Teodorescu</a>. 
+</body>
+</html>
diff --git a/src/bin/pgaccess/doc/html/tutorial/addref.jpg b/src/bin/pgaccess/doc/html/tutorial/addref.jpg
new file mode 100644 (file)
index 0000000..ee0525d
Binary files /dev/null and b/src/bin/pgaccess/doc/html/tutorial/addref.jpg differ
diff --git a/src/bin/pgaccess/doc/html/tutorial/altern_q.jpg b/src/bin/pgaccess/doc/html/tutorial/altern_q.jpg
new file mode 100644 (file)
index 0000000..3fb02ae
Binary files /dev/null and b/src/bin/pgaccess/doc/html/tutorial/altern_q.jpg differ
diff --git a/src/bin/pgaccess/doc/html/tutorial/altern_v.jpg b/src/bin/pgaccess/doc/html/tutorial/altern_v.jpg
new file mode 100644 (file)
index 0000000..52cbbb0
Binary files /dev/null and b/src/bin/pgaccess/doc/html/tutorial/altern_v.jpg differ
diff --git a/src/bin/pgaccess/doc/html/tutorial/copyright.html b/src/bin/pgaccess/doc/html/tutorial/copyright.html
new file mode 100644 (file)
index 0000000..22eada2
Binary files /dev/null and b/src/bin/pgaccess/doc/html/tutorial/copyright.html differ
diff --git a/src/bin/pgaccess/doc/html/tutorial/index.html b/src/bin/pgaccess/doc/html/tutorial/index.html
new file mode 100644 (file)
index 0000000..a63f1a8
--- /dev/null
@@ -0,0 +1,33 @@
+<!doctype html public "-//w3c//dtd html 4.0 transitional//en">
+<html><head><title>PgAccess - a Tcl/Tk interface for PostgreSQL</title></head>
+<body bgcolor="#C0C0C0">
+<h1>PgAccess - a Tcl/Tk interface for PostgreSQL</h1>
+<hr>
+<a name="intro">
+<ul><li><a href="intro.html">Introduction</a>
+ <ul><li><a href="intro.html#whatpga">What is PgAccess?</a>
+  <li><a href="intro.html#helppga">How to get help with PgAccess</a>
+ </ul>
+<a name="start">
+ <li><a href="start.html">Getting Started</a>
+ <ul><li><a href="start.html#getpga">How to get PgAccess</a>
+  <li><a href="start.html#uncpga">How to uncompress PgAccess</a>
+  <li><a href="start.html#putpga">Putting PgAccess where it will be found</a>
+  <li><a href="start.html#startpga">Starting PgAccess</a>
+  <li><a href="irix.html">Installing PgAccess under IRIX 5.3</a>
+ </ul>
+<a name="problems">
+ <li><a href="problems.html">Common Initial Problems</a>
+ <ul><li><a href="problems.html#connfail">Connection failure</a>
+  <li><a href="problems.html#nonuser">User not defined</a>
+  <li><a href="problems.html#libpg">libpgtcl not found</a>
+  <li><a href="problems.html#spchar">Locale specific characters</a>
+  <li><a href="problems.html#pg63">Problems with PostgreSQL 6.3.x</a>
+ </ul>
+ <li><a href="tut.html">PgAccess tutorial</a>
+ <ul><li><a href="tut_user.html">User Administration</a>
+  <li><a href="tut_new.html">Creating a table</a>
+  <li><a href="tut_edit.html">Editing a table</a>
+  <li><a href="tut_sel1.html">Querying - SELECT</a>
+</ul>
+</body></html>
diff --git a/src/bin/pgaccess/doc/html/tutorial/intro.html b/src/bin/pgaccess/doc/html/tutorial/intro.html
new file mode 100644 (file)
index 0000000..2f05659
--- /dev/null
@@ -0,0 +1,39 @@
+<html><head><title>PgAccess - Introduction</title></head>
+<body bgcolor="#C0C0C0">
+<h1>PgAccess - Introduction</h1>
+<a name="whatpga"><h2>What is PgAccess?</h2> 
+PgAccess is a graphical user interface for the PostgreSQL database management
+system written in the Tcl/Tk scripting language by Constantin Teodorescu.  It 
+allows the user to interact with PostgreSQL in a manner similar to many PC 
+database applications, with menu choices and graphical tools like buttons.  
+This means that the user can avoid the basic command line interface for most 
+common tasks.  PgAccess doesn't change the way PostgreSQL operates, just makes 
+it easier to use for those familiar with graphical interfaces.<p>
+Obviously, you <u>must</u> have PostgreSQL installed and running, and Tcl/Tk on
+your system before you can use PgAccess.<p>
+PgAccess is an "open source" application.  The source code is available to the 
+user, and may be modified by the user.  The user can fix a bug, or change the 
+way a function operates.  You may not want to get that involved with the
+programming, but you have the option to do so.  If you feel you have made an
+improvement to the program, you are encouraged to share it with other users.<p>
+If you are not familiar with how open source software can be altered and
+redistributed, please read <a href="copyright.html">this</a>.<p>
+<a name="helppga"><h2>How to get help with PgAccess</h2>
+The mailing list for PgAccess is: <b>pgsql-interfaces@postgresql.org</b><p>
+If you have any questions regarding PgAccess you should subscribe to this
+list in the following way:<p>
+First subscribe to the list by sending an email message to:<p>
+<samp>pgsql-interfaces-request@postgresql.org</samp><p>
+Send a single line in the body of the message as follows:<p>
+<samp>subscribe</samp><p>
+In a short time you should receive a message beginning like this:<p>
+<samp>Welcome to the pgsql-interfaces mailing list!<br>
+...</samp><p>
+This will contain instructions on how to remove yourself from the mailing
+list, so save that message.  You may only want to ask a few questions and then
+stop receiving messages.<p>
+You may also email <a href="mailto:teo@flex.ro">Constantin Teodorescu</a>
+directly, although writing to a mailing list with many correspondents will often
+produce a quicker answer.<p>
+<a href="index.html#intro">Back to index</a>
+</body></html>
diff --git a/src/bin/pgaccess/doc/html/tutorial/irix.html b/src/bin/pgaccess/doc/html/tutorial/irix.html
new file mode 100644 (file)
index 0000000..7d472aa
--- /dev/null
@@ -0,0 +1,133 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2//EN">
+<HTML>
+<HEAD>
+   <TITLE>PgAccess on Irix</TITLE>
+   <META NAME="GENERATOR" CONTENT="Mozilla/3.04Gold (X11; I; Linux 2.0.33 i586) [Netscape]">
+</HEAD>
+<BODY TEXT="#000000" BGCOLOR="#FFFFFF" LINK="#0000EF" VLINK="#51188E" ALINK="#FF0000">
+
+<H1>INSTALLING PgAccess UNDER IRIX 5.3.
+<HR WIDTH="100%"></H1>
+
+<P><B><FONT COLOR="#000080">This HOWO-TO make PgAccess working under Irix
+is written by Stuart Rison</FONT></B></P>
+
+<P>These are the steps that I had to follow to get pgaccess to run on an
+INDIGO2 running postgreSQL 6.3.2 under IRIX 5.3. I make no guarantee whatsoever
+that the same step will work for others but at least it should point you
+in the right direction. Also, I am a biologist by training so I only got
+pgaccess working by fudging (that is, trial and error) this means that
+some of the steps may be unnecessary (e.g. compiling $postgreSQL_source/src/interfaces/libpgtcl
+as both a shared and static library) and they certainly haven't been optimised
+(I know nothing about compiler switches etc.).</P>
+
+<P><B>1) Requirements:</B></P>
+
+<UL>
+<P>You will need:</P>
+
+<UL>
+<LI>postgreSQL source (http://www.postgresql.org)</LI>
+
+<LI>tcl8.0 source (http://www.tclconsortium.org/)</LI>
+
+<LI>tk8.0 source (http://www.tclconsortium.org/)</LI>
+
+<LI>pgaccess source (http://www.flex.ro/pgaccess)</LI>
+</UL>
+</UL>
+
+<P><B>2) Installation:</B></P>
+
+<P>a) tcl/tk:</P>
+
+<UL>
+<P>You must first install tcl and then tk (in that order). I just used
+./configure, no switches and gmake. Their installation should be trouble
+free. Then you must move headers and libraries to the right places so:</P>
+
+<P>Header files: both tcl and tk have a header file (tcl.h and tk.h). The
+tcl.h file is in $tcl_source_dir/generic and the tk.h file is in $tk_source_dir/generic;
+both should be copied to /usr/local/include.</P>
+
+<P>Libraries: compilation (with cc) of tcl and tk yield libraries libtcl8.0.a
+and libtk8.0.a in $source_dir/unix. Both should be copied to /usr/local/lib.</P>
+</UL>
+
+<P>b) postgreSQL:</P>
+
+<UL>
+<P>Make sure you have a fully patched postgreSQL source. If your ./configure
+says it can't load 'IRIX' settings then you most probably will need to
+patch ./configure.</P>
+
+<P>Configure using ./configure with the following switches: ./configure
+--with-includes=/usr/local/include</P>
+
+<P>--with-libraries=/usr/local/lib --with-tcl [this and previous line as
+one]</P>
+
+<P>Then make, make install as usual</P>
+</UL>
+
+<P>c) Compiling libpgtcl:</P>
+
+<UL>
+<P>The source for libpgtcl is in $postgreSQL_directory/src/interfaces/libpgsql.</P>
+
+<P>I do this twice. Once with just gmake. This produces a static library
+libpgtcl.a which I leave where it is (I don't know what to do with it but
+it may just come in handy). The I modify Makefile manually with a text
+editor. Essentially I modify two line:</P>
+
+<P>before:</P>
+
+<P># Shared library stuff</P>
+
+<P>install-shlib-dep := shlib :=</P>
+
+<P>after:</P>
+
+<P># Shared library stuff</P>
+
+<P>install-shlib-dep := install-shlib shlib := libpgtcl.so.1</P>
+
+<P>Then gmake -f Makefile_modified. This creates two shared (.so) libraries:
+libpgtcl.so and libpgtcl.so.1. I can't tell the difference between them
+so I copied them both to /usr/lib/.</P>
+</UL>
+
+<P>d) running pgaccess:</P>
+
+<UL>
+<P>Uncompress pgaccess (usually with gunzip and tar). So long as 'wish'
+(a binary produced when compiling tk8.0) is somewhere in your path, you
+should be able to run pgaccess with:</P>
+
+<P>wish -f $pgaccess_dir/pgaccess.tcl [postgreSQL_database_name]</P>
+</UL>
+
+<P>e) et voila!</P>
+
+<P><B>3) Concluding remarks:</B></P>
+
+<UL>
+<P>As I stated at the start of this document, following the procedure indicated
+above worked for me. I am sure, however, that a few of the steps are unnecessary/non-optimised/stupid
+etc. If any Unix (IRIX) boffin is reading this and you spot anything you
+would like to comment/correct etc. please e-mail me (stuart@ludwig.ucl.ac.uk).
+Also, if you just have questions and think I might help, please contact
+me at the same e-mail.</P>
+
+<P>Finally, I can accept no responsibility if these steps don't work for
+you or if it all goes horribly wrong and you 'damage' your computer trying
+them. Let common sense prevail!</P>
+</UL>
+
+<P>Good luck</P>
+
+<P>Stuart Rison LICR University College London London W1P 8BT<BR>
+<A HREF="mailto:stuart@ludwig.ucl.ac.uk">stuart@ludwig.ucl.ac.uk</A></P>
+<a href="index.html#start">Back to index</a>
+</BODY>
+</HTML>
diff --git a/src/bin/pgaccess/doc/html/tutorial/newref.txt b/src/bin/pgaccess/doc/html/tutorial/newref.txt
new file mode 100644 (file)
index 0000000..ef2185f
--- /dev/null
@@ -0,0 +1 @@
+Cassileth, BR~Unorthodox Cancer Medicine~Cancer Investigation~~1986~4~6~591-598
diff --git a/src/bin/pgaccess/doc/html/tutorial/newtable.jpg b/src/bin/pgaccess/doc/html/tutorial/newtable.jpg
new file mode 100644 (file)
index 0000000..06af40e
Binary files /dev/null and b/src/bin/pgaccess/doc/html/tutorial/newtable.jpg differ
diff --git a/src/bin/pgaccess/doc/html/tutorial/newtable.tga b/src/bin/pgaccess/doc/html/tutorial/newtable.tga
new file mode 100644 (file)
index 0000000..6104f58
Binary files /dev/null and b/src/bin/pgaccess/doc/html/tutorial/newtable.tga differ
diff --git a/src/bin/pgaccess/doc/html/tutorial/problems.html b/src/bin/pgaccess/doc/html/tutorial/problems.html
new file mode 100644 (file)
index 0000000..2238fb6
--- /dev/null
@@ -0,0 +1,83 @@
+<html><head><title>PgAccess - Common Problems</title></head>
+<body bgcolor="#C0C0C0">
+<h1>Common Problems with PgAccess</h1>
+<a name="connfail"><h2>Connection failure</h2>
+One of the most common initial problems is the message:<p>
+<samp>Error connecting database<br>
+Connection to database failed<br>
+connectDB() failed: Is the<br>
+postmaster running and<br>
+accepting TCP/IP (with -i)<br>
+connections at 'localhost' on<br>
+port '5432'?</samp><p>
+This usually occurs because the "postmaster" (the postgreSQL backend) was not
+started with the <samp>-i</samp> option.  Usually just adding <samp>-i</samp> to
+the command line that starts the postmaster and restarting will fix this.<p>
+If you have installed the prewritten script to start <b>postgreSQL</b> 
+automatically, this option is (currently) commented out:<p>
+<samp># PGOPTS="-i"</samp><p>
+just remove the hash and space and comment out the "blank" option above:<p>
+<samp>PGOPTS=""</samp><p>
+<a name="nonuser"><h2>User not defined</h2>
+Initially, <b>postgreSQL</b> only has one user, <samp>postgres</samp>, and any
+other user who starts up PgAccess will get the message:<p>
+<samp>Error connecting database<br>
+Connection to database failed<br>
+FATAL 1: SetUserId: user<br>
+'jim' is not in 'pg_shadow'</samp><p>
+See <b>User Administration</b> in the <b>PgAccess tutorial</b> for a description
+of how to create users.<p>
+<a name="libpg"><h2>libpgtcl not found</h2>
+PgAccess requires a library of functions named <samp>libpgtcl</samp>.  This
+should be available with the postgreSQL distribution, and is usually placed in
+the correct location when installing postgreSQL.  First check that there is a
+file named <samp>libpgtcl.so</samp> (perhaps with a number appended - or
+<samp>libpgtcl.dll</samp> on Windows systems) on your
+system.  If not, you will have to download and perhaps compile this library.<p>
+<samp>ftp://ftp.flex.ro/pub/pgaccess</samp><p>
+is one place that you can download precompiled libpgtcl libraries for
+PgAccess.<p>
+<a name="spchar">
+<h2>Locale specific characters</h2>
+This problem occurs with some special characters used in different
+countries because PgAccess did not use fonts with `-ISO8859-1' encoding.<p>
+One solution was proposed by H.P.Heidinger ( hph@hphbbs.ruhr.de) and
+is very simple.<p>
+If you look in the file pgaccess.tcl, you will find the fonts declared in 
+this manner:<p>
+<TT>$ grep -e '-font' -i pgaccess.tcl<BR>
+-font -Adobe-Helvetica-Medium-R-Normal--*-120-*-*-*-*-*-* \<br>
+...</TT></P>
+The font declarations should be altered to:<p>
+<tt>-font -Adobe-Helvetica-Medium-R-Normal-*-*-120-*-*-*-*-iso8859-1<br>
+...</tt><p>
+That is, inserting an asterisk between the first pair of hyphens, and changing
+the final two asterisks to <samp>iso8859</samp> and <samp>1</samp>
+respectively.<p>
+You can alter the source code by running the following script :
+<P><TT>#!/bin/sh<BR>
+cp pgaccess.tcl pgaccess.tcl-org<BR>
+cat pgaccess.tcl |\<BR>
+sed -e's/\-\*\-\*\ /\-iso8859\-1\ /g' |\<BR>
+sed -e's/\-\*\-\*\}/\-iso8859\-1}/g' |\<BR>
+sed -e's/\-\*\-\*\]/\-iso8859\-1]/g' |\<BR>
+sed -e's/\-\*\-\*$/\-iso8859\-1/g' |\<BR>
+sed -e's/\-Clean\-/\-Fixed\-/g' |\<BR>
+sed -e's/clean/fixed/g' &gt;pgaccess.iso<BR>
+mv pgaccess.iso pgaccess.tcl<BR>
+chmod +x pgaccess.tcl</TT><P>
+The final version of PgAccess (1.0) will let the user decide what fonts
+will be used through a &quot;preferences&quot; dialog window.</p>
+<a name="pg63">
+<h2>Problem with PostgreSQL 6.3.x</h2>
+PgAccess 0.93 and later may have problems working with PostgreSQL 6.3.x.
+Changes in libpgtcl have been made to remove these, but if you are
+using PostgreSQL 6.3.x, this patch will allow you to get around the problems.<p>
+In the procedure <tt>wpg_exec</tt> change the following line:<p>
+<tt>set pgsql(errmsg) [pg_result $pgsql(res) -error]</tt><p>
+to this:<p>
+<tt>set pgsql(errmsg) "NO ERROR INFORMATION SUPPLIED"</tt><p>
+and the program will work. The only disadvantage is that with some error 
+conditions, you will not get the appropriate error message from libpgtcl.<p>
+<a href="index.html#problems">Back to index</a>
+</body></html>
diff --git a/src/bin/pgaccess/doc/html/tutorial/screen1.jpg b/src/bin/pgaccess/doc/html/tutorial/screen1.jpg
new file mode 100644 (file)
index 0000000..572b507
Binary files /dev/null and b/src/bin/pgaccess/doc/html/tutorial/screen1.jpg differ
diff --git a/src/bin/pgaccess/doc/html/tutorial/sel_tbl.jpg b/src/bin/pgaccess/doc/html/tutorial/sel_tbl.jpg
new file mode 100644 (file)
index 0000000..548dbee
Binary files /dev/null and b/src/bin/pgaccess/doc/html/tutorial/sel_tbl.jpg differ
diff --git a/src/bin/pgaccess/doc/html/tutorial/start.html b/src/bin/pgaccess/doc/html/tutorial/start.html
new file mode 100644 (file)
index 0000000..8ad8c2a
--- /dev/null
@@ -0,0 +1,74 @@
+<html><head><title>PgAccess - Getting Started</title></head>
+<body bgcolor="#C0C0C0">
+<h1>PgAccess - Getting Started</h1>
+<a name="getpga"><h2>How to get PgAccess</h2>
+If you have this HTML help system, you have probably already downloaded 
+PgAccess.  If not, or you wish to download the latest version, it is available
+from the URL:<p>
+<samp>http://www.flex.ro</samp><p>
+The home page will contain instructions on which files to download for your
+operating system.  Download the file to a directory where the program will
+eventually reside (see below).<p>
+<a name="uncpga"><h2>How to uncompress PgAccess</h2>
+PgAccess, like most applications available for download, is usually downloaded 
+in compressed format to save download time.  You must uncompress these files in
+order to use the application.<p>
+<h3>UNIX (Linux, BSD, IRIX, Solaris, etc.)</h3>
+The files will be compressed using "gzip" and packaged using "tar", and have
+filenames like this:<p>
+<samp>pgaccess-n.nn.tar.gz</samp><p>
+Note that "n.nn" will be the version number in an actual file.<p>
+First decide where you want to have the program.  A typical location on UNIX
+systems is <samp>/usr/local/src/&lt;name&gt;</samp>, where &lt;name&gt; is the name of
+the program.  To use this location, download or move the "tar.gz" file to the
+directory <samp>/usr/local/src</samp>.  Change to that directory, and 
+uncompress the file with the command:<p>
+<samp>tar -zxvf pgaccess-n.nn.tar.gz</samp><p>
+You should see the files listed as they are uncompressed and placed in the new
+directory, and now have a directory named:<p>
+<samp>/usr/local/src/pgaccess</samp><p>
+In that directory will be all of the files that were packaged in the downloaded
+file.  When you have PgAccess working, you can delete the file with the ".tar"
+or ".tar.gz" extension.
+<h3>Windows</h3>
+The files will be compressed so that "WinZip" will uncompress the package.  Just
+open the file with "WinZip" and the program files will be extracted.<p>
+<a name="putpga"><h2>Putting PgAccess where it will be found</h2>
+<h3>UNIX</h3>
+In order to run PgAccess easily, the program file "pgaccess.tcl" should be in a
+location on the "PATH" of the system.  You can find out what the PATH is by
+entering:<p>
+<samp>echo $PATH<br>
+/sbin:/usr/sbin:/bin:/usr/bin:/usr/X11R6/bin:/usr/local/bin:./:/usr/local/pgsql/bin
+</samp><p>
+Usually the directory <samp>/usr/local/bin</samp> will be in your PATH, and that
+is a fairly common place to put programs like PgAccess.  Other common
+directories in the PATH are <samp>/usr/bin</samp> and <samp>/usr/sbin</samp>. 
+Simply move the file "pgaccess.tcl" to the directory where you want it.<p>
+<h3>Windows</h3>
+You will usually link PgAccess to an icon, so just specify the full path to the
+program when you create the icon.
+<a name=startpga"><h2>Starting PgAccess</h2>
+The easiest way to start PgAccess is to simply invoke the program by name:<p>
+<samp>pgaccess.tcl</samp><p>
+If the program has been placed in a directory listed in the PATH, the PgAccess 
+window should appear.<p>
+<h3>Starting from a menu</h3>
+Most users will want to link the program to a menu or icon so that it can be 
+started using the mouse or other pointing device.  Here is a method that will
+work on most Linux X-Windows systems.  Create a file named "pgaccess" in the directory
+<samp>/etc/X11/wmconfig</samp> with the following contents:<p>
+<samp>pgaccess name "PgAccess"<br>
+pgaccess description "postgreSQL frontend"<br>
+pgaccess mini-icon "mini-pgaccess.xpm"<br>
+pgaccess group "Applications"<br>
+pgaccess exec "pgaccess.tcl &"</samp><p>
+This assumes that you have an "Applications" sub-menu.  You may prefer
+"Programs" or some other place.  Also, you will have to create the
+"mini-pgaccess.xpm" icon if you want it to appear.  You can edit an existing
+icon from the <samp>/usr/share/icons/mini</samp> directory in XPaint and rename
+it.  When you next start an X-Windows session, there should be a "PgAccess" item
+on the menu that you have chosen.  Clicking on this item should start
+PgAccess.<p>
+<a href="index.html#start">Back to index</a>
+</body></html>
diff --git a/src/bin/pgaccess/doc/html/tutorial/tut.html b/src/bin/pgaccess/doc/html/tutorial/tut.html
new file mode 100644 (file)
index 0000000..e5387e6
--- /dev/null
@@ -0,0 +1,50 @@
+<html><head><title>PgAccess - Tutorial</title></head>
+<body bgcolor="#C0C0C0">
+<h1>PgAccess - Tutorial</h1>
+<a name="admin"><h2>User Administration</h2>
+The procedure for setting up <b>postgreSQL</b> usually results in a single user
+named <samp>postgres</samp>.  In order for anyone else to use <b>postgreSQL</b>,
+users must be added.  The program <samp>createuser</samp> accomplishes this. 
+First become the PostgreSQL administrator (usually <samp>postgres</samp>):<p>
+<samp>su postgres</samp><p>
+Then create a new user:<p>
+<samp>createuser jim<br>
+Enter user's postgres ID or RETURN to use unix user ID: 500 -&gt;<br>
+Is user "jim" allowed to create databases (y/n) y<br>
+Is user "jim" a superuser? (y/n) n<br>
+createuser: jim was successfully added</samp><p>
+You can use either the UNIX user ID or the postgres ID to identify users.  See
+the <b>postgreSQL</b> documentation in the "admin" section for a fuller
+account of users and groups.<p>
+To remove users, use the <samp>destroyuser</samp> command in the same way.<p> 
+<img src="screen1.jpg" border=1 align=right>
+<a name="basic"><h2>Basic use of PgAccess</h2>
+<h3>Creating a database</h3>
+At the right is the window you should see when PgAccess starts up. The first
+task for most users will be to create a database.<p> 
+Press the <em>New</em> button to bring up the window shown below.  This will
+allow you to specify the structure of the new table.  It is important to note
+that if you haven't specified a database when starting up PgAccess, this table
+will be created in the database named <samp>&lt;username&gt;</samp>, your
+username.<p>
+Assume that you want to create a table with entries describing bibliographic 
+references in the field of chemistry.  Choose a table name, such as
+<samp>chemref</samp> that will be easy to recall and find in a list.  Enter the
+table name in the first input field.<p>
+When you already have tables in a database, you can use the <em>Inherits</em>
+button to toggle a list of existing tables to inherit characteristics of another
+table.  In this example, there should be no previous tables to use.<p>
+Enter each field, giving it a name, field type and size, if the field type does
+not imply the size.  That is, if your first field was to be a sequence number,
+and you selected <em>int2</em> as the field type, you would not have to specify
+a field size.  However, if your second field was to contain the author of the
+reference, and was a <em>varchar</em> type, you would have to specify how many
+characters would be allowed in the field.<p>
+As you enter each field, click the <em>Add field</em> button to add it to the
+list at the right side of the window.  You can change the position of fields
+using the <em>Move field up</em> and <em>Move field down</em> buttons, or delete
+a field if you decide it isn't what you wanted.  When you are finished
+specifying fields, press the <em>Create table</em> button.<p>
+<img src="newtable.jpg" border=1 align=right>
+<a href="index.html#tut">Back to index</a>
+</body></html>
diff --git a/src/bin/pgaccess/doc/html/tutorial/tut_edit.html b/src/bin/pgaccess/doc/html/tutorial/tut_edit.html
new file mode 100644 (file)
index 0000000..8282fb9
--- /dev/null
@@ -0,0 +1,39 @@
+<html><head><title>PgAccess Tutorial</title></head>
+<body bgcolor="#C0C0C0">
+<h1>PgAccess Tutorial - Editing a table</h1>
+<img src="sel_tbl.jpg" border=1 align=right>
+<h2>Adding records</h2>
+Once you have a table, you can begin to add entries to it.  In the main
+PgAccess window, when you click the <em>Tables</em> button, you should see the
+new table appear in the list of tables.  Highlighting the table name by clicking
+on it and clicking on the <em>Open</em> button will open that table in another
+window, as shown below.<p>
+The most straighforward way to add records to a table is to type the information
+directly into the fields.  Two records have been entered in the table shown.  As
+is common with this user interface, clicking the mouse while the pointer is in a 
+field will allow keyboard entry to that field.  This type of entry is adequate
+when the information arrives infrequently in small parcels, for instance in
+keeping a table of contact information about other researchers.  However, what
+do you do when someone emails you the entire reference list for their doctoral
+dissertation?<p>
+This is best handled using the SQL <em>COPY</em> command. 
+First, the information will have to be massaged into shape in what is called a
+'flat' ASCII file.  This is simply a text file in which each line is a record,
+and each field in each record is separated by a <em>delimiter</em> such as a
+tilde (~).  The fields will have to be in the same order as those in your table,
+and there will have to be the same number of fields in each record as are in the
+table, otherwise you may get unexpected data or no data at all.  Say you produce
+a text file named <samp>newref.txt</samp> that starts like this:<p>
+<samp>Cassileth, BR~Unorthodox Cancer Medicine~Cancer Investigation~~1986~4~6~591-598
+<br>...</samp><p>
+Notice that there are two consecutive tildes to allow for the fact that this
+particular entry doesn't have anything in the <b>Editor</b> field.
+You can then perform a <em>Query</em> as follows:<p>
+<samp>COPY psyref FROM '/home/jim/newref.txt' USING DELIMITERS
+'~';</samp><p>
+This will read the records from <samp>newref.txt</samp> and insert them into the
+table <samp>psyref</samp>. See the PostgreSQL documentation under the headings 
+<br><b>Tutorial|The Query Language|Populating a Class with Instances</b><p>
+<img src="addref.jpg" border=1 align=right>
+<a href="index.html#tut">Back to index</a>
+</body></html>
diff --git a/src/bin/pgaccess/doc/html/tutorial/tut_new.html b/src/bin/pgaccess/doc/html/tutorial/tut_new.html
new file mode 100644 (file)
index 0000000..8fca641
--- /dev/null
@@ -0,0 +1,36 @@
+<html><head><title>PgAccess Tutorial</title></head>
+<body bgcolor="#C0C0C0">
+<h1>PgAccess Tutorial - Creating a table</h1>
+<img src="screen1.jpg" border=1 align=right>
+<h2>Creating a table</h2>
+At the right is the window you should see when PgAccess starts up. The first
+task for most users will be to create a database.  Notice the 'buttons' at the 
+left of the main window.  Clicking on these allows you to see the names of 
+different <em>objects</em> that are stored in your database, which should be 
+empty at the moment.<p> 
+Click the <em>Tables</em> and <em>New</em> buttons to bring up the window shown 
+below.  This will allow you to specify the structure of the new table.  It is 
+important to note that if you haven't specified a database when starting up 
+PgAccess, this table will be created in the database named 
+<samp>&lt;username&gt;</samp>, your username.<p>
+Assume that you want to create a table with entries describing bibliographic 
+references in the field of psychology.  Choose a table name, such as
+<samp>psyref</samp> that will be easy to recall and find in a list.  Enter the
+table name in the first input field.<p>
+When you already have tables in a database, you can use the <em>Inherits</em>
+button to toggle a list of existing tables to inherit characteristics of another
+table.  In this example, there should be no previous tables to use.<p>
+Enter each field, giving it a name, field type and size, if the field type does
+not imply the size.  That is, if your first field was to be a sequence number,
+and you selected <em>int2</em> as the field type, you would not have to specify
+a field size.  However, if your second field was to contain the author of the
+reference, and was a <em>varchar</em> type, you would have to specify how many
+characters would be allowed in the field.<p>
+As you enter each field, click the <em>Add field</em> button to add it to the
+list at the right side of the window.  You can change the position of fields
+using the <em>Move field up</em> and <em>Move field down</em> buttons, or delete
+a field if you decide it isn't what you wanted.  When you are finished
+specifying fields, press the <em>Create table</em> button.<p>
+<img src="newtable.jpg" border=1 align=right>
+<a href="index.html#tut">Back to index</a>
+</body></html>
diff --git a/src/bin/pgaccess/doc/html/tutorial/tut_sel1.html b/src/bin/pgaccess/doc/html/tutorial/tut_sel1.html
new file mode 100644 (file)
index 0000000..fdadbe8
--- /dev/null
@@ -0,0 +1,36 @@
+<html><head><title>PgAccess Tutorial</title></head>
+<body bgcolor="#C0C0C0">
+<h1>PgAccess Tutorial - SELECT</h1>
+<img src="altern_q.jpg" border=1 align=right>
+<h2>What is a query?</h2>
+<em>Query</em> is the term for an SQL command which will perform an operation
+on a table.  It is sometimes confusing to newcomers, as some of the operations
+seem to have nothing to do with querying in the common sense of <em>asking</em>.
+As we saw in the previous section, a <em>query</em> can simply copy
+records from an ASCII file to a table.<p>
+The PostgreSQL documentation has a complete list of <em>queries</em> that can be
+used.  We'll start with the common task of selecting records with certain
+characteristics.<p>
+<h2>Selecting records</h2>
+<img src="altern_v.jpg" border=1 align=right>
+Suppose that I want to know all of the references in the sample table
+<em>psyref</em> for which the word "alternative" appeared in the title.<p>
+By clicking <em>Query</em>, then <em>New</em>, a <b>Query builder</b> window will
+appear.  Clicking in the area below the buttons will allow the user to enter an
+SQL <em>query</em>.  The specification of the <em>query</em> must be exact or
+PostgreSQL will return an error message.<p>
+The <em>query</em> shown will <b>SELECT</b> those records from <em>psyref</em>
+that contain the word "alternative" anywhere in the <em>title</em> field.  The
+'*' indicates that all of the fields are to be returned.  You might only want to
+return, for instance, the <em>author</em> field if you were only interested in
+which authors had used that word in the title of their work.<p>
+At the right is the record that fulfils these conditions, displayed in the 
+<b>Table viewer</b>.  If you wanted to save this query for use again,
+clicking the <em>Save query definition</em> button will do so.  You will then
+see <em>altern</em> listed under <em>Queries</em> when you return to the main
+window.  By clicking the <em>Save this query as a view</em> tickbox in the 
+<b>Query builder</b>, the result of your query will be saved as a 
+<em>View</em> which you can access from <em>Views</em> in the main window.  
+Click the <em>Close</em> button to leave the <b>Query builder</b>.<p>
+<a href="index.html#tut">Back to index</a>
+</body></html>
diff --git a/src/bin/pgaccess/doc/html/tutorial/tut_user.html b/src/bin/pgaccess/doc/html/tutorial/tut_user.html
new file mode 100644 (file)
index 0000000..c4a6f09
--- /dev/null
@@ -0,0 +1,28 @@
+<html><head><title>PgAccess Tutorial</title></head>
+<body bgcolor="#C0C0C0">
+<h1>PgAccess Tutorial - User Administration</h1>
+While user administration is really not a part of the PgAccess program, it is 
+such a basic operation that a brief description is given here.
+<h2>Creating users</h2>
+The procedure for setting up <b>postgreSQL</b> usually results in a single user
+named <samp>postgres</samp>.  In order for anyone else to use <b>postgreSQL</b>,
+users must be added.  The program <samp>createuser</samp> accomplishes this. 
+First become the PostgreSQL administrator (usually <samp>postgres</samp>):<p>
+<samp>su postgres</samp><p>
+Then create a new user:<p>
+<samp>createuser jim<br>
+Enter user's postgres ID or RETURN to use unix user ID: 500 -&gt;<br>
+Is user "jim" allowed to create databases (y/n) y<br>
+Is user "jim" a superuser? (y/n) y<br>
+createuser: jim was successfully added</samp><p>
+You can use either the UNIX user ID or the postgres ID to identify users.  See
+the <b>postgreSQL</b> documentation in the "admin" section for a fuller
+account of users and groups.<p>
+The reason for using the command line to create the first user (other than
+<em>postgres</em>) is that <em>postgres</em> may not have X-Window permission.
+You can also create users using <b>PgAccess</b> if you are created as a 
+<em>superuser</em> as shown in the example above.<p>
+<h2>Removing users</h2>
+To remove users, use the <samp>destroyuser</samp> command in the same way.<p> 
+<a href="index.html#tut">Back to index</a>
+</body></html>
diff --git a/src/bin/pgaccess/doc/html/vdesigner.gif b/src/bin/pgaccess/doc/html/vdesigner.gif
new file mode 100644 (file)
index 0000000..71349e6
Binary files /dev/null and b/src/bin/pgaccess/doc/html/vdesigner.gif differ
diff --git a/src/bin/pgaccess/doc/html/whatsnew.html b/src/bin/pgaccess/doc/html/whatsnew.html
new file mode 100644 (file)
index 0000000..f2faede
--- /dev/null
@@ -0,0 +1,50 @@
+<!doctype html public "-//w3c//dtd html 4.0 transitional//en">
+<html>
+<head>
+   <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
+   <meta name="GENERATOR" content="Mozilla/4.61 [en] (X11; I; Linux 2.2.11 i586) [Netscape]">
+</head>
+<body bgcolor="#FEFEDF">
+<b>29 August 1999</b> - PgAccess 0.98 has been released!
+<ul>
+<li>
+international version (romanian, french, italian translations available)
+in separate files (japanese translation now possible)</li>
+
+<li>
+context sensitive help, complete help for SQL commands</li>
+
+<li>
+geometry changes for many forms</li>
+
+<li>
+form designer enhancements (widget icons , new attribute window style,
+form startup script)</li>
+
+<li>
+ability to inspect PostgreSQL system tables (preferences)</li>
+
+<li>
+enhanced table design window, table permissions</li>
+
+<li>
+distribution archive changes</li>
+
+<li>
+unified internal global variables</li>
+
+<li>
+unified internal window naming conventions</li>
+
+<li>
+usage of Tcl namespaces for all modules</li>
+
+<li>
+PgAccess developer <a href="api.html">API</a></li>
+
+<li>
+web site enhancements</li>
+</ul>
+
+</body>
+</html>
diff --git a/src/bin/pgaccess/doc/html/win32.html b/src/bin/pgaccess/doc/html/win32.html
new file mode 100644 (file)
index 0000000..368eb99
--- /dev/null
@@ -0,0 +1,45 @@
+<!doctype html public "-//w3c//dtd html 4.0 transitional//en">
+<html>
+<head>
+   <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
+   <meta name="GENERATOR" content="Mozilla/4.61 [en] (X11; I; Linux 2.2.11 i586) [Netscape]">
+</head>
+<body bgcolor="#FEFEDF">
+
+<h2>
+PgAccess on Win32</h2>
+
+<hr>In order to run PgAccess on a Win32 workstation you should follow the
+following steps:
+<ol>
+<li>
+download and install a Tcl/Tk package from <a href="http://www.scriptics.com">Scriptics</a>
+(8.0.x or 8.1.x)</li>
+
+<li>
+install PgAccess package</li>
+
+<li>
+check the Tcl/Tk version that you have</li>
+
+<li>
+check the PostgreSQL version installed on your database server machine</li>
+
+<li>
+get from win32/dll directory the appropriate libraries suitable for your
+Tcl/Tk version and PostgreSQL version and copy them into your Windows/System
+directory renaming them as libpq.dll and libpgtcl.dll</li>
+
+<li>
+check if your win32 workstation is able to see your database server (ping
+yourdatabaseserver)</li>
+
+<li>
+ask your database administrator to verify if your win32 workstation has
+access rights to the database (pg_hba.conf)</li>
+</ol>
+
+<p><br>You should be able to run PgAccess.
+<br>&nbsp;
+</body>
+</html>
diff --git a/src/bin/pgaccess/images/icon_button.gif b/src/bin/pgaccess/images/icon_button.gif
new file mode 100644 (file)
index 0000000..df70591
Binary files /dev/null and b/src/bin/pgaccess/images/icon_button.gif differ
diff --git a/src/bin/pgaccess/images/icon_checkbutton.gif b/src/bin/pgaccess/images/icon_checkbutton.gif
new file mode 100644 (file)
index 0000000..ddfe64c
Binary files /dev/null and b/src/bin/pgaccess/images/icon_checkbutton.gif differ
diff --git a/src/bin/pgaccess/images/icon_entry.gif b/src/bin/pgaccess/images/icon_entry.gif
new file mode 100644 (file)
index 0000000..750d1ff
Binary files /dev/null and b/src/bin/pgaccess/images/icon_entry.gif differ
diff --git a/src/bin/pgaccess/images/icon_frame.gif b/src/bin/pgaccess/images/icon_frame.gif
new file mode 100644 (file)
index 0000000..8541cbe
Binary files /dev/null and b/src/bin/pgaccess/images/icon_frame.gif differ
diff --git a/src/bin/pgaccess/images/icon_label.gif b/src/bin/pgaccess/images/icon_label.gif
new file mode 100644 (file)
index 0000000..d606816
Binary files /dev/null and b/src/bin/pgaccess/images/icon_label.gif differ
diff --git a/src/bin/pgaccess/images/icon_listbox.gif b/src/bin/pgaccess/images/icon_listbox.gif
new file mode 100644 (file)
index 0000000..c485e9b
Binary files /dev/null and b/src/bin/pgaccess/images/icon_listbox.gif differ
diff --git a/src/bin/pgaccess/images/icon_query.gif b/src/bin/pgaccess/images/icon_query.gif
new file mode 100644 (file)
index 0000000..ced0ef2
Binary files /dev/null and b/src/bin/pgaccess/images/icon_query.gif differ
diff --git a/src/bin/pgaccess/images/icon_radiobutton.gif b/src/bin/pgaccess/images/icon_radiobutton.gif
new file mode 100644 (file)
index 0000000..9803df6
Binary files /dev/null and b/src/bin/pgaccess/images/icon_radiobutton.gif differ
diff --git a/src/bin/pgaccess/images/icon_text.gif b/src/bin/pgaccess/images/icon_text.gif
new file mode 100644 (file)
index 0000000..49d193c
Binary files /dev/null and b/src/bin/pgaccess/images/icon_text.gif differ
diff --git a/src/bin/pgaccess/lib/database.tcl b/src/bin/pgaccess/lib/database.tcl
new file mode 100644 (file)
index 0000000..828baf0
--- /dev/null
@@ -0,0 +1,61 @@
+namespace eval Database {
+
+proc {getTablesList} {} {
+global CurrentDB PgAcVar
+       set tlist {}
+       if {[catch {
+               wpg_select $CurrentDB "select c.relname,count(c.relname) from pg_class C, pg_rewrite R where (r.ev_class = C.oid) and (r.ev_type = '1') group by relname" rec {
+                       if {$rec(count)!=0} {
+                               set itsaview($rec(relname)) 1
+                       }
+               }
+               if {! $PgAcVar(pref,systemtables)} {
+                       wpg_select $CurrentDB "select relname from pg_class where (relname !~ '^pg_') and (relkind='r') order by relname" rec {
+                               if {![regexp "^pga_" $rec(relname)]} then {
+                                       if {![info exists itsaview($rec(relname))]} {
+                                               lappend tlist $rec(relname)
+                                       }
+                               }
+                       }
+               } else {
+                       wpg_select $CurrentDB "select relname from pg_class where (relkind='r') order by relname" rec {
+                               if {![info exists itsaview($rec(relname))]} {
+                                       lappend tlist $rec(relname)
+                               }
+                       }
+               }
+       } gterrmsg]} {
+               showError $gterrmsg
+       }
+       return $tlist
+}
+
+
+proc {vacuum} {} {
+global PgAcVar CurrentDB
+       if {$CurrentDB==""} return;
+       set PgAcVar(statusline,dbname) [format [intlmsg "vacuuming database %s ..."] $PgAcVar(currentdb,dbname)]
+       setCursor CLOCK
+       set pgres [wpg_exec $CurrentDB "vacuum;"]
+       catch {pg_result $pgres -clear}
+       setCursor DEFAULT
+       set PgAcVar(statusline,dbname) $PgAcVar(currentdb,dbname)
+}
+
+
+proc {getPgType} {oid} {
+global CurrentDB
+       set temp "unknown"
+       wpg_select $CurrentDB "select typname from pg_type where oid=$oid" rec {
+               set temp $rec(typname)
+       }
+       return $temp
+}
+
+
+proc {executeUpdate} {sqlcmd} {
+global CurrentDB
+       return [sql_exec noquiet $sqlcmd]
+}
+
+}
diff --git a/src/bin/pgaccess/lib/forms.tcl b/src/bin/pgaccess/lib/forms.tcl
new file mode 100644 (file)
index 0000000..631c353
--- /dev/null
@@ -0,0 +1,1263 @@
+namespace eval Forms {
+
+proc {new} {} {
+global PgAcVar
+       Window show .pgaw:FormDesign:menu
+       tkwait visibility .pgaw:FormDesign:menu
+       Window show .pgaw:FormDesign:toolbar
+       tkwait visibility .pgaw:FormDesign:toolbar
+       Window show .pgaw:FormDesign:attributes
+       tkwait visibility .pgaw:FormDesign:attributes
+       Window show .pgaw:FormDesign:draft
+       design:init
+}
+
+
+proc {open} {formname} {
+        forms:load $formname run
+        design:run
+}
+
+proc {design} {formname} {
+       forms:load $formname design
+}
+
+
+proc {design:change_coords} {} {
+global PgAcVar
+       set PgAcVar(fdvar,dirty) 1
+       set i $PgAcVar(fdvar,attributeFrame)
+       if {$i == 0} {
+               # it's the form
+               set errmsg ""
+               if {[catch {wm geometry .pgaw:FormDesign:draft $PgAcVar(fdvar,c_width)x$PgAcVar(fdvar,c_height)+$PgAcVar(fdvar,c_left)+$PgAcVar(fdvar,c_top)} errmsg] != 0} {
+                       showError $errmsg
+               }
+               return
+       }               
+       set c [list $PgAcVar(fdvar,c_left) $PgAcVar(fdvar,c_top) [expr $PgAcVar(fdvar,c_left)+$PgAcVar(fdvar,c_width)] [expr $PgAcVar(fdvar,c_top)+$PgAcVar(fdvar,c_height)]]
+       set PgAcVar(fdobj,$i,coord) $c
+       .pgaw:FormDesign:draft.c delete o$i
+       design:draw_object $i
+       design:draw_hookers $i
+}
+
+
+proc {design:delete_object} {} {
+global PgAcVar
+       set i $PgAcVar(fdvar,moveitemobj)
+       .pgaw:FormDesign:draft.c delete o$i
+       .pgaw:FormDesign:draft.c delete hook
+       set j [lsearch $PgAcVar(fdvar,objlist) $i]
+       set PgAcVar(fdvar,objlist) [lreplace $PgAcVar(fdvar,objlist) $j $j]
+       set PgAcVar(fdvar,dirty) 1
+}
+
+
+proc {design:draw_hook} {x y} {
+       .pgaw:FormDesign:draft.c create rectangle [expr $x-2] [expr $y-2] [expr $x+2] [expr $y+2] -fill black -tags hook
+}
+
+
+proc {design:draw_hookers} {i} {
+global PgAcVar
+       foreach {x1 y1 x2 y2} $PgAcVar(fdobj,$i,coord) {}
+       .pgaw:FormDesign:draft.c delete hook
+       design:draw_hook $x1 $y1
+       design:draw_hook $x1 $y2
+       design:draw_hook $x2 $y1
+       design:draw_hook $x2 $y2
+}
+
+
+proc {design:draw_grid} {} {
+       for {set i 0} {$i<100} {incr i} {
+               .pgaw:FormDesign:draft.c create line 0 [expr {$i*6}] 1000 [expr {$i*6}] -fill #afafaf -tags grid
+               .pgaw:FormDesign:draft.c create line [expr {$i*6}] 0 [expr {$i*6}] 1000 -fill #afafaf -tags grid
+       }
+}
+
+
+proc {design:draw_object} {i} {
+global PgAcVar
+set c $PgAcVar(fdobj,$i,coord)
+foreach {x1 y1 x2 y2} $c {}
+.pgaw:FormDesign:draft.c delete o$i
+set wfont $PgAcVar(fdobj,$i,font)
+switch $wfont {
+       {} {set wfont $PgAcVar(pref,font_normal) ; set PgAcVar(fdobj,$i,font) normal}
+       normal  {set wfont $PgAcVar(pref,font_normal)}
+       bold  {set wfont $PgAcVar(pref,font_bold)}
+       italic  {set wfont $PgAcVar(pref,font_italic)}
+       fixed  {set wfont $PgAcVar(pref,font_fix)}
+}
+switch $PgAcVar(fdobj,$i,class) {
+       button {
+               design:draw_rectangle $x1 $y1 $x2 $y2 $PgAcVar(fdobj,$i,relief) $PgAcVar(fdobj,$i,bcolor) o$i
+               .pgaw:FormDesign:draft.c create text [expr ($x1+$x2)/2] [expr ($y1+$y2)/2] -fill $PgAcVar(fdobj,$i,fcolor) -text $PgAcVar(fdobj,$i,label) -font $wfont -tags o$i
+       }
+       text {
+               design:draw_rectangle $x1 $y1 $x2 $y2 $PgAcVar(fdobj,$i,relief) $PgAcVar(fdobj,$i,bcolor) o$i
+       }
+       entry {
+               design:draw_rectangle $x1 $y1 $x2 $y2 $PgAcVar(fdobj,$i,relief) $PgAcVar(fdobj,$i,bcolor) o$i
+       }
+       label {
+               set temp $PgAcVar(fdobj,$i,label)
+               if {$temp==""} {set temp "____"}
+               design:draw_rectangle $x1 $y1 $x2 $y2 $PgAcVar(fdobj,$i,relief) $PgAcVar(fdobj,$i,bcolor) o$i
+               .pgaw:FormDesign:draft.c create text [expr {$x1+1}] [expr {$y1+1}] -text $temp -fill $PgAcVar(fdobj,$i,fcolor) -font $wfont -anchor nw -tags o$i
+       }
+       checkbox {
+               design:draw_rectangle [expr $x1+2] [expr $y1+5] [expr $x1+12] [expr $y1+15] raised #a0a0a0 o$i
+               .pgaw:FormDesign:draft.c create text [expr $x1+20] [expr $y1+3] -text $PgAcVar(fdobj,$i,label) -anchor nw \
+                -fill $PgAcVar(fdobj,$i,fcolor) -font $wfont -tags o$i
+       }
+       radio {
+               .pgaw:FormDesign:draft.c create oval [expr $x1+4] [expr $y1+5] [expr $x1+14] [expr $y1+15] -fill white -tags o$i
+               .pgaw:FormDesign:draft.c create text [expr $x1+24] [expr $y1+3] -text $PgAcVar(fdobj,$i,label) -anchor nw \
+                -fill $PgAcVar(fdobj,$i,fcolor) -font $wfont -tags o$i
+       }
+       query {
+               .pgaw:FormDesign:draft.c create oval $x1 $y1 [expr $x1+20] [expr $y1+20] -fill white -tags o$i
+               .pgaw:FormDesign:draft.c create text [expr $x1+5] [expr $y1+4] -text Q  -anchor nw -font $PgAcVar(pref,font_normal) -tags o$i
+       }
+       listbox {
+               design:draw_rectangle $x1 $y1 [expr $x2-12] $y2 sunken $PgAcVar(fdobj,$i,bcolor) o$i
+               design:draw_rectangle [expr $x2-11] $y1 $x2 $y2 sunken gray o$i
+               .pgaw:FormDesign:draft.c create line [expr $x2-5] $y1 $x2 [expr $y1+10] -fill #808080 -tags o$i
+               .pgaw:FormDesign:draft.c create line [expr $x2-10] [expr $y1+9] $x2 [expr $y1+9] -fill #808080 -tags o$i
+               .pgaw:FormDesign:draft.c create line [expr $x2-10] [expr $y1+9] [expr $x2-5] $y1 -fill white -tags o$i
+               .pgaw:FormDesign:draft.c create line [expr $x2-5] $y2 $x2 [expr $y2-10] -fill #808080 -tags o$i
+               .pgaw:FormDesign:draft.c create line [expr $x2-10] [expr $y2-9] $x2 [expr $y2-9] -fill white -tags o$i
+               .pgaw:FormDesign:draft.c create line [expr $x2-10] [expr $y2-9] [expr $x2-5] $y2 -fill white -tags o$i
+       }
+}
+.pgaw:FormDesign:draft.c raise hook
+}
+
+proc {design:draw_rectangle} {x1 y1 x2 y2 relief color tag} {
+       if {$relief=="raised"} {
+               set c1 white
+               set c2 #606060
+       }
+       if {$relief=="sunken"} {
+               set c1 #606060
+               set c2 white
+       }
+       if {$relief=="ridge"} {
+               design:draw_rectangle $x1 $y1 $x2 $y2 raised none $tag
+               design:draw_rectangle [expr {$x1+1}] [expr {$y1+1}] [expr {$x2+1}] [expr {$y2+1}] sunken none $tag
+               design:draw_rectangle [expr {$x1+2}] [expr {$y1+2}] $x2 $y2 flat $color $tag
+               return
+       }
+       if {$relief=="groove"} {
+               design:draw_rectangle $x1 $y1 $x2 $y2 sunken none $tag
+               design:draw_rectangle [expr {$x1+1}] [expr {$y1+1}] [expr {$x2+1}] [expr {$y2+1}] raised none $tag
+               design:draw_rectangle [expr {$x1+2}] [expr {$y1+2}] $x2 $y2 flat $color $tag
+               return
+       }
+       if {$color != "none"} {
+               .pgaw:FormDesign:draft.c create rectangle $x1 $y1 $x2 $y2 -outline "" -fill $color -tags $tag
+       }
+       if {$relief=="flat"} {
+               return
+       }
+       .pgaw:FormDesign:draft.c create line $x1 $y1 $x2 $y1 -fill $c1 -tags $tag
+       .pgaw:FormDesign:draft.c create line $x1 $y1 $x1 $y2 -fill $c1 -tags $tag
+       .pgaw:FormDesign:draft.c create line $x1 $y2 $x2 $y2 -fill $c2 -tags $tag
+       .pgaw:FormDesign:draft.c create line $x2 $y1 $x2 [expr 1+$y2] -fill $c2 -tags $tag
+}
+
+
+proc {design:init} {} {
+global PgAcVar
+       PgAcVar:clean fdvar,*
+       PgAcVar:clean fdobj,*
+       catch {.pgaw:FormDesign:draft.c delete all}
+       # design:draw_grid
+       set PgAcVar(fdobj,0,name) {f1}
+       set PgAcVar(fdobj,0,class) form
+       set PgAcVar(fdobj,0,command) {}
+       set PgAcVar(fdvar,formtitle) "New form"
+       set PgAcVar(fdvar,objnum) 0
+       set PgAcVar(fdvar,objlist) {}
+       set PgAcVar(fdvar,oper) none
+       set PgAcVar(fdvar,tool) point
+       set PgAcVar(fdvar,resizable) 1
+       set PgAcVar(fdvar,dirty) 0
+}
+
+
+proc {design:item_click} {x y} {
+global PgAcVar
+       set PgAcVar(fdvar,oper) none
+       set PgAcVar(fdvar,moveitemobj) {}
+       set il [.pgaw:FormDesign:draft.c find overlapping $x $y $x $y]
+       .pgaw:FormDesign:draft.c delete hook
+       if {[llength $il] == 0} {
+               design:show_attributes 0
+               return
+       }
+       set tl [.pgaw:FormDesign:draft.c gettags [lindex $il 0]]
+       set i [lsearch -glob $tl o*]
+       if {$i == -1} return
+       set objnum [string range [lindex $tl $i] 1 end]
+       set PgAcVar(fdvar,moveitemobj) $objnum
+       set PgAcVar(fdvar,moveitemx) $x
+       set PgAcVar(fdvar,moveitemy) $y
+       set PgAcVar(fdvar,oper) move
+       design:show_attributes $objnum
+       design:draw_hookers $objnum
+}
+
+
+proc {forms:load} {name mode} {
+global PgAcVar CurrentDB
+       design:init
+       set PgAcVar(fdvar,formtitle) $name
+       if {$mode=="design"} {
+               Window show .pgaw:FormDesign:draft
+               Window show .pgaw:FormDesign:menu
+               Window show .pgaw:FormDesign:attributes
+               Window show .pgaw:FormDesign:toolbar
+       }
+       set res [wpg_exec $CurrentDB "select * from pga_forms where formname='$PgAcVar(fdvar,formtitle)'"]
+       set info [lindex [pg_result $res -getTuple 0] 1]
+       pg_result $res -clear
+       set PgAcVar(fdobj,0,name) [lindex $info 0]
+       set PgAcVar(fdvar,objnum) [lindex $info 1]
+       # check for old format , prior to 0.97 that
+       # save here the objlist (deprecated)
+       set temp [lindex $info 2]
+       if {[lindex $temp 0] == "FS"} {
+               set PgAcVar(fdobj,0,command) [lindex $temp 1]
+       } else {
+               set PgAcVar(fdobj,0,command) {}
+       }
+       set PgAcVar(fdvar,objlist) {}
+       set PgAcVar(fdvar,geometry) [lindex $info 3]
+       set i 1
+       foreach objinfo [lrange $info 4 end] {
+               lappend PgAcVar(fdvar,objlist) $i
+               set PgAcVar(fdobj,$i,class)    [lindex $objinfo 0]
+               set PgAcVar(fdobj,$i,name)     [lindex $objinfo 1]
+               set PgAcVar(fdobj,$i,coord)    [lindex $objinfo 2]
+               set PgAcVar(fdobj,$i,command)  [lindex $objinfo 3]
+               set PgAcVar(fdobj,$i,label)    [lindex $objinfo 4]
+               set PgAcVar(fdobj,$i,variable) [lindex $objinfo 5]
+               design:setDefaultReliefAndColor $i
+               set PgAcVar(fdobj,$i,value) $PgAcVar(fdobj,$i,name)
+               if {[llength $objinfo] >  6 } {
+                       set PgAcVar(fdobj,$i,value)       [lindex $objinfo 6]
+                       set PgAcVar(fdobj,$i,relief)      [lindex $objinfo 7]
+                       set PgAcVar(fdobj,$i,fcolor)      [lindex $objinfo 8]
+                       set PgAcVar(fdobj,$i,bcolor)      [lindex $objinfo 9]
+                       set PgAcVar(fdobj,$i,borderwidth) [lindex $objinfo 10]
+                       set PgAcVar(fdobj,$i,font)        [lindex $objinfo 11]
+                       # for space saving purposes we have saved onbly the first letter
+                       switch $PgAcVar(fdobj,$i,font) {
+                               n {set PgAcVar(fdobj,$i,font) normal}
+                               i {set PgAcVar(fdobj,$i,font) italic}
+                               b {set PgAcVar(fdobj,$i,font) bold}
+                               f {set PgAcVar(fdobj,$i,font) fixed}
+                       }
+               }
+               if {$mode=="design"} {design:draw_object $i}
+               incr i
+       }
+       if {$mode=="design"} {wm geometry .pgaw:FormDesign:draft $PgAcVar(fdvar,geometry)}
+}
+
+
+proc {design:mouse_down} {x y} {
+global PgAcVar
+       set x [expr 3*int($x/3)]
+       set y [expr 3*int($y/3)]
+       set PgAcVar(fdvar,xstart) $x
+       set PgAcVar(fdvar,ystart) $y
+       if {$PgAcVar(fdvar,tool)=="point"} {
+               design:item_click $x $y
+               return
+       }
+       set PgAcVar(fdvar,oper) draw
+}
+
+
+proc {design:mouse_move} {x y} {
+global PgAcVar
+       #set PgAcVar(fdvar,msg) "x=$x y=$y"
+       set x [expr 3*int($x/3)]
+       set y [expr 3*int($y/3)]
+       set oper ""
+       catch {set oper $PgAcVar(fdvar,oper)}
+       if {$oper=="draw"} {
+               catch {.pgaw:FormDesign:draft.c delete curdraw}
+               .pgaw:FormDesign:draft.c create rectangle $PgAcVar(fdvar,xstart) $PgAcVar(fdvar,ystart) $x $y -tags curdraw
+               return
+       }
+       if {$oper=="move"} {
+               set dx [expr $x-$PgAcVar(fdvar,moveitemx)]
+               set dy [expr $y-$PgAcVar(fdvar,moveitemy)]
+               .pgaw:FormDesign:draft.c move o$PgAcVar(fdvar,moveitemobj) $dx $dy
+               .pgaw:FormDesign:draft.c move hook $dx $dy
+               set PgAcVar(fdvar,moveitemx) $x
+               set PgAcVar(fdvar,moveitemy) $y
+               set PgAcVar(fdvar,dirty) 1
+       }
+}
+
+proc {design:setDefaultReliefAndColor} {i} {
+global PgAcVar
+       set PgAcVar(fdobj,$i,borderwidth) 1
+       set PgAcVar(fdobj,$i,relief) flat
+       set PgAcVar(fdobj,$i,fcolor) {}
+       set PgAcVar(fdobj,$i,bcolor) {}
+       set PgAcVar(fdobj,$i,font) normal
+       switch $PgAcVar(fdobj,$i,class) {
+               button {
+                       set PgAcVar(fdobj,$i,fcolor) #000000
+                       set PgAcVar(fdobj,$i,bcolor) #d9d9d9
+                       set PgAcVar(fdobj,$i,relief) raised
+               }
+               text {
+                       set PgAcVar(fdobj,$i,fcolor) #000000
+                       set PgAcVar(fdobj,$i,bcolor) #fefefe
+                       set PgAcVar(fdobj,$i,relief) sunken
+               }
+               entry {
+                       set PgAcVar(fdobj,$i,fcolor) #000000
+                       set PgAcVar(fdobj,$i,bcolor) #fefefe
+                       set PgAcVar(fdobj,$i,relief) sunken
+               }
+               label {
+                       set PgAcVar(fdobj,$i,fcolor) #000000
+                       set PgAcVar(fdobj,$i,bcolor) #d9d9d9
+                       set PgAcVar(fdobj,$i,relief) flat
+               }
+               checkbox {
+                       set PgAcVar(fdobj,$i,fcolor) #000000
+                       set PgAcVar(fdobj,$i,bcolor) #d9d9d9
+                       set PgAcVar(fdobj,$i,relief) flat
+               }
+               radio {
+                       set PgAcVar(fdobj,$i,fcolor) #000000
+                       set PgAcVar(fdobj,$i,bcolor) #d9d9d9
+                       set PgAcVar(fdobj,$i,relief) flat
+               }
+               listbox {
+                       set PgAcVar(fdobj,$i,fcolor) #000000
+                       set PgAcVar(fdobj,$i,bcolor) #fefefe
+                       set PgAcVar(fdobj,$i,relief) sunken
+               }
+       }
+}
+
+proc {design:mouse_up} {x y} {
+global PgAcVar
+       set x [expr 3*int($x/3)]
+       set y [expr 3*int($y/3)]
+       if {$PgAcVar(fdvar,oper)=="move"} {
+               set PgAcVar(fdvar,moveitem) {}
+               set PgAcVar(fdvar,oper) none
+               set oc $PgAcVar(fdobj,$PgAcVar(fdvar,moveitemobj),coord)
+               set dx [expr $x - $PgAcVar(fdvar,xstart)]
+               set dy [expr $y - $PgAcVar(fdvar,ystart)]
+               set newcoord [list [expr $dx+[lindex $oc 0]] [expr $dy+[lindex $oc 1]] [expr $dx+[lindex $oc 2]] [expr $dy+[lindex $oc 3]]]
+               set PgAcVar(fdobj,$PgAcVar(fdvar,moveitemobj),coord) $newcoord
+               design:show_attributes $PgAcVar(fdvar,moveitemobj)
+               design:draw_hookers $PgAcVar(fdvar,moveitemobj)
+               return
+       }
+       if {$PgAcVar(fdvar,oper)!="draw"} return
+       set PgAcVar(fdvar,oper) none
+       .pgaw:FormDesign:draft.c delete curdraw
+       # Check for x2<x1 or y2<y1
+       if {$x<$PgAcVar(fdvar,xstart)} {set temp $x ; set x $PgAcVar(fdvar,xstart) ; set PgAcVar(fdvar,xstart) $temp}
+       if {$y<$PgAcVar(fdvar,ystart)} {set temp $y ; set y $PgAcVar(fdvar,ystart) ; set PgAcVar(fdvar,ystart) $temp}
+       # Check for too small sizes
+       if {[expr $x-$PgAcVar(fdvar,xstart)]<20} {set x [expr $PgAcVar(fdvar,xstart)+20]}
+       if {[expr $y-$PgAcVar(fdvar,ystart)]<10} {set y [expr $PgAcVar(fdvar,ystart)+10]}
+       incr PgAcVar(fdvar,objnum)
+       set i $PgAcVar(fdvar,objnum)
+       lappend PgAcVar(fdvar,objlist) $i
+
+       set PgAcVar(fdobj,$i,class) $PgAcVar(fdvar,tool)
+       set PgAcVar(fdobj,$i,coord) [list $PgAcVar(fdvar,xstart) $PgAcVar(fdvar,ystart) $x $y]
+       set PgAcVar(fdobj,$i,name) $PgAcVar(fdvar,tool)$i
+       set PgAcVar(fdobj,$i,label) $PgAcVar(fdvar,tool)$i
+       set PgAcVar(fdobj,$i,command) {}
+       set PgAcVar(fdobj,$i,variable) {}
+       set PgAcVar(fdobj,$i,value) {}
+
+       design:setDefaultReliefAndColor $i
+       
+       design:draw_object $i
+       design:show_attributes $i
+       set PgAcVar(fdvar,moveitemobj) $i
+       design:draw_hookers $i
+       set PgAcVar(fdvar,tool) point
+       set PgAcVar(fdvar,dirty) 1
+}
+
+
+proc {design:save} {name} {
+global PgAcVar CurrentDB
+       if {[string length $PgAcVar(fdobj,0,name)]==0} {
+               tk_messageBox -title [intlmsg Warning] -message [intlmsg "Forms need an internal name, only literals, low case"]
+               return 0
+       }
+       if {[string length $PgAcVar(fdvar,formtitle)]==0} {
+               tk_messageBox -title [intlmsg Warning] -message [intlmsg "Form must have a name"]
+               return 0
+       }
+       set info [list $PgAcVar(fdobj,0,name) $PgAcVar(fdvar,objnum) [list FS $PgAcVar(fdobj,0,command)] [wm geometry .pgaw:FormDesign:draft]]
+       foreach i $PgAcVar(fdvar,objlist) {
+               set wfont $PgAcVar(fdobj,$i,font)
+               if {[lsearch {normal bold italic fixed} $wfont] != -1} {
+                       set wfont [string range $wfont 0 0]
+               }
+               lappend info [list $PgAcVar(fdobj,$i,class) $PgAcVar(fdobj,$i,name) $PgAcVar(fdobj,$i,coord) $PgAcVar(fdobj,$i,command) $PgAcVar(fdobj,$i,label) $PgAcVar(fdobj,$i,variable) $PgAcVar(fdobj,$i,value) $PgAcVar(fdobj,$i,relief) $PgAcVar(fdobj,$i,fcolor) $PgAcVar(fdobj,$i,bcolor) $PgAcVar(fdobj,$i,borderwidth) $wfont]
+       }
+       sql_exec noquiet "delete from pga_forms where formname='$PgAcVar(fdvar,formtitle)'"
+       regsub -all "'" $info "''" info
+       sql_exec noquiet "insert into pga_forms values ('$PgAcVar(fdvar,formtitle)','$info')"
+       Mainlib::cmd_Forms
+       set PgAcVar(fdvar,dirty) 0
+       return 1
+}
+
+
+proc {design:set_name} {} {
+global PgAcVar
+       set i $PgAcVar(fdvar,moveitemobj)
+       foreach k $PgAcVar(fdvar,objlist) {
+               if {($PgAcVar(fdobj,$k,name)==$PgAcVar(fdvar,c_name)) && ($i!=$k)} {
+                       tk_messageBox -title [intlmsg Warning] -message [format [intlmsg "There is another object (a %s) with the same name.\nPlease change it!"] $PgAcVar(fdobj,$k,class)]
+                       return
+               }
+       }
+       set PgAcVar(fdobj,$i,name) $PgAcVar(fdvar,c_name)
+       design:show_attributes $i
+       set PgAcVar(fdvar,dirty) 1
+}
+
+
+proc {design:set_text} {} {
+global PgAcVar
+       design:draw_object $PgAcVar(fdvar,moveitemobj)
+       set PgAcVar(fdvar,dirty) 1
+}
+
+
+proc {design:createAttributesFrame} {i} {
+global PgAcVar
+       # Check if attributes frame is already created for that item
+       
+       if {[info exists PgAcVar(fdvar,attributeFrame)]} {
+               if {$PgAcVar(fdvar,attributeFrame) == $i} return
+       }
+       set PgAcVar(fdvar,attributeFrame) $i
+       
+       # Delete old widgets from the frame
+       foreach wid [winfo children .pgaw:FormDesign:attributes.f] {
+               destroy $wid
+       }
+
+       set row 0
+       set base .pgaw:FormDesign:attributes.f
+       grid columnconf $base 1 -weight 1
+
+       set objclass $PgAcVar(fdobj,$i,class)
+
+       # if i is zero, then the object is the form
+       
+       if {$i == 0} {
+               label $base.l$row \
+               -borderwidth 0 -text [intlmsg {Startup script}]
+               entry $base.e$row -textvariable PgAcVar(fdobj,$i,command) \
+               -background #fefefe -borderwidth 1 -width 200 
+               button $base.b$row \
+               -borderwidth 1 -padx 1 -pady 0 -text ... -command "
+                               Window show .pgaw:FormDesign:commands
+                               set PgAcVar(fdvar,commandFor) $i
+                               .pgaw:FormDesign:commands.f.txt delete 1.0 end
+                               .pgaw:FormDesign:commands.f.txt insert end \$PgAcVar(fdobj,$i,command)"
+               grid $base.l$row \
+               -in $base -column 0 -row $row -columnspan 1 -rowspan 1 -sticky w 
+               grid $base.e$row \
+               -in $base -column 1 -row $row -columnspan 1 -rowspan 1 -padx 2 \
+               -sticky w                               
+               grid $base.b$row \
+               -in $base -column 2 -row $row -columnspan 1 -rowspan 1 
+               incr row
+       }
+
+       # does it have a text attribute ?
+       if {[lsearch {button label radio checkbox} $objclass] > -1} {
+               label $base.l$row \
+               -borderwidth 0 -text [intlmsg Text]
+               entry $base.e$row -textvariable PgAcVar(fdobj,$i,label) \
+               -background #fefefe -borderwidth 1 -width 200 
+               bind $base.e$row <Key-Return> "Forms::design:set_text"
+               grid $base.l$row \
+                       -in $base -column 0 -row $row -columnspan 1 -rowspan 1 -sticky w 
+               grid $base.e$row \
+               -in $base -column 1 -row $row -columnspan 1 -rowspan 1 -padx 2 -sticky w                                
+               incr row
+       }
+
+       # does it have a variable attribute ?
+       if {[lsearch {button label radio checkbox entry} $objclass] > -1} {
+               label $base.l$row \
+               -borderwidth 0 -text [intlmsg Variable]
+               entry $base.e$row -textvariable PgAcVar(fdobj,$i,variable) \
+               -background #fefefe -borderwidth 1 -width 200 
+               grid $base.l$row \
+               -in $base -column 0 -row $row -columnspan 1 -rowspan 1 -sticky w 
+               grid $base.e$row \
+               -in $base -column 1 -row $row -columnspan 1 -rowspan 1 -padx 2 \
+               -sticky w                               
+               incr row
+       }
+
+       # does it have a Command attribute ?
+       if {[lsearch {button checkbox} $objclass] > -1} {
+               label $base.l$row \
+               -borderwidth 0 -text [intlmsg Command]
+               entry $base.e$row -textvariable PgAcVar(fdobj,$i,command) \
+               -background #fefefe -borderwidth 1 -width 200 
+               button $base.b$row \
+               -borderwidth 1 -padx 1 -pady 0 -text ... -command "
+                               Window show .pgaw:FormDesign:commands
+                               set PgAcVar(fdvar,commandFor) $i
+                               .pgaw:FormDesign:commands.f.txt delete 1.0 end
+                               .pgaw:FormDesign:commands.f.txt insert end \$PgAcVar(fdobj,$i,command)"
+               grid $base.l$row \
+               -in $base -column 0 -row $row -columnspan 1 -rowspan 1 -sticky w 
+               grid $base.e$row \
+               -in $base -column 1 -row $row -columnspan 1 -rowspan 1 -padx 2 \
+               -sticky w                               
+               grid $base.b$row \
+               -in $base -column 2 -row $row -columnspan 1 -rowspan 1 
+               incr row
+       }
+
+       # does it have a value attribute ?
+       if {[lsearch {radio checkbox} $objclass] > -1} {
+               label $base.l$row \
+               -borderwidth 0 -text [intlmsg Value]
+               entry $base.e$row -textvariable PgAcVar(fdobj,$i,value) \
+               -background #fefefe -borderwidth 1 -width 200 
+               grid $base.l$row \
+               -in $base -column 0 -row $row -columnspan 1 -rowspan 1 -sticky w 
+               grid $base.e$row \
+               -in $base -column 1 -row $row -columnspan 1 -rowspan 1 -padx 2 \
+               -sticky w                               
+               incr row
+       }
+
+       # does it have fonts ?
+       if {[lsearch {label button entry listbox text checkbox radio} $objclass] > -1} {
+               label $base.lfont \
+                       -borderwidth 0 -text [intlmsg Font]
+               grid $base.lfont \
+                       -in $base -column 0 -row $row -columnspan 1 -rowspan 1 -pady 2 -sticky w 
+               entry $base.efont -textvariable PgAcVar(fdobj,$i,font) \
+               -background #fefefe -borderwidth 1 -width 200 
+               bind $base.efont <Key-Return> "Forms::design:draw_object $i ; set PgAcVar(fdvar,dirty) 1"
+               grid $base.efont \
+               -in $base -column 1 -row $row -columnspan 1 -rowspan 1 -padx 2 -sticky w                                
+               menubutton $base.mbf \
+           -borderwidth 1 -menu $base.mbf.m -padx 2 -pady 0 \
+               -text {...}  -font $PgAcVar(pref,font_normal) -relief raised
+               menu $base.mbf.m \
+                       -borderwidth 1 -cursor {} -tearoff 0 -font $PgAcVar(pref,font_normal)
+               foreach font {normal bold italic fixed} {
+                       $base.mbf.m add command \
+               -command "
+                       set PgAcVar(fdobj,$i,font) $font
+                       Forms::design:draw_object $i
+                       set PgAcVar(fdvar,dirty) 1
+               " -label $font
+               }
+               grid $base.mbf \
+                       -in $base -column 2 -row $row -columnspan 1 -rowspan 1 -pady 2 -padx 2 -sticky w 
+               incr row
+       }
+
+       # does it have colors ?
+       if {[lsearch {label button radio checkbox entry listbox text} $objclass] > -1} {
+               label $base.lcf \
+               -borderwidth 0 -text [intlmsg Foreground]
+               label $base.scf \
+               -background $PgAcVar(fdobj,$i,fcolor) -borderwidth 1 -relief sunken -width 200 
+               button $base.bcf \
+                       -command "set tempcolor \[tk_chooseColor -initialcolor $PgAcVar(fdobj,$i,fcolor) -title {Choose color}\] 
+                               if {\$tempcolor != {}} {
+                                       set PgAcVar(fdobj,$i,fcolor) \$tempcolor
+                                       $base.scf configure -background \$PgAcVar(fdobj,$i,fcolor)
+                                       set PgAcVar(fdvar,dirty) 1
+                                       Forms::design:draw_object $i
+                               }" \
+               -borderwidth 1 -padx 1 -pady 0 -text ... 
+               grid $base.lcf \
+               -in $base -column 0 -row $row -columnspan 1 -rowspan 1 -sticky w 
+               grid $base.scf \
+               -in $base -column 1 -row $row -columnspan 1 -rowspan 1 -padx 2 \
+               -sticky w 
+               grid $base.bcf \
+               -in $base -column 2 -row $row -columnspan 1 -rowspan 1 
+               incr row
+               label $base.lcb \
+                       -borderwidth 0 -text Background 
+               label $base.scb \
+                       -background $PgAcVar(fdobj,$i,bcolor) -borderwidth 1 -relief sunken -width 200 
+               button $base.bcb \
+                       -command "set tempcolor \[tk_chooseColor -initialcolor $PgAcVar(fdobj,$i,bcolor) -title {Choose color}\]
+                               if {\$tempcolor != {}} {
+                                       set PgAcVar(fdobj,$i,bcolor) \$tempcolor
+                                       $base.scb configure -background \$PgAcVar(fdobj,$i,bcolor)
+                                       set PgAcVar(fdvar,dirty) 1
+                                       Forms::design:draw_object $i
+                               }" \
+                       -borderwidth 1 -padx 1 -pady 0 -text ... 
+               grid $base.lcb \
+                       -in $base -column 0 -row $row -columnspan 1 -rowspan 1 -sticky w 
+               grid $base.scb \
+                       -in $base -column 1 -row $row -columnspan 1 -rowspan 1 -padx 2 -sticky w 
+               grid $base.bcb \
+                       -in $base -column 2 -row $row -columnspan 1 -rowspan 1
+               incr row
+       }
+
+       # does it have border types ?
+       if {[lsearch {label button entry listbox text} $objclass] > -1} {
+               label $base.lrelief \
+                       -borderwidth 0 -text [intlmsg Relief]
+               grid $base.lrelief \
+                       -in $base -column 0 -row $row -columnspan 1 -rowspan 1 -pady 2 -sticky w 
+               menubutton $base.mb \
+           -borderwidth 2 -menu $base.mb.m -padx 4 -pady 3 -width 100 -relief $PgAcVar(fdobj,$i,relief) \
+               -text groove -textvariable PgAcVar(fdobj,$i,relief) \
+               -font $PgAcVar(pref,font_normal)
+               menu $base.mb.m \
+                       -borderwidth 1 -cursor {} -tearoff 0 -font $PgAcVar(pref,font_normal)
+               foreach brdtype {raised sunken ridge groove flat} {
+                       $base.mb.m add command \
+               -command "
+                       set PgAcVar(fdobj,$i,relief) $brdtype
+                       $base.mb configure -relief \$PgAcVar(fdobj,$i,relief)
+                       Forms::design:draw_object $i
+               " -label $brdtype
+               }
+               grid $base.mb \
+                       -in $base -column 1 -row $row -columnspan 1 -rowspan 1 -pady 2 -padx 2 -sticky w 
+               incr row
+
+       }
+
+       # is it a DataControl ?
+       if {$objclass == "query"} {
+               label $base.l$row \
+               -borderwidth 0 -text [intlmsg SQL]
+               entry $base.e$row -textvariable PgAcVar(fdobj,$i,command) \
+               -background #fefefe -borderwidth 1 -width 200 
+               grid $base.l$row \
+               -in $base -column 0 -row $row -columnspan 1 -rowspan 1 -sticky w 
+               grid $base.e$row \
+               -in $base -column 1 -row $row -columnspan 1 -rowspan 1 -padx 2 \
+               -sticky w                               
+               incr row
+       }
+
+       # does it have a borderwidth attribute ?
+       if {[lsearch {button label radio checkbox entry listbox text} $objclass] > -1} {
+               label $base.l$row \
+               -borderwidth 0 -text [intlmsg {Border width}]
+               entry $base.e$row -textvariable PgAcVar(fdobj,$i,borderwidth) \
+               -background #fefefe -borderwidth 1 -width 200 
+               grid $base.l$row \
+               -in $base -column 0 -row $row -columnspan 1 -rowspan 1 -sticky w 
+               grid $base.e$row \
+               -in $base -column 1 -row $row -columnspan 1 -rowspan 1 -padx 2 \
+               -sticky w                               
+               incr row
+       }
+
+
+       # The last dummy label
+       
+       label $base.ldummy -text {} -borderwidth 0
+       grid $base.ldummy -in $base -column 0 -row 100
+       grid rowconf $base 100 -weight 1
+
+}
+
+
+proc {design:show_attributes} {i} {
+global PgAcVar
+       set objclass $PgAcVar(fdobj,$i,class)
+       set PgAcVar(fdvar,c_class) $objclass
+       design:createAttributesFrame $i
+       set PgAcVar(fdvar,c_name) $PgAcVar(fdobj,$i,name)
+       if {$i == 0} {
+               # Object 0 is the form
+               set c [split [winfo geometry .pgaw:FormDesign:draft] x+]
+               set PgAcVar(fdvar,c_top) [lindex $c 3]
+               set PgAcVar(fdvar,c_left) [lindex $c 2]
+               set PgAcVar(fdvar,c_width) [lindex $c 0]
+               set PgAcVar(fdvar,c_height) [lindex $c 1]
+               return
+       }
+       set c $PgAcVar(fdobj,$i,coord)
+       set PgAcVar(fdvar,c_top) [lindex $c 1]
+       set PgAcVar(fdvar,c_left) [lindex $c 0]
+       set PgAcVar(fdvar,c_width) [expr [lindex $c 2]-[lindex $c 0]]
+       set PgAcVar(fdvar,c_height) [expr [lindex $c 3]-[lindex $c 1]]
+}
+
+
+proc {design:run} {} {
+global PgAcVar CurrentDB DataControlVar
+set base .$PgAcVar(fdobj,0,name)
+if {[winfo exists $base]} {
+   wm deiconify $base; return
+}
+toplevel $base -class Toplevel
+wm focusmodel $base passive
+wm geometry $base $PgAcVar(fdvar,geometry)
+wm maxsize $base 785 570
+wm minsize $base 1 1
+wm overrideredirect $base 0
+wm resizable $base 1 1
+wm deiconify $base
+wm title $base $PgAcVar(fdvar,formtitle)
+foreach item $PgAcVar(fdvar,objlist) {
+set coord $PgAcVar(fdobj,$item,coord)
+set name $PgAcVar(fdobj,$item,name)
+set wh "-width [expr 3+[lindex $coord 2]-[lindex $coord 0]]  -height [expr 3+[lindex $coord 3]-[lindex $coord 1]]"
+set visual 1
+
+set wfont $PgAcVar(fdobj,$item,font)
+switch $wfont {
+       {} {set wfont $PgAcVar(pref,font_normal)}
+       normal  {set wfont $PgAcVar(pref,font_normal)}
+       bold  {set wfont $PgAcVar(pref,font_bold)}
+       italic  {set wfont $PgAcVar(pref,font_italic)}
+       fixed  {set wfont $PgAcVar(pref,font_fix)}
+}
+
+namespace forget ::DataControl($base.$name)
+
+# Checking if relief ridge or groove has borderwidth 2
+if {[lsearch {ridge groove} $PgAcVar(fdobj,$item,relief)] != -1} {
+       if {$PgAcVar(fdobj,$item,borderwidth) < 2} {
+               set PgAcVar(fdobj,$item,borderwidth) 2
+       }
+}
+
+# Checking if borderwidth is okay
+if {[lsearch {0 1 2 3 4 5} $PgAcVar(fdobj,$item,borderwidth)] == -1} {
+       set PgAcVar(fdobj,$item,borderwidth) 1
+}
+
+set cmd {}
+catch {set cmd $PgAcVar(fdobj,$item,command)}
+
+switch $PgAcVar(fdobj,$item,class) {
+       button {
+               button $base.$name  -borderwidth 1 -padx 0 -pady 0 -text "$PgAcVar(fdobj,$item,label)" \
+               -fg $PgAcVar(fdobj,$item,fcolor) -bg $PgAcVar(fdobj,$item,bcolor) \
+               -borderwidth $PgAcVar(fdobj,$item,borderwidth) \
+               -relief $PgAcVar(fdobj,$item,relief) -font $wfont -command [subst {$cmd}]
+               if {$PgAcVar(fdobj,$item,variable) != ""} {
+                       $base.$name configure -textvariable $PgAcVar(fdobj,$item,variable)
+               }
+       }
+       checkbox {
+               checkbutton  $base.$name -onvalue t -offvalue f -font $wfont \
+               -fg $PgAcVar(fdobj,$item,fcolor) \
+               -borderwidth $PgAcVar(fdobj,$item,borderwidth) \
+               -command [subst {$cmd}] \
+               -text "$PgAcVar(fdobj,$item,label)" -variable "$PgAcVar(fdobj,$item,variable)" -borderwidth 1
+               set wh {}
+       }
+       query {
+               set visual 0
+               set DataControlVar($base.$name,sql) $PgAcVar(fdobj,$item,command)
+               namespace eval ::DataControl($base.$name) "proc open {} {
+                       global CurrentDB DataControlVar
+                       variable tuples
+                       catch {unset tuples}
+                       set wn \[focus\] ; setCursor CLOCK
+                       set res \[wpg_exec \$CurrentDB \"\$DataControlVar($base.$name,sql)\"\]
+                       pg_result \$res -assign tuples
+                       set fl {}
+                       foreach fd \[pg_result \$res -lAttributes\] {lappend fl \[lindex \$fd 0\]}
+                       set DataControlVar($base.$name,fields) \$fl
+                       set DataControlVar($base.$name,recno) 0
+                       set DataControlVar($base.$name,nrecs) \[pg_result \$res -numTuples\]
+                       setCursor NORMAL
+               }"
+               namespace eval ::DataControl($base.$name) "proc setSQL {sqlcmd} {
+                       global DataControlVar
+                       set DataControlVar($base.$name,sql) \$sqlcmd
+               }"
+               namespace eval ::DataControl($base.$name) "proc getRowCount {} {
+                       global DataControlVar
+                       return \$DataControlVar($base.$name,nrecs)
+               }"
+               namespace eval ::DataControl($base.$name)  "proc getRowIndex {} {
+                       global DataControlVar
+                       return \$DataControlVar($base.$name,recno)
+               }"
+               namespace eval ::DataControl($base.$name)  "proc moveTo {newrecno} {
+                       global DataControlVar
+                       set DataControlVar($base.$name,recno) \$newrecno
+               }"
+               namespace eval ::DataControl($base.$name) "proc close {} {
+                       variable tuples
+                       catch {unset tuples}
+               }"
+               namespace eval ::DataControl($base.$name)  "proc getFieldList {} {
+                       global DataControlVar
+                       return \$DataControlVar($base.$name,fields)
+               }"
+               namespace eval ::DataControl($base.$name)  "proc fill {lb fld} {
+                       global DataControlVar
+                       variable tuples
+                       \$lb delete 0 end
+                       for {set i 0} {\$i<\$DataControlVar($base.$name,nrecs)} {incr i} {
+                               \$lb insert end \$tuples\(\$i,\$fld\)
+                       }
+               }"
+               namespace eval ::DataControl($base.$name)  "proc moveFirst {} {global DataControlVar ; set DataControlVar($base.$name,recno) 0}"
+               namespace eval ::DataControl($base.$name)  "proc moveNext {} {global DataControlVar ; incr DataControlVar($base.$name,recno) ; if {\$DataControlVar($base.$name,recno)==\[getRowCount\]} {moveLast}}"
+               namespace eval ::DataControl($base.$name)  "proc movePrevious {} {global DataControlVar ; incr DataControlVar($base.$name,recno) -1 ; if {\$DataControlVar($base.$name,recno)==-1} {moveFirst}}"
+               namespace eval ::DataControl($base.$name)  "proc moveLast {} {global DataControlVar ; set DataControlVar($base.$name,recno) \[expr \[getRowCount\] -1\]}"
+               namespace eval ::DataControl($base.$name)  "proc updateDataSet {} {\
+                       global DataControlVar
+                       global DataSet
+                       variable tuples
+                       set i \$DataControlVar($base.$name,recno)
+                       foreach fld \$DataControlVar($base.$name,fields) {
+                               catch {
+                                       upvar DataSet\($base.$name,\$fld\) dbvar
+                                       set dbvar \$tuples\(\$i,\$fld\)
+                               }
+                       }
+               }"
+               namespace eval ::DataControl($base.$name)  "proc clearDataSet {} {
+                       global DataControlVar
+                       global DataSet
+                       catch { foreach fld \$DataControlVar($base.$name,fields) {
+                               catch {
+                                       upvar DataSet\($base.$name,\$fld\) dbvar
+                                       set dbvar {}
+                               }
+                       }}
+               }"
+       }
+       radio {
+               radiobutton  $base.$name -font $wfont -text "$PgAcVar(fdobj,$item,label)" \
+               -fg $PgAcVar(fdobj,$item,fcolor) -bg $PgAcVar(fdobj,$item,bcolor) -variable $PgAcVar(fdobj,$item,variable) \
+               -value $PgAcVar(fdobj,$item,value) -borderwidth 1
+               set wh {}
+       }
+       entry {
+               set var {} ; catch {set var $PgAcVar(fdobj,$item,variable)}
+               entry $base.$name -bg $PgAcVar(fdobj,$item,bcolor) -fg $PgAcVar(fdobj,$item,fcolor) \
+               -borderwidth $PgAcVar(fdobj,$item,borderwidth) -font $wfont \
+               -relief $PgAcVar(fdobj,$item,relief) -selectborderwidth 0  -highlightthickness 0 
+               if {$var!=""} {$base.$name configure -textvar $var}
+       }
+       text {
+               text $base.$name -fg $PgAcVar(fdobj,$item,fcolor) -bg $PgAcVar(fdobj,$item,bcolor) \
+               -relief $PgAcVar(fdobj,$item,relief) -borderwidth $PgAcVar(fdobj,$item,borderwidth) \
+               -font $wfont
+       }
+       label {
+               # set wh {}
+               label $base.$name -font $wfont -anchor nw -padx 0 -pady 0 -text $PgAcVar(fdobj,$item,label) \
+               -borderwidth $PgAcVar(fdobj,$item,borderwidth) \
+               -relief $PgAcVar(fdobj,$item,relief)  -fg $PgAcVar(fdobj,$item,fcolor) -bg $PgAcVar(fdobj,$item,bcolor) 
+               set var {} ; catch {set var $PgAcVar(fdobj,$item,variable)}
+               if {$var!=""} {$base.$name configure -textvar $var}
+       }
+       listbox {
+               listbox $base.$name -bg $PgAcVar(fdobj,$item,bcolor)  -highlightthickness 0 -selectborderwidth 0 \
+               -borderwidth $PgAcVar(fdobj,$item,borderwidth) -relief $PgAcVar(fdobj,$item,relief) \
+               -fg $PgAcVar(fdobj,$item,fcolor) -bg $PgAcVar(fdobj,$item,bcolor) -font $wfont -yscrollcommand [subst {$base.sb$name set}]
+               scrollbar $base.sb$name -borderwidth 1 -command [subst {$base.$name yview}] -orient vert  -highlightthickness 0
+               eval [subst "place $base.sb$name -x [expr [lindex $coord 2]-14] -y [expr [lindex $coord 1]-1] -width 16 -height [expr 3+[lindex $coord 3]-[lindex $coord 1]] -anchor nw -bordermode ignore"]
+       }
+}
+if $visual {eval [subst "place $base.$name  -x [expr [lindex $coord 0]-1] -y [expr [lindex $coord 1]-1] -anchor nw $wh -bordermode ignore"]}
+}
+if {$PgAcVar(fdobj,0,command) != ""} {
+       uplevel #0 $PgAcVar(fdobj,0,command)
+}
+}
+
+proc {design:close} {} {
+global PgAcVar
+       if {$PgAcVar(fdvar,dirty)} {
+               if {[tk_messageBox -title [intlmsg Warning] -message [intlmsg "Do you want to save the form into the database?"] -type yesno -default yes]=="yes"} {
+                       if {[design:save $PgAcVar(fdvar,formtitle)]==0} {return}
+               }
+       }
+       catch {Window destroy .pgaw:FormDesign:draft}
+       catch {Window destroy .pgaw:FormDesign:toolbar}
+       catch {Window destroy .pgaw:FormDesign:menu}
+       catch {Window destroy .pgaw:FormDesign:attributes}
+       catch {Window destroy .pgaw:FormDesign:commands}
+       catch {Window destroy .$PgAcVar(fdobj,0,name)}
+}
+
+}
+
+proc vTclWindow.pgaw:FormDesign:draft {base} {
+       if {$base == ""} {
+               set base .pgaw:FormDesign:draft
+       }
+       if {[winfo exists $base]} {
+               wm deiconify $base; return
+       }
+       toplevel $base -class Toplevel
+       wm focusmodel $base passive
+       wm geometry $base 377x315+50+130
+       wm maxsize $base 785 570
+       wm minsize $base 1 1
+       wm overrideredirect $base 0
+       wm resizable $base 1 1
+       wm deiconify $base
+       wm title $base [intlmsg "Form design"]
+       bind $base <Key-Delete> {
+               Forms::design:delete_object
+       }
+       bind $base <Key-F1> "Help::load form_design"
+       canvas $base.c \
+               -background #a0a0a0 -height 207 -highlightthickness 0 -relief ridge \
+               -selectborderwidth 0 -width 295 
+       bind $base.c <Button-1> {
+               Forms::design:mouse_down %x %y
+       }
+       bind $base.c <ButtonRelease-1> {
+               Forms::design:mouse_up %x %y
+       }
+       bind $base.c <Motion> {
+               Forms::design:mouse_move %x %y
+       }
+       pack $base.c \
+               -in .pgaw:FormDesign:draft -anchor center -expand 1 -fill both -side top
+}
+
+proc vTclWindow.pgaw:FormDesign:attributes {base} {
+       if {$base == ""} {
+               set base .pgaw:FormDesign:attributes
+       }
+       if {[winfo exists $base]} {
+               wm deiconify $base; return
+       }
+       toplevel $base -class Toplevel
+       wm focusmodel $base passive
+       wm geometry $base 237x300+461+221
+       wm maxsize $base 785 570
+       wm minsize $base 1 1
+       wm overrideredirect $base 0
+       wm resizable $base 0 0
+       wm deiconify $base
+       wm title $base [intlmsg "Attributes"]
+
+       # The identification frame
+
+       frame $base.fi \
+        -borderwidth 2 -height 75 -relief groove -width 125 
+       label $base.fi.lclass \
+        -borderwidth 0 -text [intlmsg Class]
+       entry $base.fi.eclass -textvariable PgAcVar(fdvar,c_class) \
+        -borderwidth 1 -width 200 
+       label $base.fi.lname \
+        -borderwidth 0 -text [intlmsg Name]
+       entry $base.fi.ename -textvariable PgAcVar(fdvar,c_name) \
+        -background #fefefe -borderwidth 1 -width 200 
+       bind $base.fi.ename <Key-Return> {
+               Forms::design:set_name
+       }
+
+
+       # The geometry frame
+
+       frame $base.fg \
+        -borderwidth 2 -height 75 -relief groove -width 125 
+       entry $base.fg.e1 -textvariable PgAcVar(fdvar,c_width) \
+        -background #fefefe -borderwidth 1 -width 5 
+       entry $base.fg.e2 -textvariable PgAcVar(fdvar,c_height) \
+        -background #fefefe -borderwidth 1 -width 5 
+       entry $base.fg.e3 -textvariable PgAcVar(fdvar,c_left) \
+        -background #fefefe -borderwidth 1 -width 5 
+       entry $base.fg.e4 -textvariable PgAcVar(fdvar,c_top) \
+        -background #fefefe -borderwidth 1 -width 5 
+       bind $base.fg.e1 <Key-Return> {
+               Forms::design:change_coords
+       }
+       bind $base.fg.e2 <Key-Return> {
+               Forms::design:change_coords
+       }
+       bind $base.fg.e3 <Key-Return> {
+               Forms::design:change_coords
+       }
+       bind $base.fg.e4 <Key-Return> {
+               Forms::design:change_coords
+       }
+       label $base.fg.l1 \
+        -borderwidth 0 -text Width 
+       label $base.fg.l2 \
+        -borderwidth 0 -text Height 
+       label $base.fg.l3 \
+        -borderwidth 0 -text Left 
+       label $base.fg.l4 \
+        -borderwidth 0 -text Top 
+       label $base.fg.lx1 \
+        -borderwidth 0 -text x 
+       label $base.fg.lp1 \
+        -borderwidth 0 -text + 
+       label $base.fg.lp2 \
+        -borderwidth 0 -text + 
+
+       # The frame for the rest of the attributes (dynamically generated)
+
+       
+       frame $base.f \
+        -borderwidth 2 -height 75 -relief groove -width 125 
+
+
+       # Geometry for "identification frame"
+
+
+       place $base.fi \
+        -x 5 -y 5 -width 230 -height 55 -anchor nw -bordermode ignore 
+       grid columnconf $base.fi 1 -weight 1
+       grid $base.fi.lclass \
+        -in $base.fi -column 0 -row 0 -columnspan 1 -rowspan 1 -sticky w 
+       grid $base.fi.eclass \
+        -in $base.fi -column 1 -row 0 -columnspan 1 -rowspan 1 -padx 2 \
+        -sticky w 
+       grid $base.fi.lname \
+        -in $base.fi -column 0 -row 1 -columnspan 1 -rowspan 1 -sticky w 
+       grid $base.fi.ename \
+        -in $base.fi -column 1 -row 1 -columnspan 1 -rowspan 1 -padx 2 \
+        -sticky w 
+
+
+
+       # Geometry for "geometry frame"
+
+       place $base.fg \
+        -x 5 -y 60 -width 230 -height 45 -anchor nw -bordermode ignore 
+       grid $base.fg.e1 \
+        -in $base.fg -column 0 -row 0 -columnspan 1 -rowspan 1 
+       grid $base.fg.e2 \
+        -in $base.fg -column 2 -row 0 -columnspan 1 -rowspan 1 
+       grid $base.fg.e3 \
+        -in $base.fg -column 4 -row 0 -columnspan 1 -rowspan 1 
+       grid $base.fg.e4 \
+        -in $base.fg -column 6 -row 0 -columnspan 1 -rowspan 1 
+       grid $base.fg.l1 \
+        -in $base.fg -column 0 -row 1 -columnspan 1 -rowspan 1 
+       grid $base.fg.l2 \
+        -in $base.fg -column 2 -row 1 -columnspan 1 -rowspan 1 
+       grid $base.fg.l3 \
+        -in $base.fg -column 4 -row 1 -columnspan 1 -rowspan 1 
+       grid $base.fg.l4 \
+        -in $base.fg -column 6 -row 1 -columnspan 1 -rowspan 1 
+       grid $base.fg.lx1 \
+        -in $base.fg -column 1 -row 0 -columnspan 1 -rowspan 1 
+       grid $base.fg.lp1 \
+        -in $base.fg -column 5 -row 0 -columnspan 1 -rowspan 1 
+       grid $base.fg.lp2 \
+        -in $base.fg -column 3 -row 0 -columnspan 1 -rowspan 1 
+
+       place $base.f -x 5 -y 105 -width 230 -height 190 -anchor nw
+
+}
+
+
+proc vTclWindow.pgaw:FormDesign:commands {base} {
+global PgAcVar
+       if {$base == ""} {
+               set base .pgaw:FormDesign:commands
+       }
+       if {[winfo exists $base]} {
+               wm deiconify $base; return
+       }
+       toplevel $base -class Toplevel
+       wm focusmodel $base passive
+       wm geometry $base 640x480+120+100
+       wm maxsize $base 785 570
+       wm minsize $base 1 19
+       wm overrideredirect $base 0
+       wm resizable $base 1 1
+       wm title $base [intlmsg "Command"]
+       frame $base.f \
+               -borderwidth 2 -height 75 -relief groove -width 125 
+       scrollbar $base.f.sb \
+               -borderwidth 1 -command {.pgaw:FormDesign:commands.f.txt yview} -orient vert -width 12 
+       text $base.f.txt \
+               -font $PgAcVar(pref,font_fix) -height 1 -tabs {20 40 60 80 100 120 140 160 180 200} \
+               -width 200 -yscrollcommand {.pgaw:FormDesign:commands.f.sb set} 
+       frame $base.fb \
+               -height 75 -width 125 
+       button $base.fb.b1 \
+               -borderwidth 1 \
+               -command {
+                       set PgAcVar(fdobj,$PgAcVar(fdvar,commandFor),command) [.pgaw:FormDesign:commands.f.txt get 1.0 "end - 1 chars"]
+                       Window hide .pgaw:FormDesign:commands
+                       set PgAcVar(fdvar,dirty) 1
+               } -text [intlmsg Save] -width 5 
+       button $base.fb.b2 \
+               -borderwidth 1 -command {Window hide .pgaw:FormDesign:commands} \
+               -text [intlmsg Cancel]
+       pack $base.f \
+               -in .pgaw:FormDesign:commands -anchor center -expand 1 -fill both -side top 
+       pack $base.f.sb \
+               -in .pgaw:FormDesign:commands.f -anchor e -expand 1 -fill y -side right 
+       pack $base.f.txt \
+               -in .pgaw:FormDesign:commands.f -anchor center -expand 1 -fill both -side top 
+       pack $base.fb \
+               -in .pgaw:FormDesign:commands -anchor center -expand 0 -fill none -side top 
+       pack $base.fb.b1 \
+               -in .pgaw:FormDesign:commands.fb -anchor center -expand 0 -fill none -side left 
+       pack $base.fb.b2 \
+               -in .pgaw:FormDesign:commands.fb -anchor center -expand 0 -fill none -side top 
+}
+
+proc vTclWindow.pgaw:FormDesign:menu {base} {
+       if {$base == ""} {
+               set base .pgaw:FormDesign:menu
+       }
+       if {[winfo exists $base]} {
+               wm deiconify $base; return
+       }
+       toplevel $base -class Toplevel
+       wm focusmodel $base passive
+       wm geometry $base 432x74+0+0
+       wm maxsize $base 1009 738
+       wm minsize $base 1 1
+       wm overrideredirect $base 0
+       wm resizable $base 0 0
+       wm deiconify $base
+       wm title $base [intlmsg "Form designer"]
+       frame $base.f1 \
+               -height 75 -relief groove -width 125 
+       label $base.f1.l1 \
+               -borderwidth 0 -text "[intlmsg {Form name}] "
+       entry $base.f1.e1 \
+               -background #fefefe -borderwidth 1 -textvariable PgAcVar(fdvar,formtitle) 
+       frame $base.f2 \
+               -height 75 -relief groove -width 125 
+       label $base.f2.l \
+               -borderwidth 0 -text "[intlmsg {Form's window internal name}] "
+       entry $base.f2.e \
+               -background #fefefe -borderwidth 1 -textvariable PgAcVar(fdobj,0,name) 
+       frame $base.f3 \
+               -height 1 -width 125 
+       button $base.f3.b1 \
+               -command {set PgAcVar(fdvar,geometry) [wm geometry .pgaw:FormDesign:draft] ; Forms::design:run} -padx 1 \
+               -text [intlmsg {Test form}]
+       button $base.f3.b2 \
+               -command {destroy .$PgAcVar(fdobj,0,name)} -padx 1 \
+               -text [intlmsg {Close test form}]
+       button $base.f3.b3 \
+               -command {Forms::design:save nimic} -padx 1 -text [intlmsg Save]
+       button $base.f3.b4 \
+               -command {Forms::design:close} \
+               -padx 1 -text [intlmsg Close]
+       pack $base.f1 \
+               -in .pgaw:FormDesign:menu -anchor center -expand 0 -fill x -pady 2 -side top 
+       pack $base.f1.l1 \
+               -in .pgaw:FormDesign:menu.f1 -anchor center -expand 0 -fill none -side left 
+       pack $base.f1.e1 \
+               -in .pgaw:FormDesign:menu.f1 -anchor center -expand 1 -fill x -side left 
+       pack $base.f2 \
+               -in .pgaw:FormDesign:menu -anchor center -expand 0 -fill x -pady 1 -side top 
+       pack $base.f2.l \
+               -in .pgaw:FormDesign:menu.f2 -anchor center -expand 0 -fill none -side left 
+       pack $base.f2.e \
+               -in .pgaw:FormDesign:menu.f2 -anchor center -expand 1 -fill x -side left 
+       pack $base.f3 \
+               -in .pgaw:FormDesign:menu -anchor center -expand 0 -fill x -pady 2 -side bottom 
+       pack $base.f3.b1 \
+               -in .pgaw:FormDesign:menu.f3 -anchor center -expand 0 -fill none -side left 
+       pack $base.f3.b2 \
+               -in .pgaw:FormDesign:menu.f3 -anchor center -expand 0 -fill none -side left 
+       pack $base.f3.b3 \
+               -in .pgaw:FormDesign:menu.f3 -anchor center -expand 0 -fill none -side left 
+       pack $base.f3.b4 \
+               -in .pgaw:FormDesign:menu.f3 -anchor center -expand 0 -fill none -side right 
+}
+
+
+proc vTclWindow.pgaw:FormDesign:toolbar {base} {
+global PgAcVar
+       foreach wid {button frame radiobutton checkbutton label text entry listbox query} {
+               image create photo "icon_$wid"  -file [file join $PgAcVar(PGACCESS_HOME) images icon_$wid.gif] 
+       }
+       if {$base == ""} {
+               set base .pgaw:FormDesign:toolbar
+       }
+       if {[winfo exists $base]} {
+               wm deiconify $base; return
+       }
+       toplevel $base -class Toplevel -menu .pgaw:FormDesign:toolbar.m17 
+       wm focusmodel $base passive
+       wm geometry $base 29x235+1+130
+       wm maxsize $base 1009 738
+       wm minsize $base 1 1
+       wm overrideredirect $base 0
+       wm resizable $base 0 0
+       wm deiconify $base
+       wm title $base [intlmsg "Toolbar"]
+       button $base.b1 \
+               -borderwidth 1 -command {set PgAcVar(fdvar,tool) button} -image icon_button \
+               -padx 9 -pady 3 
+       button $base.b3 \
+               -borderwidth 1 -command {set PgAcVar(fdvar,tool) radio} \
+               -image icon_radiobutton -padx 9 -pady 3 
+       button $base.b4 \
+               -borderwidth 1 -command {set PgAcVar(fdvar,tool) checkbox} \
+               -image icon_checkbutton -padx 9 -pady 3 
+       button $base.b5 \
+               -borderwidth 1 -command {set PgAcVar(fdvar,tool) label} -image icon_label \
+               -padx 9 -pady 3 
+       button $base.b6 \
+               -borderwidth 1 -command {set PgAcVar(fdvar,tool) text} -image icon_text \
+               -padx 9 -pady 3 
+       button $base.b7 \
+               -borderwidth 1 -command {set PgAcVar(fdvar,tool) entry} -image icon_entry \
+               -padx 9 -pady 3 
+       button $base.b8 \
+               -borderwidth 1 -command {set PgAcVar(fdvar,tool) listbox} -image icon_listbox \
+               -padx 9 -pady 3 
+       button $base.b9 \
+               -borderwidth 1 -command {set PgAcVar(fdvar,tool) query} -height 21 \
+               -image icon_query -padx 9 -pady 3 -width 20 
+       grid $base.b1 \
+               -in .pgaw:FormDesign:toolbar -column 0 -row 2 -columnspan 1 -rowspan 1 
+       grid $base.b3 \
+               -in .pgaw:FormDesign:toolbar -column 0 -row 4 -columnspan 1 -rowspan 1 
+       grid $base.b4 \
+               -in .pgaw:FormDesign:toolbar -column 0 -row 5 -columnspan 1 -rowspan 1 
+       grid $base.b5 \
+               -in .pgaw:FormDesign:toolbar -column 0 -row 0 -columnspan 1 -rowspan 1 
+       grid $base.b6 \
+               -in .pgaw:FormDesign:toolbar -column 0 -row 6 -columnspan 1 -rowspan 1 
+       grid $base.b7 \
+               -in .pgaw:FormDesign:toolbar -column 0 -row 1 -columnspan 1 -rowspan 1 
+       grid $base.b8 \
+               -in .pgaw:FormDesign:toolbar -column 0 -row 7 -columnspan 1 -rowspan 1 
+       grid $base.b9 \
+               -in .pgaw:FormDesign:toolbar -column 0 -row 8 -columnspan 2 -rowspan 3 
+}
+
diff --git a/src/bin/pgaccess/lib/functions.tcl b/src/bin/pgaccess/lib/functions.tcl
new file mode 100644 (file)
index 0000000..96e4860
--- /dev/null
@@ -0,0 +1,181 @@
+namespace eval Functions {
+
+proc {new} {} {
+global PgAcVar
+       Window show .pgaw:Function
+       set PgAcVar(function,name) {}
+       set PgAcVar(function,nametodrop) {}
+       set PgAcVar(function,parameters) {}
+       set PgAcVar(function,returns) {}
+       set PgAcVar(function,language) {}
+       .pgaw:Function.fs.text1 delete 1.0 end
+       focus .pgaw:Function.fp.e1
+       wm transient .pgaw:Function .pgaw:Main
+}
+
+
+proc {design} {functionname} {
+global PgAcVar CurrentDB
+       Window show .pgaw:Function
+       .pgaw:Function.fs.text1 delete 1.0 end
+       wpg_select $CurrentDB "select * from pg_proc where proname='$functionname'" rec {
+               set PgAcVar(function,name) $functionname
+               set temppar $rec(proargtypes)
+               set PgAcVar(function,returns) [Database::getPgType $rec(prorettype)]
+               set funcnrp $rec(pronargs)
+               set prolanguage $rec(prolang)
+               .pgaw:Function.fs.text1 insert end $rec(prosrc)
+       }
+       wpg_select $CurrentDB "select lanname from pg_language where oid=$prolanguage" rec {
+               set PgAcVar(function,language) $rec(lanname)
+       }
+       if { $PgAcVar(function,language)=="C" || $PgAcVar(function,language)=="c" } {
+           wpg_select $CurrentDB "select probin from pg_proc where proname='$functionname'" rec {
+               .pgaw:Function.fs.text1 delete 1.0 end
+               .pgaw:Function.fs.text1 insert end $rec(probin)
+           }
+       }
+       set PgAcVar(function,parameters) {}
+       for {set i 0} {$i<$funcnrp} {incr i} {
+               lappend PgAcVar(function,parameters) [Database::getPgType [lindex $temppar $i]]
+       }
+       set PgAcVar(function,parameters) [join $PgAcVar(function,parameters) ,]
+       set PgAcVar(function,nametodrop) "$PgAcVar(function,name) ($PgAcVar(function,parameters))"
+}
+
+
+proc {save} {} {
+global PgAcVar
+       if {$PgAcVar(function,name)==""} {
+               focus .pgaw:Function.fp.e1
+               showError [intlmsg "You must supply a name for this function!"]
+       } elseif {$PgAcVar(function,returns)==""} {
+               focus .pgaw:Function.fp.e3
+               showError [intlmsg "You must supply a return type!"]
+       } elseif {$PgAcVar(function,language)==""} {
+               focus .pgaw:Function.fp.e4
+               showError [intlmsg "You must supply the function language!"]
+       } else {
+               set funcbody [.pgaw:Function.fs.text1 get 1.0 end]
+               regsub -all "\n" $funcbody " " funcbody
+               if {$PgAcVar(function,nametodrop) != ""} {
+                       if {! [sql_exec noquiet "drop function $PgAcVar(function,nametodrop)"]} {
+                               return
+                       }
+               }
+               if {[sql_exec noquiet "create function $PgAcVar(function,name) ($PgAcVar(function,parameters)) returns $PgAcVar(function,returns) as '$funcbody' language '$PgAcVar(function,language)'"]} {
+                       Window destroy .pgaw:Function
+                       tk_messageBox -title PostgreSQL -parent .pgaw:Main -message [intlmsg "Function saved!"]
+                       Mainlib::tab_click Functions
+               }                                               
+       }
+}
+
+}
+
+proc vTclWindow.pgaw:Function {base} {
+global PgAcVar
+       if {$base == ""} {
+               set base .pgaw:Function
+       }
+       if {[winfo exists $base]} {
+               wm deiconify $base; return
+       }
+       toplevel $base -class Toplevel
+       wm focusmodel $base passive
+       wm geometry $base 480x330+98+212
+       wm maxsize $base 1009 738
+       wm minsize $base 480 330
+       wm overrideredirect $base 0
+       wm resizable $base 1 1
+       wm deiconify $base
+       wm title $base [intlmsg "Function"]
+       bind $base <Key-F1> "Help::load functions"
+       frame $base.fp \
+               -height 88 -relief groove -width 125 
+       label $base.fp.l1 \
+               -borderwidth 0 -relief raised -text [intlmsg Name]
+       entry $base.fp.e1 \
+               -background #fefefe -borderwidth 1 -textvariable PgAcVar(function,name) 
+       bind $base.fp.e1 <Key-Return> {
+               focus .pgaw:Function.fp.e2
+       }
+       label $base.fp.l2 \
+               -borderwidth 0 -relief raised -text [intlmsg Parameters]
+       entry $base.fp.e2 \
+               -background #fefefe -borderwidth 1 -textvariable PgAcVar(function,parameters) -width 15 
+       bind $base.fp.e2 <Key-Return> {
+               focus .pgaw:Function.fp.e3
+       }
+       label $base.fp.l3 \
+               -borderwidth 0 -relief raised -text [intlmsg Returns]
+       entry $base.fp.e3 \
+               -background #fefefe -borderwidth 1 -textvariable PgAcVar(function,returns) 
+       bind $base.fp.e3 <Key-Return> {
+               focus .pgaw:Function.fp.e4
+       }
+       label $base.fp.l4 \
+               -borderwidth 0 -relief raised -text [intlmsg Language]
+       entry $base.fp.e4 \
+               -background #fefefe -borderwidth 1 -textvariable PgAcVar(function,language) -width 15 
+       bind $base.fp.e4 <Key-Return> {
+               focus .pgaw:Function.fs.text1
+       }
+       label $base.fp.lspace \
+               -borderwidth 0 -relief raised -text {    } 
+       frame $base.fs \
+               -borderwidth 2 -height 75 -relief groove -width 125 
+       text $base.fs.text1 \
+               -background #fefefe -foreground #000000 -borderwidth 1 -font $PgAcVar(pref,font_fix) -height 16 \
+               -tabs {20 40 60 80 100 120} -width 43 -yscrollcommand {.pgaw:Function.fs.vsb set} 
+       scrollbar $base.fs.vsb \
+               -borderwidth 1 -command {.pgaw:Function.fs.text1 yview} -orient vert 
+       frame $base.fb \
+               -borderwidth 2 -height 75 -width 125 
+       frame $base.fb.fbc \
+               -borderwidth 2 -height 75 -width 125 
+       button $base.fb.fbc.btnsave -command {Functions::save} \
+               -borderwidth 1 -padx 9 -pady 3 -text [intlmsg Save]
+       button $base.fb.fbc.btnhelp -command {Help::load functions} \
+               -borderwidth 1 -padx 9 -pady 3 -text [intlmsg Help]
+       button $base.fb.fbc.btncancel \
+               -borderwidth 1 -command {Window destroy .pgaw:Function} -padx 9 -pady 3 \
+               -text [intlmsg Cancel]
+       pack $base.fp \
+               -in .pgaw:Function -anchor center -expand 0 -fill x -side top 
+       grid $base.fp.l1 \
+               -in .pgaw:Function.fp -column 0 -row 0 -columnspan 1 -rowspan 1 -sticky w 
+       grid $base.fp.e1 \
+               -in .pgaw:Function.fp -column 1 -row 0 -columnspan 1 -rowspan 1 
+       grid $base.fp.l2 \
+               -in .pgaw:Function.fp -column 3 -row 0 -columnspan 1 -rowspan 1 -sticky w 
+       grid $base.fp.e2 \
+               -in .pgaw:Function.fp -column 4 -row 0 -columnspan 1 -rowspan 1 -pady 2 
+       grid $base.fp.l3 \
+               -in .pgaw:Function.fp -column 0 -row 4 -columnspan 1 -rowspan 1 -sticky w 
+       grid $base.fp.e3 \
+               -in .pgaw:Function.fp -column 1 -row 4 -columnspan 1 -rowspan 1 
+       grid $base.fp.l4 \
+               -in .pgaw:Function.fp -column 3 -row 4 -columnspan 1 -rowspan 1 -sticky w 
+       grid $base.fp.e4 \
+               -in .pgaw:Function.fp -column 4 -row 4 -columnspan 1 -rowspan 1 -pady 3 
+       grid $base.fp.lspace \
+               -in .pgaw:Function.fp -column 2 -row 4 -columnspan 1 -rowspan 1 
+       pack $base.fs \
+               -in .pgaw:Function -anchor center -expand 1 -fill both -side top 
+       pack $base.fs.text1 \
+               -in .pgaw:Function.fs -anchor center -expand 1 -fill both -side left 
+       pack $base.fs.vsb \
+               -in .pgaw:Function.fs -anchor center -expand 0 -fill y -side right 
+       pack $base.fb \
+               -in .pgaw:Function -anchor center -expand 0 -fill x -side bottom 
+       pack $base.fb.fbc \
+               -in .pgaw:Function.fb -anchor center -expand 0 -fill none -side top 
+       pack $base.fb.fbc.btnsave \
+               -in .pgaw:Function.fb.fbc -anchor center -expand 0 -fill none -side left 
+       pack $base.fb.fbc.btnhelp \
+               -in .pgaw:Function.fb.fbc -anchor center -expand 0 -fill none -side left 
+       pack $base.fb.fbc.btncancel \
+               -in .pgaw:Function.fb.fbc -anchor center -expand 0 -fill none -side right 
+}
+
diff --git a/src/bin/pgaccess/lib/help.tcl b/src/bin/pgaccess/lib/help.tcl
new file mode 100644 (file)
index 0000000..87f6570
--- /dev/null
@@ -0,0 +1,127 @@
+namespace eval Help {
+
+proc {findLink} {} {
+       foreach tagname [.pgaw:Help.f.t tag names current] {
+               if {$tagname!="link"} {
+                       load $tagname
+                       return
+               }
+       }
+}
+
+
+proc {load} {topic args} {
+global PgAcVar
+       if {![winfo exists .pgaw:Help]} {
+               Window show .pgaw:Help
+               tkwait visibility .pgaw:Help
+       }
+       wm deiconify .pgaw:Help
+       if {![info exists PgAcVar(help,history)]} {
+               set PgAcVar(help,history) {}
+       }
+       if {[llength $args]==1} {
+               set PgAcVar(help,current_topic) [lindex $args 0]
+               set PgAcVar(help,history) [lrange $PgAcVar(help,history) 0 [lindex $args 0]]
+       } else {
+               lappend PgAcVar(help,history) $topic
+               set PgAcVar(help,current_topic) [expr {[llength $PgAcVar(help,history)]-1}]
+       }
+       # Limit the history length to 100 topics
+       if {[llength $PgAcVar(help,history)]>100} {
+               set PgAcVar(help,history) [lrange $PgAcVar(help,history) 1 end]
+       }
+
+       .pgaw:Help.f.t configure -state normal
+       .pgaw:Help.f.t delete 1.0 end
+       .pgaw:Help.f.t tag configure bold -font $PgAcVar(pref,font_bold)
+       .pgaw:Help.f.t tag configure italic -font $PgAcVar(pref,font_italic)
+       .pgaw:Help.f.t tag configure large -font {Helvetica -14 bold}
+       .pgaw:Help.f.t tag configure title -font $PgAcVar(pref,font_bold) -justify center
+       .pgaw:Help.f.t tag configure link -font {Helvetica -12 underline} -foreground #000080
+       .pgaw:Help.f.t tag configure code -font $PgAcVar(pref,font_fix)
+       .pgaw:Help.f.t tag configure warning -font $PgAcVar(pref,font_bold) -foreground #800000
+       .pgaw:Help.f.t tag bind link <Button-1> {Help::findLink}
+       set errmsg {}
+       .pgaw:Help.f.t configure -tabs {30 60 90 120 150 180 210 240 270 300 330 360 390}
+       catch { source [file join $PgAcVar(PGACCESS_HOME) lib help $topic.hlp] } errmsg
+       if {$errmsg!=""} {
+               .pgaw:Help.f.t insert end "Error loading help file [file join $PgAcVar(PGACCESS_HOME) $topic.hlp]\n\n$errmsg" bold
+       }
+       .pgaw:Help.f.t configure -state disabled
+       focus .pgaw:Help.f.sb
+}
+
+proc {back} {} {
+global PgAcVar
+       if {![info exists PgAcVar(help,history)]} {return}
+       if {[llength $PgAcVar(help,history)]==0} {return}
+       set i $PgAcVar(help,current_topic)
+       if {$i<1} {return}
+       incr i -1
+       load [lindex $PgAcVar(help,history) $i] $i
+}
+
+
+}
+
+proc vTclWindow.pgaw:Help {base} {
+global PgAcVar
+       if {$base == ""} {
+               set base .pgaw:Help
+       }
+       if {[winfo exists $base]} {
+               wm deiconify $base; return
+       }
+       toplevel $base -class Toplevel
+       wm focusmodel $base passive
+       set sw [winfo screenwidth .]
+       set sh [winfo screenheight .]
+       set x [expr {($sw - 640)/2}]
+       set y [expr {($sh - 480)/2}] 
+       wm geometry $base 640x480+$x+$y
+       wm maxsize $base 1009 738
+       wm minsize $base 1 1
+       wm overrideredirect $base 0
+       wm resizable $base 1 1
+       wm deiconify $base
+       wm title $base [intlmsg "Help"]
+       bind $base <Key-Escape> "Window destroy .pgaw:Help"
+       frame $base.fb \
+               -borderwidth 2 -height 75 -relief groove -width 125 
+       button $base.fb.bback \
+               -command Help::back -padx 9 -pady 3 -text [intlmsg Back]
+       button $base.fb.bi \
+               -command {Help::load index} -padx 9 -pady 3 -text [intlmsg Index]
+       button $base.fb.bp \
+               -command {Help::load postgresql} -padx 9 -pady 3 -text PostgreSQL 
+       button $base.fb.btnclose \
+               -command {Window destroy .pgaw:Help} -padx 9 -pady 3 -text [intlmsg Close]
+       frame $base.f \
+               -borderwidth 2 -height 75 -relief groove -width 125 
+       text $base.f.t \
+               -borderwidth 1 -cursor {} -font $PgAcVar(pref,font_normal) -height 2 \
+               -highlightthickness 0 -state disabled \
+               -tabs {30 60 90 120 150 180 210 240 270 300 330 360 390} -width 8 \
+               -wrap word -yscrollcommand {.pgaw:Help.f.sb set} 
+       scrollbar $base.f.sb \
+               -borderwidth 1 -command {.pgaw:Help.f.t yview} -highlightthickness 0 \
+               -orient vert 
+       pack $base.fb \
+               -in .pgaw:Help -anchor center -expand 0 -fill x -side top 
+       pack $base.fb.bback \
+               -in .pgaw:Help.fb -anchor center -expand 0 -fill none -side left 
+       pack $base.fb.bi \
+               -in .pgaw:Help.fb -anchor center -expand 0 -fill none -side left 
+       pack $base.fb.bp \
+               -in .pgaw:Help.fb -anchor center -expand 0 -fill none -side left 
+       pack $base.fb.btnclose \
+               -in .pgaw:Help.fb -anchor center -expand 0 -fill none -side right 
+       pack $base.f \
+               -in .pgaw:Help -anchor center -expand 1 -fill both -side top 
+       pack $base.f.t \
+               -in .pgaw:Help.f -anchor center -expand 1 -fill both -side left 
+       pack $base.f.sb \
+               -in .pgaw:Help.f -anchor center -expand 0 -fill y -side right 
+}
+
diff --git a/src/bin/pgaccess/lib/help/abort.hlp b/src/bin/pgaccess/lib/help/abort.hlp
new file mode 100644 (file)
index 0000000..f7cb4ce
--- /dev/null
@@ -0,0 +1,10 @@
+.pgaw:Help.f.t insert end \
+"ABORT" {bold} " rolls back the current transaction and causes all the updates made by the transaction to be discarded. This command is identical in behavior to the SQL92 command ROLLBACK, and is present only for historical reasons.
+
+" {} "Synopsis" {bold} "
+
+" {} "ABORT" {code} "
+
+" {} "Compatibility SQL92" {bold} "
+
+This command is a Postgres extension present for historical reasons. " {} "ROLLBACK" {bold} " is the SQL92 equivalent command."
diff --git a/src/bin/pgaccess/lib/help/add_records.hlp b/src/bin/pgaccess/lib/help/add_records.hlp
new file mode 100644 (file)
index 0000000..4ece31e
--- /dev/null
@@ -0,0 +1,7 @@
+.pgaw:Help.f.t insert end \
+"Adding new records to an existing table" {bold} "
+
+  " {} "Open a table for viewing and editing" {link open_table} " and move to the end of the displayed records using the vertical scrollbar. You will find there a single row containing only * characters. Click with the mouse on a field and start edit the new record. Move through the fields using Tab and Shift-Tab.
+  The new record will be saved into the database when you will select another record (or press on the mouse right-button).
+"  
+
diff --git a/src/bin/pgaccess/lib/help/alter_table.hlp b/src/bin/pgaccess/lib/help/alter_table.hlp
new file mode 100644 (file)
index 0000000..84b83b3
--- /dev/null
@@ -0,0 +1,30 @@
+.pgaw:Help.f.t insert end "ALTER TABLE" {bold} " changes the definition of an existing table. The new columns and their types are specified in the same style and with the the same restrictions as in CREATE TABLE. The RENAME clause causes the name of a table or column to change without changing any of the data contained in the affected table. Thus, the table or column will remain of the same type and size after this command is executed.
+
+" {} "Synopsis" {bold} "
+
+ALTER TABLE table \[ * \] ADD \[ COLUMN \] column type
+ALTER TABLE table \[ * \] RENAME \[ COLUMN \] column TO newcolumn
+ALTER TABLE table RENAME TO newtable
+
+" {code} "table" {italic} "
+       The name of an existing table to alter.
+
+" {} "column" {italic} "
+       Name of a new or existing column.
+
+" {} "type " {italic} "
+       Type of the new column.
+
+" {} "newcolumn " {italic} "
+       New name for an existing column.
+
+" {} "newtable " {italic} "
+       New name for an existing column.
+       
+You must own the table in order to change its schema.
+
+" {} "Notes:" {italic} " The keyword COLUMN is noise and can be omitted.
+
+\"\[*\]\" following a name of a table indicates that statement should be run over that table and all tables below it in the inheritance hierarchy. The PostgreSQL User's Guide has further information on inheritance.
+
+Refer to " {} "CREATE TABLE" {link create_table} " for a further description of valid arguments."
diff --git a/src/bin/pgaccess/lib/help/alter_user.hlp b/src/bin/pgaccess/lib/help/alter_user.hlp
new file mode 100644 (file)
index 0000000..89da51f
--- /dev/null
@@ -0,0 +1,49 @@
+.pgaw:Help.f.t insert end "ALTER USER" {bold} " is used to change the attributes of a user's Postgres account. Please note that \
+it is not possible to alter a user's " {} "usesysid" {bold} " via the alter user statement. Also, it is only possible for \
+the Postgres user or any user with read and modify permissions on " {} "pg_shadow" {bold} " to alter user passwords. \
+If any of the clauses of the alter user statement are omitted, the corresponding value in the " {} "pg_shadow" {bold} " table is left unchanged. \
+
+" {} "Synopsis" {bold} "
+
+ALTER USER username
+    \[ WITH PASSWORD password \]
+    \[ CREATEDB | NOCREATEDB \]
+    \[ CREATEUSER | NOCREATEUSER \]
+    \[ IN GROUP groupname \[, ...\] \]
+    \[ VALID UNTIL 'abstime' \]
+    
+
+" {code} "Inputs" {bold} "
+Refer to CREATE USER for a detailed description of each clause. 
+
+" {} "username" {italic} "
+       The Postgres account name of the user whose details are to be altered. 
+
+" {} "password" {italic} "
+       The new password to be used for this account. 
+
+" {} "groupname" {italic} "
+       The name of an access group into which this account is to be put. 
+
+" {} "abstime" {italic} "
+       The date (and, optionally, the time) at which this user's access is to be terminated. 
+
+" {} "Outputs" {bold} "
+
+" {} "ALTER USER" {italic} "
+       Message returned if the alteration was successful.
+
+" {} "ERROR: alterUser: user 'username' does not exist" {italic} "
+       Error message returned if the user specified doesn't exist.
+
+" {} "Notes" {italic} "
+
+" {} "ALTER USER" {bold} " statement is a Postgres language extension. 
+Refer to CREATE/DROP USER to create or remove a user account. 
+In the current release (v6.5), the IN GROUP clause is parsed but has no affect. When it is fully implemented, it is intended to modify the pg_group relation.
+
+" {} "Compatibility" {bold} "
+
+SQL92 
+There is no ALTER USER statement in SQL92. The standard leaves the definition of users to the \
+implementation." 
diff --git a/src/bin/pgaccess/lib/help/author.hlp b/src/bin/pgaccess/lib/help/author.hlp
new file mode 100644 (file)
index 0000000..bea532a
--- /dev/null
@@ -0,0 +1,12 @@
+.pgaw:Help.f.t insert end \
+"The author of PgAccess\n" {title} \
+"
+   My name is Constantin Teodorescu, I'm 36 years old, I have graduated the Faculty of Computers and Automation Bucharest, ROMANIA, I have a 16 year experience in developing applications in various languages, Pascal, C, C++, Visual Basic, Delphi, Perl , Tcl/Tk and Java for different platforms. Currently working as a manager of a team that works in Unix with Java , SQL databases (Oracle, SYBASE) currently using PostgreSQL database for developing professional client/server multi-platform applications (standalone Java or Tcl/Tk ,Java applets) for different customers and various projects (accounting, invoicing, stock inventory).
+
+   In present I am the technical manager of FLEX Consulting Braila, a computer shop, software company, networking designer and consultant, ISP provider for Braila city. I'm also a columnist in the romanian technical magazine \"PC-Magazine\" and \"BYTE\".
+
+   I have discovered PostgreSQL in 1995 and from the first moment I decided to help it's development writting PgAccess, a graphical interface.
+
+   The work has been done using Visual Tcl, in my opinion the best tool for developing Tcl/Tk projects. Visual Tcl is free, more information at http://www.neuron.com/stewart/vtcl/index.html
+
+   I'm waiting for any suggestions at e-mail address teo@flex.ro"
diff --git a/src/bin/pgaccess/lib/help/begin.hlp b/src/bin/pgaccess/lib/help/begin.hlp
new file mode 100644 (file)
index 0000000..21f65fa
--- /dev/null
@@ -0,0 +1,35 @@
+.pgaw:Help.f.t insert end "BEGIN" {bold} "
+By default, Postgres executes transactions in unchained mode (also known as " {} "autocommit" {bold} " in other database systems). In other words, each user statement is executed in its own transaction \
+and a commit is implicitly performed at the end of the statement (if execution was successful, otherwise a rollback is done). BEGIN initiates a user transaction in chained mode, i.e. all user \
+statements after BEGIN command will be executed in a single transaction until an explicit COMMIT, ROLLBACK or execution abort. Statements in chained mode are executed much faster, \
+because transaction start/commit requires significant CPU and disk activity. Execution of multiple statements inside a transaction is also required for consistency when changing several related \
+tables. \
+The default transaction isolation level in Postgres is READ COMMITTED, where queries inside the transaction see only changes committed before query execution. So, you have to use SET \
+TRANSACTION ISOLATION LEVEL SERIALIZABLE just after BEGIN if you need more rigorous transaction isolation. In SERIALIZABLE mode queries will see only changes committed \
+before the entire transaction began (actually, before execution of the first DML statement in a serializable transaction).  \
+If the transaction is committed, Postgres will ensure either that all updates are done or else that none of them are done. Transactions have the standard ACID (atomic, consistent, isolatable, and durable) property.
+
+" {} "Synopsis" {bold} "
+" {} "  
+BEGIN \[ WORK | TRANSACTION \]
+
+" {code} "Notes" {bold} "
+The keyword TRANSACTION is just a cosmetic alternative to WORK. Neither keyword need be specified. 
+Refer to the LOCK statement for further information about locking tables inside a transaction. 
+Use " {} "COMMIT" {link commit} " or " {} "ROLLBACK" {link rollback} " to terminate a transaction.
+
+" {} "Usage" {bold} "
+To begin a user transaction: 
+
+" {} "BEGIN WORK;" {italic} "
+
+" {} "Compatibility" {bold} "
+BEGIN is a Postgres language extension.
+
+" {} "SQL92" {bold} "
+
+There is no explicit BEGIN WORK command in SQL92; transaction initiation is always implicit and it terminates either with a COMMIT or with a ROLLBACK statement. 
+
+       Note: Many relational database systems offer an autocommit feature as a convenience. 
+
+SQL92 also requires SERIALIZABLE to be the default transaction isolation level. "
diff --git a/src/bin/pgaccess/lib/help/close.hlp b/src/bin/pgaccess/lib/help/close.hlp
new file mode 100644 (file)
index 0000000..96eac35
--- /dev/null
@@ -0,0 +1,22 @@
+.pgaw:Help.f.t insert end "CLOSE" {bold} " frees the resources associated with an open cursor. After the cursor is closed, no subsequent operations are allowed on it. A cursor should be closed when it is no longer needed. \
+An implicit close is executed for every open cursor when a transaction is terminated by  \
+" {} "COMMIT" {link commit} " or " {} "ROLLBACK" {link rollback} ".
+
+" {} "Synopsis" {bold} "
+
+CLOSE cursor
+
+" {} "Usage" {bold} "
+
+Close the cursor liahona:
+
+CLOSE liahona;
+
+" {} "Compatibility" {bold} "
+
+SQL92 
+CLOSE is fully compatible with SQL92
+
+" {} "Notes" {bold} "
+
+Postgres does not have an explicit OPEN cursor statement; a cursor is considered open when it is declared. Use the DECLARE statement to declare a cursor."
diff --git a/src/bin/pgaccess/lib/help/cluster.hlp b/src/bin/pgaccess/lib/help/cluster.hlp
new file mode 100644 (file)
index 0000000..30f1c2c
--- /dev/null
@@ -0,0 +1,48 @@
+.pgaw:Help.f.t insert end "CLUSTER" {bold} " instructs Postgres to cluster the class specified by classname approximately based on the index specified by indexname. The index must already have been defined on classname. \
+When a class is clustered, it is physically reordered based on the index information. The clustering is static. In other words, as the class is updated, the changes are not clustered. No attempt is \
+made to keep new instances or updated tuples clustered. If one wishes, one can recluster manually by issuing the command \
+again.
+
+" {} "Synopsis" {bold} "
+   CLUSTER indexname ON table
+
+" {} "Inputs" {bold} "
+
+" {} "indexname" {italic} "
+       The name of an index. 
+
+" {} "table" {italic} "
+       The name of a table. 
+
+" {} "Outputs" {bold} "
+
+CLUSTER
+       The clustering was done successfully. 
+ERROR: relation <tablerelation_number> inherits \"invoice\"
+ERROR: Relation x does not exist!
+
+" {} "Usage" {bold} "
+Cluster the employees relation on the basis of its salary attribute 
+
+   CLUSTER emp_ind ON emp
+   
+" {} "Notes" {bold} "
+
+The table is actually copied to a temporary table in index order, then renamed back to the original name. For this reason, all grant permissions and other indexes are lost when clustering is \
+performed. 
+In cases where you are accessing single rows randomly within a table, the actual order of the data in the heap table is unimportant. However, if you tend to access some data more than others, \
+and there is an index that groups them together, you will benefit from using CLUSTER. 
+Another place CLUSTER is helpful is in cases where you use an index to pull out several rows from a table. If you are requesting a range of indexed values from a table, or a single indexed \
+value that has multiple rows that match, CLUSTER will help because once the index identifies the heap page for the first row that matches, all other rows that match are probably already on the \
+same heap page, saving disk accesses and speeding up the query. 
+There are two ways to cluster data. The first is with the CLUSTER command, which reorders the original table with the ordering of the index you specify. This can be slow on large tables \
+because the rows are fetched from the heap in index order, and if the heap table is unordered, the entries are on random pages, so there is one disk page retrieved for every row moved. Postgres \
+has a cache, but the majority of a big table will not fit in the cache. 
+
+Another way to cluster data is to use 
+
+SELECT ... INTO TABLE temp FROM ... ORDER BY ...
+
+This uses the Postgres sorting code in ORDER BY to match the index, and is much faster for unordered data. You then drop the old table, use ALTER TABLE/RENAME to rename temp to \
+the old name, and recreate any indexes. The only problem is that OIDs will not be preserved. From then on, CLUSTER should be fast because most of the heap data has already been ordered, \
+and the existing index is used. "
diff --git a/src/bin/pgaccess/lib/help/commit.hlp b/src/bin/pgaccess/lib/help/commit.hlp
new file mode 100644 (file)
index 0000000..2bd40c9
--- /dev/null
@@ -0,0 +1,17 @@
+.pgaw:Help.f.t insert end "COMMIT" {bold} " commits the current transaction. All changes made by the transaction become visible to others and are guaranteed to be durable if a crash occurs.
+
+" {} "Synopsis" {bold} "
+" {} "
+COMMIT \[ WORK | TRANSACTION \]
+
+" {code} "Usage" {bold} "
+
+To make all changes permanent: 
+
+COMMIT WORK;
+
+" {} "Notes" {bold} "
+
+The keywords WORK and TRANSACTION are noise and can be omitted. 
+
+Use " {} "ROLLBACK" {link rollback} " to abort a transaction."
diff --git a/src/bin/pgaccess/lib/help/copy.hlp b/src/bin/pgaccess/lib/help/copy.hlp
new file mode 100644 (file)
index 0000000..eaf77a3
--- /dev/null
@@ -0,0 +1,105 @@
+.pgaw:Help.f.t insert end "COPY" {bold} " moves data between Postgres tables and standard Unix files. COPY instructs the Postgres backend to directly read from or write to a file. The file must be directly visible to the backend \
+and the name must be specified from the viewpoint of the backend. If stdin or stdout are specified, data flows through the client frontend to the backend.
+
+" {} "Synopsis" {bold} "
+" {} "
+COPY \[ BINARY \] table \[ WITH OIDS \]
+    FROM { 'filename' | stdin }
+    \[ USING DELIMITERS 'delimiter' \]
+COPY \[ BINARY \] table \[ WITH OIDS \]
+    TO { 'filename' | stdout }
+    \[ USING DELIMITERS 'delimiter' \]    
+
+" {code} "Inputs" {bold} "
+
+" {} "BINARY" {italic} "
+       Changes the behavior of field formatting, forcing all data to be stored or read as binary objects rather than as text. 
+
+" {} "table" {italic} "
+       The name of an existing table. 
+
+" {} "WITH OIDS" {italic} "
+       Copies the internal unique object id (OID) for each row. 
+
+" {} "filename" {italic} "
+       The absolute Unix pathname of the input or output file. 
+
+" {} "stdin" {italic} "
+       Specifies that input comes from a pipe or terminal. 
+
+" {} "stdout" {italic} "
+       Specifies that output goes to a pipe or terminal. 
+
+" {} "delimiter" {italic} "
+       A character that delimits the input or output fields. 
+       
+" {} "Outputs" {bold} "
+
+" {} "COPY" {italic} "
+       The copy completed successfully. 
+
+" {} "ERROR: error message" {italic} "
+       The copy failed for the reason stated in the error message. 
+
+" {} "Usage" {bold} "
+
+The following example copies a table to standard output, using a vertical bar \(\"|\"\) as the field delimiter:
+COPY country TO stdout USING DELIMITERS '|';
+
+To copy data from a Unix file into a table \"country\": 
+COPY country FROM '/usr1/proj/bray/sql/country_data';
+  
+Here is a sample of data suitable for copying into a table from stdin \(so it has the termination sequence on the last \
+line\):
+
+   AF      AFGHANISTAN
+   AL      ALBANIA
+   DZ      ALGERIA
+   ...
+   ZM      ZAMBIA
+   ZW      ZIMBABWE
+   \.
+
+" {} "File Formats" {bold} "
+
+" {} "Text Format" {italic} "
+When COPY TO is used without the BINARY option, the file generated will have each row \(instance\) on a single line, with each column \
+\(attribute\) separated by the delimiter character. Embedded delimiter characters will be preceded by a backslash character \
+\(\"\\\"\). The attribute values themselves are strings generated by the output function associated with each attribute type. \
+The output function for a type should not try to generate the backslash character; this will be handled by COPY itself.
+
+The actual format for each instance is 
+
+<attr1><separator><attr2><separator>...<separator><attrn><newline>
+The oid is placed on the beginning of the line if WITH OIDS is specified.
+
+If " {} "COPY" {bold} " is sending its output to standard output instead of a file, it will send a backslash\(\"\\\"\) and a period \
+\(\".\"\) followed immediately by a newline, on a separate line, when it is done. Similarly, \
+if " {} "COPY" {bold} " is reading from standard input, it will expect a backslash \(\"\\\"\) and a period \
+\(\".\"\) followed by a newline, as the first three characters on a line to denote end-of-file. However, COPY will \
+terminate \(followed by the backend itself\) if a true EOF is encountered before this special end-of-file pattern is found.
+
+The backslash character has other special meanings. NULL attributes are represented as \"\\N\". A literal backslash character is represented as two consecutive backslashes \
+\(\"\\\\\"\). A literal tab character is represented as a backslash and a tab. A literal newline character is represented as a backslash and a newline. When loading text data not generated by Postgres, you will need to \
+convert backslash characters \(\"\\\"\) to double-backslashes \(\"\\\\\"\) to ensure that they are loaded properly. 
+
+" {} "Binary Format" {italic} "
+
+In the case of " {} "COPY BINARY" {bold} ", the first four bytes in the file will be the number of instances in the file. If this number is zero, the \
+" {} "COPY BINARY" {bold} " command will read until end of file is encountered. Otherwise, it will stop reading when this number of instances has been read. Remaining data in the file will be ignored.  \
+The format for each instance in the file is as follows. Note that this format must be followed exactly. Unsigned four-byte integer quantities are called uint32 in the table below.
+
+" {} "Notes" {bold} "
+
+The " {} "BINARY" {bold} " keyword will force all data to be stored/read as binary objects rather than as text. It is somewhat faster than the normal copy command, but is not generally portable, and the files \
+generated are somewhat larger, although this factor is highly dependent on the data itself. By default, a text copy uses a tab \
+\(\"\\t\"\) character as a delimiter. The delimiter may also be changed to any other single character with the keyword phrase USING DELIMITERS. Characters in data fields which happen to match the delimiter character will be quoted.
+
+You must have select access on any table whose values are read by " {} "COPY" {bold} ", and either insert or update access to a table into which values are being inserted by \
+" {} "COPY" {bold} ". The backend also needs appropriate Unix permissions for any file read or written by \
+" {} "COPY" {bold} ". 
+
+The keyword phrase " {} "USING DELIMITERS" {bold} " specifies a single character to be used for all delimiters between columns. If multiple characters are specified in the delimiter string, only the first \
+character is used. 
+
+       Tip: Do not confuse " {} "COPY" {bold} " with the psql instruction \\copy. "
diff --git a/src/bin/pgaccess/lib/help/copyrights.hlp b/src/bin/pgaccess/lib/help/copyrights.hlp
new file mode 100644 (file)
index 0000000..d81fd16
--- /dev/null
@@ -0,0 +1,11 @@
+.pgaw:Help.f.t insert end \
+"Copyrights\n\n" {title} \
+"
+PostgreSQL is Copyright © 1996-9 by the PostgreSQL Global Development Group, and is distributed under the terms of the Berkeley license. 
+
+Postgres95 is Copyright © 1994-5 by the Regents of the University of California. Permission to use, copy, modify, and distribute this software and its documentation for any purpose, without fee, and without a written agreement is hereby granted, provided that the above copyright notice and this paragraph and the following two paragraphs appear in all copies. 
+
+In no event shall the University of California be liable to any party for direct, indirect, special, incidental, or consequential damages, including lost profits, arising out of the use of this software and its documentation, even if the University of California has been advised of the possibility of such damage. 
+
+The University of California specifically disclaims any warranties, including, but not limited to, the implied warranties of merchantability and fitness for a particular purpose. The software provided hereunder is on an \"as-is\" basis, and the University of California has no obligations to provide maintainance, support, updates, enhancements, or modifications. 
+"
diff --git a/src/bin/pgaccess/lib/help/create_aggregate.hlp b/src/bin/pgaccess/lib/help/create_aggregate.hlp
new file mode 100644 (file)
index 0000000..8734ace
--- /dev/null
@@ -0,0 +1,90 @@
+.pgaw:Help.f.t insert end "CREATE AGGREGATE" {bold} " allows a user or programmer to extend Postgres functionality by defining new aggregate functions. Some aggregate functions for base types such as \
+min\(int4\) and avg(float8) are already provided in the base distribution. If one defines new types or needs an aggregate function not already provided then CREATE AGGREGATE can be used to provide \
+the desired features. 
+
+An aggregate function can require up to three functions, two state transition functions, sfunc1 and sfunc2: 
+    sfunc1( internal-state1, next-data_item ) ---> next-internal-state1
+    sfunc2( internal-state2 ) ---> next-internal-state2   
+
+and a final calculation function, ffunc: 
+
+    ffunc(internal-state1, internal-state2) ---> aggregate-value   
+
+Postgres creates up to two temporary variables (referred to here as temp1 and temp2) to hold intermediate results used as arguments to the transition functions. 
+
+These transition functions are required to have the following properties: 
+
+       The arguments to sfunc1 must be temp1 of type sfunc1_return_type and column_value of type data_type. The return value must be of type sfunc1_return_type and will be used as
+       the first argument in the next call to sfunc1. 
+
+       The argument and return value of sfunc2 must be temp2 of type sfunc2_return_type. 
+
+       The arguments to the final-calculation-function must be temp1 and temp2 and its return value must be a Postgres base type (not necessarily data_type which had been specified for
+       BASETYPE). 
+
+       FINALFUNC should be specified if and only if both state-transition functions are specified. 
+
+An aggregate function may also require one or two initial conditions, one for each transition function. These are specified and stored in the database as fields of type text. 
+
+" {} "Synopsis" {bold} "
+" {} "
+CREATE AGGREGATE name \[ AS \]
+    ( BASETYPE    = data_type
+    \[ , SFUNC1    = sfunc1
+      , STYPE1    = sfunc1_return_type \]
+    \[ , SFUNC2    = sfunc2
+      , STYPE2    = sfunc2_return_type \]
+    \[ , FINALFUNC = ffunc \]
+    \[ , INITCOND1 = initial_condition1 \]
+    \[ , INITCOND2 = initial_condition2 \]
+    )
+
+" {code} "Inputs" {bold} "
+
+" {} "name" {italic} "
+       The name of an aggregate function to create. 
+
+" {} "data_type" {italic} "
+       The fundamental data type on which this aggregate function operates. 
+
+" {} "sfunc1" {italic} "
+       The state transition function to be called for every non-NULL field from the source column. It takes a variable of type sfunc1_return_type as the first argument and that field as the
+       second argument. 
+
+" {} "sfunc1_return_type" {italic} "
+       The return type of the first transition function. 
+
+" {} "sfunc2" {italic} "
+       The state transition function to be called for every non-NULL field from the source column. It takes a variable of type sfunc2_return_type as the only argument and returns a variable
+       of the same type. 
+
+" {} "sfunc2_return_type" {italic} "
+       The return type of the second transition function. 
+
+" {} "ffunc" {italic} "
+       The final function called after traversing all input fields. This function must take two arguments of types sfunc1_return_type and sfunc2_return_type. 
+
+" {} "initial_condition1" {italic} "
+       The initial value for the first transition function argument. 
+
+" {} "initial_condition2" {italic} "
+       The initial value for the second transition function argument. 
+
+" {} "Outputs" {bold} "
+
+" {} "CREATE" {italic} "
+
+       Message returned if the command completes successfully.
+
+" {} "Usage" {bold} "
+
+Refer to the chapter on aggregate functions in the PostgreSQL Programmer's Guide on aggregate functions for complete examples of usage. 
+
+" {} "Notes" {bold} "
+
+Use " {} "DROP AGGREGATE" {bold} " to drop aggregate functions. 
+
+It is possible to specify aggregate functions that have varying combinations of state and final functions. For example, the count aggregate requires SFUNC2 (an incrementing function) but not \
+SFUNC1 or FINALFUNC, whereas the sum aggregate requires SFUNC1 (an addition function) but not SFUNC2 or FINALFUNC and the avg aggregate requires both of the above state \
+functions as well as a FINALFUNC (a division function) to produce its answer. In any case, at least one state function must be defined, and any SFUNC2 must have a corresponding \
+INITCOND2."
diff --git a/src/bin/pgaccess/lib/help/create_database.hlp b/src/bin/pgaccess/lib/help/create_database.hlp
new file mode 100644 (file)
index 0000000..a14e1e5
--- /dev/null
@@ -0,0 +1,59 @@
+.pgaw:Help.f.t insert end "CREATE DATABASE" {bold} " creates a new Postgres database. The creator becomes the administrator of the new database. 
+
+" {} "Synopsis" {bold} "
+" {} "
+CREATE DATABASE name \[ WITH LOCATION = 'dbpath' \]
+
+" {code} "Inputs" {bold} "
+
+" {} "name" {italic} "
+       The name of a database to create. 
+
+" {} "dbpath" {italic} "
+       An alternate location can be specified as either an environment variable known to the backend server (e.g. 'PGDATA2') or as an absolute path name (e.g. '/usr/local/pgsql/data'). In \
+       either case, the location must be pre-configured by initlocation. 
+
+" {} "Outputs" {bold} "
+
+" {} "CREATEDB" {italic} "
+       Message returned if the command completes successfully. 
+
+" {} "WARN: createdb: database \"name\" already exists." {italic} "
+       This occurs if database specified already exists. 
+
+" {} "ERROR: Unable to create database directory directory" {italic} "
+       There was a problem with creating the required directory; this operation will need permissions for the postgres user on the specified location. 
+
+" {} "Usage" {bold} "
+
+To create a new database: 
+
+   olly=> create database lusiadas;  
+
+To create a new database in an alternate area ~/private_db: 
+
+   $ mkdir private_db
+   $ initlocation ~/private_db
+   Creating Postgres database system directory /home/olly/private_db/base
+   
+   $ psql olly
+   Welcome to the POSTGRESQL interactive sql monitor:
+    Please read the file COPYRIGHT for copyright terms of POSTGRESQL
+    
+    type \\? for help on slash commands
+    type \\q to quit
+    type \\g or terminate with semicolon to execute query
+    You are currently connected to the database: template1
+    
+    olly=> create database elsewhere with location = '/home/olly/private_db';
+
+" {} "Bugs" {bold} "
+
+There are security and data integrity issues involved with using alternate database locations specified with absolute path names, and by default only an environment variable known to the \
+backend may be specified for an alternate location. See the Administrator's Guide for more information. 
+
+" {} "Notes" {bold} "
+
+" {} "CREATE DATABASE" {italic} " is a Postgres language extension. 
+
+Use " {} "DROP DATABASE" {italic} " to remove a database. "
diff --git a/src/bin/pgaccess/lib/help/create_function.hlp b/src/bin/pgaccess/lib/help/create_function.hlp
new file mode 100644 (file)
index 0000000..828f157
--- /dev/null
@@ -0,0 +1,69 @@
+.pgaw:Help.f.t insert end \
+"Synopsis" {bold} "
+
+CREATE FUNCTION name ( \[ ftype \[, ...\] \] )
+RETURNS rtype
+AS definition
+LANGUAGE 'langname'
+" {code} "
+
+name" {italic} "
+       The name of a function to create. 
+
+" {} "ftype" {italic} "
+       The data type of function arguments. 
+
+" {} "rtype" {italic} "
+       The return data type. 
+
+" {} "definition" {italic} "
+       A string defining the function; the meaning depends on the language. It may be an internal function name, the path to an object file, an SQL query, or text in a procedural language. 
+
+" {} "langname" {italic} "
+       may be 'C', 'sql', 'internal' or 'plname', where 'plname' is the name of a created procedural language. See CREATE LANGUAGE for details. 
+
+" {} "Outputs" {bold} "
+
+CREATE
+       This is returned if the command completes successfully. 
+
+CREATE FUNCTION allows a Postgres user to register a function with a database. Subsequently, this user is treated as the owner of the function. 
+
+" {} "Notes:" {italic} "Refer to the chapter on functions in the PostgreSQL Programmer's Guide for further information. 
+
+Use " {} "DROP FUNCTION" {link drop_function} " to drop user-defined functions. 
+
+Postgres allows function \"overloading\"; that is, the same name can be used for several different functions so long as they have distinct argument types. This facility must be used with caution for INTERNAL and C-language functions, however. 
+
+Two INTERNAL functions cannot have the same C name without causing errors at link time. To get around that, give them different C names (for example, use the argument types as part of the C names), then specify those names in the AS clause of CREATE FUNCTION. If the AS clause is left empty then CREATE FUNCTION assumes the C name of the function is the same as the SQL name. 
+
+For dynamically-loaded C functions, the SQL name of the function must be the same as the C function name, because the AS clause is used to give the path name of the object file containing the C code. In this situation it is best not to try to overload SQL function names. It might work to load a C function that has the same C name as an internal function or another dynamically-loaded function --- or it might not. On some platforms the dynamic loader may botch the load in interesting ways if there is a conflict of C function names. So, even if it works for you today, you might regret overloading names later when you try to run the code somewhere else. 
+
+" {} "Usage" {bold} "
+
+To create a simple SQL function: 
+" {} "
+CREATE FUNCTION product_price(int4) RETURNS float8 AS
+       'SELECT price FROM products where id = \$1'
+LANGUAGE 'sql';
+
+SELECT product_price(314) AS answer;
+
+answer 
+------
+15.25
+" {code} "
+
+To create a C function, calling a routine from a user-created shared library. This particular routine calculates a check digit and returns TRUE if the check digit in the function parameters is correct. It is intended for use in a CHECK contraint. 
+" {} "
+CREATE FUNCTION ean_checkdigit(bpchar, bpchar) RETURNS bool
+AS '/usr1/proj/bray/sql/funcs.so' LANGUAGE 'c';
+
+CREATE TABLE product (
+       id        char(8) PRIMARY KEY,
+       eanprefix char(8) CHECK (eanprefix ~ '\[0-9\]{2}-\[0-9\]{5}')
+       REFERENCES brandname(ean_prefix),
+       eancode   char(6) CHECK (eancode ~ '\[0-9\]{6}'),
+       CONSTRAINT ean    CHECK (ean_checkdigit(eanprefix, eancode))
+);
+" {code}
diff --git a/src/bin/pgaccess/lib/help/create_index.hlp b/src/bin/pgaccess/lib/help/create_index.hlp
new file mode 100644 (file)
index 0000000..65548a5
--- /dev/null
@@ -0,0 +1,87 @@
+.pgaw:Help.f.t insert end "CREATE INDEX" {bold} " constructs an index index_name. on the specified table. 
+
+       Tip: Indexes are primarily used to enhance database performance. But inappropriate use will result in slower performance. 
+
+       In the first syntax shown above, the key fields for the index are specified as column names; a column may also have an associated operator class. An operator class is used to specify the \
+operators to be used for a particular index. For example, a btree index on four-byte integers would use the int4_ops class; this operator class includes comparison functions for four-byte \
+integers. The default operator class is the appropriate operator class for that field type. 
+
+       In the second syntax, an index is defined on the result of a user-defined function func_name applied to one or more attributes of a single class. These functional indexes can be used to obtain \
+fast access to data based on operators that would normally require some transformation to apply them to the base data. 
+
+" {} "Synopsis" {bold} "
+
+CREATE \[ UNIQUE \] INDEX index_name
+    ON table \[ USING acc_name \]
+    ( column \[ ops_name\] \[, ...\] )
+CREATE \[ UNIQUE \] INDEX index_name
+    ON table \[ USING acc_name \]
+    ( func_name( column \[, ... \]) ops_name )
+
+" {code} "Inputs" {bold} "
+
+" {} "UNIQUE" {italic} "
+       Causes the system to check for duplicate values in the table when the index is created \
+       \(if data already exist\) and each time data is added. Attempts to insert or update non-duplicate \
+       data will generate an error. 
+
+" {} "index_name" {italic} "
+       The name of the index to be created. 
+
+" {} "table" {italic} "
+       The name of the table to be indexed. 
+
+" {} "acc_name" {italic} "
+       the name of the access method which is to be used for the index. The default access method is BTREE. Postgres provides three access methods for secondary indexes: 
+
+       BTREE
+
+              an implementation of the Lehman-Yao high-concurrency btrees. 
+
+       RTREE
+
+              implements standard rtrees using Guttman's quadratic split algorithm. 
+
+       HASH
+
+              an implementation of Litwin's linear hashing. 
+
+" {} "column" {italic} "
+       The name of a column of the table. 
+
+" {} "ops_name" {italic} "
+       An associated operator class. The following select list returns all ops_names: 
+" {} "
+       SELECT am.amname AS acc_name,
+              opc.opcname AS ops_name,
+              opr.oprname AS ops_comp
+           FROM pg_am am, pg_amop amop,
+                pg_opclass opc, pg_operator opr
+           WHERE amop.amopid = am.oid AND
+                 amop.amopclaid = opc.oid AND
+                 amop.amopopr = opr.oid
+           ORDER BY acc_name, ops_name, ops_comp
+
+" {code} "func_name" {italic} "
+       A user-defined function, which returns a value that can be indexed. 
+
+" {} "Outputs" {bold} "
+
+" {} "CREATE" {italic} "
+       The message returned if the index is successfully created. 
+
+" {} "ERROR: Cannot create index: 'index_name' already exists." {italic} "
+       This error occurs if it is impossible to create the index. 
+       
+" {} "Usage" {bold} "
+
+To create a btree index on the field title in the table films: 
+" {} "
+CREATE UNIQUE INDEX title_idx
+    ON films (title);
+    
+" {code} "Notes" {bold} "
+
+Currently, only the BTREE access method supports multi-column indexes. Up to 7 keys may be specified. 
+
+Use DROP INDEX to remove an index. "
diff --git a/src/bin/pgaccess/lib/help/create_language.hlp b/src/bin/pgaccess/lib/help/create_language.hlp
new file mode 100644 (file)
index 0000000..e68fe6f
--- /dev/null
@@ -0,0 +1,130 @@
+.pgaw:Help.f.t insert end "CREATE LANGUAGE" {bold} ". Using CREATE LANGUAGE, a Postgres user can register a new language with Postgres. Subsequently, functions and trigger procedures can be defined in this new language. The user must \
+have the Postgres superuser privilege to register a new language. 
+
+Writing PL handlers 
+
+       The call handler for a procedural language must be written in a compiler language such as 'C' and registered with Postgres as a function taking no arguments and returning the opaque type, a \
+placeholder for unspecified or undefined types.. This prevents the call handler from being called directly as a function from queries. 
+However, arguments must be supplied on the actual call when a PL function or trigger procedure in the language offered by the handler is to be executed.  \
+       When called from the trigger manager, the only argument is the object ID from the procedure's pg_proc entry. All other information from the trigger manager is found in the global \
+       CurrentTriggerData pointer. 
+       When called from the function manager, the arguments are the object ID of the procedure's pg_proc entry, the number of arguments given to the PL function, the arguments in a \
+       FmgrValues structure and a pointer to a boolean where the function tells the caller if the return value is the SQL NULL value. 
+
+       It's up to the call handler to fetch the pg_proc entry and to analyze the argument and return types of the called procedure. The AS clause from the CREATE FUNCTION of the procedure will \
+be found in the prosrc attribute of the pg_proc table entry. This may be the source text in the procedural language itself (like for PL/Tcl), a pathname to a file or anything else that tells the call \
+handler what to do in detail. 
+
+" {} "Synopsis" {bold} "
+
+CREATE \[ TRUSTED \] PROCEDURAL LANGUAGE 'langname'
+    HANDLER call_handler
+    LANCOMPILER 'comment'
+
+" {code} "Inputs" {bold} "
+
+" {} "TRUSTED" {italic} "
+       TRUSTED specifies that the call handler for the language is safe; that is, it offers an unprivileged user no functionality to bypass access restrictions. If this keyword is omitted when
+       registering the language, only users with the Postgres superuser privilege can use this language to create new functions (like the 'C' language). 
+
+" {} "langname" {italic} "
+       The name of the new procedural language. The language name is case insensitive. A procedural language cannot override one of the built-in languages of Postgres. 
+
+" {} "HANDLER call_handler" {italic} "
+       call_handler is the name of a previously registered function that will be called to execute the PL procedures. 
+
+" {} "comment" {italic} "
+       The LANCOMPILER argument is the string that will be inserted in the LANCOMPILER attribute of the new pg_language entry. At present, Postgres does not use this attribute in any way. 
+
+" {} "Outputs" {bold} "
+
+" {} "CREATE" {italic} "
+       This message is returned if the language is successfully created. 
+
+" {} "ERROR: PL handler function funcname\(\) doesn't exist" {italic} "
+       This error is returned if the function funcname() is not found. 
+
+" {} "Usage" {bold} "
+
+This is a template for a PL handler written in 'C': 
+" {} "
+   #include \"executor/spi.h\"
+   #include \"commands/trigger.h\"
+   #include \"utils/elog.h\"
+   #include \"fmgr.h\"        /* for FmgrValues struct */
+   #include \"access/heapam.h\"
+   #include \"utils/syscache.h\"
+   #include \"catalog/pg_proc.h\"
+   #include \"catalog/pg_type.h\"
+        
+   Datum
+   plsample_call_handler\(
+        Oid       prooid,
+        int       pronargs,
+        FmgrValues     *proargs,
+        bool      *isNull\)
+   \{
+        Datum          retval;
+        TriggerData    *trigdata;
+
+        if \(CurrentTriggerData == NULL\) \{
+             /*
+              * Called as a function
+              */
+
+             retval = ...
+        \} else \{
+             /*
+              * Called as a trigger procedure
+              */
+             trigdata = CurrentTriggerData;
+             CurrentTriggerData = NULL;
+
+             retval = ...
+        \}
+
+        *isNull = false;
+        return retval;
+   \}
+" {code} "  
+Only a few thousand lines of code have to be added instead of the dots to complete the PL call handler. See CREATE FUNCTION for information on how to compile it into a loadable module .
+
+The following commands then register the sample procedural language: 
+" {} "
+    CREATE FUNCTION plsample_call_handler () RETURNS opaque
+    AS '/usr/local/pgsql/lib/plsample.so'
+    LANGUAGE 'C';
+    
+    CREATE PROCEDURAL LANGUAGE 'plsample'
+    HANDLER plsample_call_handler
+    LANCOMPILER 'PL/Sample';
+
+" {code} "Notes" {bold} "
+
+Use " {} "CREATE FUNCTION" {bold} " to create a function. 
+
+Use DROP LANGUAGE to drop procedural languages. 
+
+Refer to the table pg_language for further information: 
+
+Table    = pg_language
+" {} "
++-----------------+----------+-------+
+| Field           |   Type   | Length|
++-----------------+----------+-------+
+| lanname         | name     |   32  |
+| lancompiler     | text     |   var |
++-----------------+----------+-------+
+
+lanname |lancompiler   
+--------+--------------
+internal|n/a           
+lisp    |/usr/ucb/liszt
+C       |/bin/cc       
+sql     |postgres
+" {code} "
+
+" {} "Restrictions" {bold} "
+
+Since the call handler for a procedural language must be registered with Postgres in the 'C' language, it inherits all the capabilities and restrictions of 'C' functions.
+"
diff --git a/src/bin/pgaccess/lib/help/create_operator.hlp b/src/bin/pgaccess/lib/help/create_operator.hlp
new file mode 100644 (file)
index 0000000..160cabb
--- /dev/null
@@ -0,0 +1,145 @@
+.pgaw:Help.f.t insert end "CREATE OPERATOR" {bold} " defines a new operator, name. The user who defines an operator becomes its owner. 
+
+The operator name is a sequence of up to thirty two (32) characters in any combination from the following: 
+
+    + - * / < > = ~ ! @ # % ^ & | ` ? $ : 
+       " {} "Note:" {bold} " No alphabetic characters are allowed in an operator name. This enables Postgres to parse SQL input into tokens without requiring spaces between each token. 
+
+The operator \"!=\" is mapped to \"<>\" on input, so they are therefore equivalent. 
+
+At least one of LEFTARG and RIGHTARG must be defined. For binary operators, both should be defined. For right unary operators, only LEFTARG should be defined, while for left unary \
+operators only RIGHTARG should be defined. 
+Also, the func_name procedure must have been previously defined using CREATE FUNCTION and must be defined to accept the correct number of arguments (either one or two).  \
+The commutator operator should be identified if one exists, so that Postgres can reverse the order of the operands if it wishes. For example, the operator area-less-than, <<<, would probably \
+have a commutator operator, area-greater-than, >>>. Hence, the query optimizer could freely convert: 
+
+    \"0,0,1,1\"::box  >>> MYBOXES.description
+to 
+    MYBOXES.description <<< \"0,0,1,1\"::box
+
+This allows the execution code to always use the latter representation and simplifies the query optimizer somewhat. 
+
+Similarly, if there is a negator operator then it should be identified. Suppose that an operator, area-equal, ===, exists, as well as an area not equal, !==. The negator link allows the query \
+optimizer to simplify 
+
+    NOT MYBOXES.description === \"0,0,1,1\"::box   
+to 
+    MYBOXES.description !== \"0,0,1,1\"::box
+    
+If a commutator operator name is supplied, Postgres searches for it in the catalog. If it is found and it does not yet have a commutator itself, then the commutator's entry is updated to have the \
+newly created operator as its commutator. This applies to the negator, as well. 
+
+This is to allow the definition of two operators that are the commutators or the negators of each other. The first operator should be defined without a commutator or negator (as appropriate). \
+When the second operator is defined, name the first as the commutator or negator. The first will be updated as a side effect.(As of Postgres 6.5, it also works to just have both operators refer to \
+each other.) 
+
+The next three specifications are present to support the query optimizer in performing joins. Postgres can always evaluate a join (i.e., processing a clause with two tuple variables separated by \
+an operator that returns a boolean) by iterative substitution \[WONG76\]. In addition, Postgres can use a hash-join algorithm along the lines of \
+\[SHAP86\]; however, it must know whether this \
+strategy is applicable. The current hash-join algorithm is only correct for operators that represent equality tests; furthermore, equality of the datatype must mean bitwise equality of the \
+representation of the type. (For example, a datatype that contains unused bits that don't matter for equality tests could not be hashjoined.) The HASHES flag indicates to the query optimizer \
+that a hash join may safely be used with this operator.
+
+Similarly, the two sort operators indicate to the query optimizer whether merge-sort is a usable join strategy and which operators should be used to sort the two operand classes. Sort operators \
+should only be provided for an equality operator, and they should refer to less-than operators for the left and right side data types respectively. 
+
+If other join strategies are found to be practical, Postgres will change the optimizer and run-time system to use them and will require additional specification when an operator is defined. \
+Fortunately, the research community invents new join strategies infrequently, and the added generality of user-defined join strategies was not felt to be worth the complexity involved. 
+
+The last two pieces of the specification are present so the query optimizer can estimate result sizes. If a clause of the form: 
+
+    MYBOXES.description <<< \"0,0,1,1\"::box
+
+is present in the qualification, then Postgres may have to estimate the fraction of the instances in MYBOXES that satisfy the clause. The function res_proc must be a registered function \
+(meaning it is already defined using CREATE FUNCTION) which accepts arguments of the correct data types and returns a floating point number. The query optimizer simply calls this function, \
+passing the parameter \"0,0,1,1\" and multiplies the result by the relation size to get the desired expected number of instances. 
+
+Similarly, when the operands of the operator both contain instance variables, the query optimizer must estimate the size of the resulting join. The function join_proc will return another floating \
+point number which will be multiplied by the cardinalities of the two classes involved to compute the desired expected result size. 
+
+The difference between the function 
+
+    my_procedure_1 (MYBOXES.description, \"0,0,1,1\"::box)
+   
+and the operator 
+
+    MYBOXES.description === \"0,0,1,1\"::box
+   
+is that Postgres attempts to optimize operators and can decide to use an index to restrict the search space when operators are involved. However, there is no attempt to optimize functions, and \
+they are performed by brute force. Moreover, functions can have any number of arguments while operators are restricted to one or two. 
+
+" {} "Synopsis" {bold} "
+
+CREATE OPERATOR name (
+        PROCEDURE  = func_name
+     \[, LEFTARG    = type1 \]
+     \[, RIGHTARG   = type2 \]
+     \[, COMMUTATOR = com_op \]
+     \[, NEGATOR    = neg_op \]
+     \[, RESTRICT   = res_proc \]
+     \[, JOIN       = join_proc \]
+     \[, HASHES \]
+     \[, SORT1      = left_sort_op \]
+     \[, SORT2      = right_sort_op \]
+    )
+
+" {code} "Inputs" {bold} "
+
+" {} "name" {italic} "
+       The operator to be defined. See below for allowable characters. 
+
+" {} "func_name" {italic} "
+       The function used to implement this operator. 
+
+" {} "type1" {italic} "
+       The type for the left-hand side of the operator, if any. This option would be omitted for a right-unary operator. 
+
+" {} "type2" {italic} "
+       The type for the right-hand side of the operator, if any. This option would be omitted for a left-unary operator. 
+
+" {} "com_op" {italic} "
+       The commutator for this operator. 
+
+" {} "neg_op" {italic} "
+       The negator of this operator. 
+
+" {} "res_proc" {italic} "
+       The restriction selectivity estimator function for this operator. 
+
+" {} "join_proc" {italic} "
+       The join selectivity estimator function for this operator. 
+
+" {} "HASHES" {italic} "
+       Indicates this operator can support a hash-join algorithm. 
+
+" {} "left_sort_op" {italic} "
+       Operator that sorts the left-hand data type of this operator. 
+
+" {} "right_sort_op" {italic} "
+       Operator that sorts the right-hand data type of this operator. 
+       
+" {} "Outputs" {bold} "
+
+" {} "CREATE" {italic} "
+       Message returned if the operator is successfully created. 
+
+" {} "Usage" {bold} "
+
+The following command defines a new operator, area-equality, for the BOX data type. 
+" {} "
+   CREATE OPERATOR === (
+   LEFTARG = box,
+   RIGHTARG = box,
+   PROCEDURE = area_equal_procedure,
+   COMMUTATOR = ===,
+   NEGATOR = !==,
+   RESTRICT = area_restriction_procedure,
+   JOIN = area_join_procedure,
+   HASHES,
+   SORT1 = <<<,
+   SORT2 = <<<)
+
+" {code} "Notes" {bold} "
+
+Refer to the chapter on operators in the PostgreSQL User's Guide for further information. Refer to DROP OPERATOR to delete user-defined operators from a database.
+"
diff --git a/src/bin/pgaccess/lib/help/create_rule.hlp b/src/bin/pgaccess/lib/help/create_rule.hlp
new file mode 100644 (file)
index 0000000..d03390d
--- /dev/null
@@ -0,0 +1,132 @@
+.pgaw:Help.f.t insert end "CREATE RULE" {bold} " The semantics of a rule is that at the time an individual instance is accessed, updated, inserted or deleted, there is a current instance (for retrieves, updates and deletes) and a new instance (for \
+updates and appends). If the event specified in the ON clause and the condition specified in the WHERE clause are true for the current instance, the action part of the rule is executed. First, \
+however, values from fields in the current instance and/or the new instance are substituted for current.attribute-name and new.attribute-name. 
+
+The action part of the rule executes with the same command and transaction identifier as the user command that caused activation. 
+
+" {} "Synopsis" {bold} "
+
+CREATE RULE name
+    AS ON event
+    TO object \[ WHERE condition \]
+    DO \[ INSTEAD \] \[ action | NOTHING \]
+    
+" {code} "Inputs" {bold} "
+
+" {} "name" {italic} "
+       The name of a rule to create. 
+
+" {} "event" {italic} "
+       Event is one of select, update, delete or insert. 
+
+" {} "object" {italic} "
+       Object is either table or table.column. 
+
+" {} "condition" {italic} "
+       Any SQL WHERE clause. new or current can appear instead of an instance variable whenever an instance variable is permissible in SQL. 
+
+" {} "action" {italic} "
+       Any SQL statement. new or current can appear instead of an instance variable whenever an instance variable is permissible in SQL. 
+      
+" {} "Outputs" {bold} "
+
+" {} "CREATE" {italic} "
+       Message returned if the rule is successfully created.
+       
+" {} "Usage" {bold} "
+
+Make Sam get the same salary adjustment as Joe: 
+" {} "
+create rule example_1 as
+    on update EMP.salary where current.name = \"Joe\"
+    do update EMP (salary = new.salary)
+    where EMP.name = \"Sam\"
+   
+" {code} "
+At the time Joe receives a salary adjustment, the event will become true and Joe's current instance and proposed new instance are available to the execution routines. Hence, his new salary is \
+substituted into the action part of the rule which is subsequently executed. This propagates Joe's salary on to Sam. 
+
+Make Bill get Joe's salary when it is accessed: 
+" {} "
+create rule example_2 as
+    on select to EMP.salary
+    where current.name = \"Bill\"
+    do instead
+    select (EMP.salary) from EMP
+        where EMP.name = \"Joe\"
+   
+" {code} "
+Deny Joe access to the salary of employees in the shoe department (current_user returns the name of the current user): 
+
+" {} "  
+create rule example_3 as
+    on select to EMP.salary
+    where current.dept = \"shoe\" and current_user = \"Joe\"
+    do instead nothing
+   
+" {code} "
+Create a view of the employees working in the toy department. 
+" {} "
+create TOYEMP(name = char16, salary = int4)
+
+create rule example_4 as
+    on select to TOYEMP
+    do instead
+    select (EMP.name, EMP.salary) from EMP
+        where EMP.dept = \"toy\"
+   
+" {code} "
+All new employees must make 5,000 or less 
+" {} "
+create rule example_5 as
+    on insert to EMP where new.salary > 5000
+    do update newset salary = 5000
+
+" {code} "Notes" {bold} "
+
+A caution about SQL rules is in order. If the same class name or instance variable appears in the event, the condition and the action parts of a rule, they are all considered different tuple \
+variables. More accurately, new and current are the only tuple variables that are shared between these clauses. For example, the following two rules have the same semantics: 
+" {} "
+on update to EMP.salary where EMP.name = \"Joe\"
+    do update EMP ( ... ) where ...
+
+on update to EMP-1.salary where EMP-2.name = \"Joe\"
+    do update EMP-3 ( ... ) where ...
+    
+" {code} "
+Each rule can have the optional tag INSTEAD. Without this tag, action will be performed in addition to the user command when the event in the condition part of the rule occurs. Alternately, \
+the action part will be done instead of the user command. In this later case, the action can be the keyword NOTHING. 
+
+When choosing between the rewrite and instance rule systems for a particular rule application, remember that in the rewrite system, current refers to a relation and some qualifiers whereas in \
+the instance system it refers to an instance (tuple). 
+
+It is very important to note that the rewrite rule system will neither detect nor process circular rules. For example, though each of the following two rule definitions are accepted by Postgres, the \
+retrieve command will cause Postgres to crash: 
+
+Example 14-1. Example of a circular rewrite rule combination.
+" {} "
+create rule bad_rule_combination_1 as
+    on select to EMP
+    do instead select to TOYEMP
+
+create rule bad_rule_combination_2 as
+    on select to TOYEMP
+    do instead select to EMP
+     
+" {code} "
+This attempt to retrieve from EMP will cause Postgres to crash. 
+" {} "
+select * from EMP
+      
+" {code} "
+You must have rule definition access to a class in order to define a rule on it. Use GRANT and REVOKE to change permissions. 
+
+" {} "Bugs" {bold} "
+
+The object in a SQL rule cannot be an array reference and cannot have parameters. 
+
+Aside from the \"oid\" field, system attributes cannot be referenced anywhere in a rule. Among other things, this means that functions of instances (e.g., \"foo(emp)\" where \
+\"emp\" is a class) cannot be called anywhere in a rule. 
+
+The rule system stores the rule text and query plans as text attributes. This implies that creation of rules may fail if the rule plus its various internal representations exceed some value that is on \
+the order of one page (8KB). "
diff --git a/src/bin/pgaccess/lib/help/create_sequence.hlp b/src/bin/pgaccess/lib/help/create_sequence.hlp
new file mode 100644 (file)
index 0000000..e75a6bc
--- /dev/null
@@ -0,0 +1,42 @@
+.pgaw:Help.f.t insert end \
+"CREATE SEQUENCE" {bold} " will enter a new sequence number generator into the current data base. This involves creating and initialising a new single-row table with the name seqname. The generator will be \"owned\" by the user issuing the command. 
+
+After a sequence is created, you may use the function nextval(seqname) to get a new number from the sequence. The function currval('seqname') may be used to determine the number returned by the last call to nextval(seqname) for the specified sequence in the current session. The function setval('seqname', newvalue) may be used to set the current value of the specified sequence. The next call to nextval(seqname) will return the given value plus the sequence increment. 
+
+" {} "Synopsis" {bold} "
+
+CREATE SEQUENCE seqname
+\[ INCREMENT increment \]
+\[ MINVALUE  minvalue \]
+\[ MAXVALUE  maxvalue \]
+\[ START     start \]
+\[ CACHE     cache \]
+\[ CYCLE \]
+" {code} "
+" {} "Inputs" {bold} "
+
+" {} "seqname" {italic} "
+       The name of a sequence to be created. 
+
+" {} "increment" {italic} "
+       The INCREMENT increment clause is optional. A positive value will make an ascending sequence, a negative one a descending sequence. The default value is one (1). 
+
+" {} "minvalue" {italic} "
+       The optional clause MINVALUE minvalue determines the minimum value a sequence can generate. The defaults are 1 and -2147483647 for ascending and descending sequences, respectively. 
+
+" {} "maxvalue" {italic} "
+       Use the optional clause MAXVALUE maxvalue to determine the maximum value for the sequence. The defaults are 2147483647 and -1 for ascending and descending sequences, respectively. 
+
+" {} "start" {italic} "
+       The optional START start clause enables the sequence to begin anywhere. The default starting value is minvalue for ascending sequences and maxvalue for descending ones. 
+
+" {} "cache" {italic} "
+       The CACHE cache option enables sequence numbers to be preallocated and stored in memory for faster access. The minimum value is 1 (only one value can be generated at a time, i.e. no cache) and this is also the default. 
+
+" {} "CYCLE" {italic} "
+       The optional CYCLE keyword may be used to enable the sequence to continue when the maxvalue or minvalue has been reached by an ascending or descending sequence respectively. If the limit is reached, the next number generated will be whatever the minvalue or maxvalue is, as appropriate. 
+
+" {} "CAUTION" {title} "
+Unexpected results may be obtained if a cache setting greater than one is used for a sequence object that will be used concurrently by multiple backends. Each backend will allocate \"cache\" successive sequence values during one access to the sequence object and increase the sequence object's last_value accordingly. Then, the next cache-1 uses of nextval within that backend simply return the preallocated values without touching the shared object. So, numbers allocated but not used in the current session will be lost. Furthermore, although multiple backends are guaranteed to allocate distinct sequence values, the values may be generated out of sequence when all the backends are considered. (For example, with a cache setting of 10, backend A might reserve values 1..10 and return nextval=1, then backend B might reserve values 11..20 and return nextval=11 before backend A has generated nextval=2.) Thus, with a cache setting of one it is safe to assume that nextval values are generated sequentially; with a cache setting greater than one you should only assume that the nextval values are all distinct, not that they are generated purely sequentially. Also, last_value will reflect the latest value reserved by any backend, whether or not it has yet been returned by nextval. 
+
+CREATE SEQUENCE is a Postgres language extension. There is no CREATE SEQUENCE statement in SQL92."
diff --git a/src/bin/pgaccess/lib/help/create_table.hlp b/src/bin/pgaccess/lib/help/create_table.hlp
new file mode 100644 (file)
index 0000000..c55548b
--- /dev/null
@@ -0,0 +1,39 @@
+.pgaw:Help.f.t insert end \
+"CREATE TABLE" {bold} "
+
+CREATE \[ TEMPORARY | TEMP \] TABLE table (
+       column type
+       \[ NULL | NOT NULL \] \[ UNIQUE \] \[ DEFAULT value \]
+       \[column_constraint_clause | PRIMARY KEY } \[ ... \] \]
+       \[, ... ]
+       \[, PRIMARY KEY ( column \[, ...\] ) \]
+       \[, CHECK ( condition ) \]
+       \[, table_constraint_clause \]
+       ) \[ INHERITS ( inherited_table \[, ...\] ) \]
+" {code} "
+TEMPORARY
+       The table is created only for this session, and is automatically dropped on session exit. Existing permanent tables with the same name are not visible while the temporary table exists. 
+" {} "
+table" {italic} "
+   The name of a new table to be created. 
+" {} " 
+column" {italic} "
+   The name of a column. 
+" {} "
+type" {italic} "
+   The type of the column. This may include array specifiers. Refer to the PostgreSQL User's Guide for further information about data types and arrays. 
+" {} "
+DEFAULT value" {italic} "
+   A default value for a column. See the DEFAULT clause for more information. 
+" {} "
+column_constraint_clause" {italic} "
+   The optional column constraint clauses specify a list of integrity constraints or tests which new or updated entries must satisfy for an insert or update operation to succeed. Each constraint must evaluate to a boolean expression. Although SQL92 requires the column_constraint_clause to refer to that column only, Postgres allows multiple columns to be referenced within a single column constraint. See the column constraint clause for more information. 
+" {} "
+table_constraint_clause" {italic} "
+   The optional table CONSTRAINT clause specifies a list of integrity constraints which new or updated entries must satisfy for an insert or update operation to succeed. Each constraint must evaluate to a boolean expression. Multiple columns may be referenced within a single constraint. Only one PRIMARY KEY clause may be specified for a table; PRIMARY KEY column (a table constraint) and PRIMARY KEY (a column constraint) are mutually exclusive.. See the table constraint clause for more information. 
+" {} "
+INHERITS inherited_table" {italic} "
+   The optional INHERITS clause specifies a collection of table names from which this table automatically inherits all fields. If any inherited field name appears more than once, Postgres reports an error. Postgres automatically allows the created table to inherit functions on tables above it in the inheritance hierarchy. 
+
+Aside:  Inheritance of functions is done according to the conventions of the Common Lisp Object System (CLOS). 
+"
diff --git a/src/bin/pgaccess/lib/help/create_table_as.hlp b/src/bin/pgaccess/lib/help/create_table_as.hlp
new file mode 100644 (file)
index 0000000..b7de4e1
--- /dev/null
@@ -0,0 +1,20 @@
+.pgaw:Help.f.t insert end "CREATE TABLE AS" {bold} " CREATE TABLE AS enables a table to be created from the contents of an existing table. It has functionality equivalent to SELECT TABLE INTO, but with perhaps a more obvious syntax. 
+
+" {} "Synopsis" {bold} "
+" {} "
+CREATE TABLE table \[ (column \[, ...\] ) \]
+     AS select_clause
+
+" {code} "Inputs" {bold} "
+
+" {} "table" {italic} "
+       The name of a new table to be created. 
+
+" {} "column" {italic} "
+       The name of a column. Multiple column names can be specified using a comma-delimited list of column names. 
+
+" {} "select_clause" {italic} "
+       A valid query statement. Refer to SELECT for a description of the allowed syntax. 
+
+" {} "Outputs" {bold} "
+Refer to CREATE TABLE and SELECT for a summary of possible output messages. "
diff --git a/src/bin/pgaccess/lib/help/create_trigger.hlp b/src/bin/pgaccess/lib/help/create_trigger.hlp
new file mode 100644 (file)
index 0000000..d3f777a
--- /dev/null
@@ -0,0 +1,80 @@
+.pgaw:Help.f.t insert end "CREATE TRIGGER" {bold} " will enter a new trigger into the current data base. The trigger will be associated with the relation relname and will execute the specified function funcname. 
+
+The trigger can be specified to fire either before the operation is attempted on a tuple (before constraints are checked and the INSERT, UPDATE or DELETE is attempted) or after the operation \
+has been attempted (e.g. after constraints are checked and the INSERT, UPDATE or DELETE has completed). If the trigger fires before the event, the trigger may skip the operation for the \
+current tuple, or change the tuple being inserted (for INSERT and UPDATE operations only). If the trigger fires after the event, all changes, including the last insertion, update, or deletion, are \
+\"visible\" to the trigger. 
+
+Refer to the chapters on SPI and Triggers in the PostgreSQL Programmer's Guide for more information. 
+
+" {} "Synopsis" {bold} "
+
+CREATE TRIGGER name \{ BEFORE | AFTER \}
+    \{ event \[OR ...\] \}
+    ON table FOR EACH \{ ROW | STATEMENT \}
+    EXECUTE PROCEDURE funcname ( arguments )
+
+" {code} "Inputs" {bold} "
+
+" {} "name" {italic} "
+       The name of an existing trigger. 
+
+" {} "table" {italic} "
+       The name of a table. 
+
+" {} "event" {italic} "
+       One of INSERT, DELETE or UPDATE. 
+
+" {} "funcname" {italic} "
+       A user-supplied function. 
+
+" {} "Outputs" {bold} "
+
+" {} "CREATE" {italic} "
+       This message is returned if the trigger is successfully created. 
+
+" {} "Usage" {bold} "
+
+Check if the specified distributor code exists in the distributors table before appending or updating a row in the table films: 
+" {} "
+   CREATE TRIGGER if_dist_exists
+   BEFORE INSERT OR UPDATE ON films FOR EACH ROW
+   EXECUTE PROCEDURE check_primary_key ('did', 'distributors', 'did');
+  
+" {code} "
+Before cancelling a distributor or updating its code, remove every reference to the table films: 
+" {} "
+   CREATE TRIGGER if_film_exists 
+   BEFORE DELETE OR UPDATE ON distributors FOR EACH ROW
+   EXECUTE PROCEDURE check_foreign_key (1, 'CASCADE', 'did', 'films', 'did');
+
+
+
+" {code} "Compatibility" {bold} "
+
+" {} "SQL92" {italic} "
+
+There is no CREATE TRIGGER in SQL92. 
+
+The second example above may also be done by using a FOREIGN KEY constraint as in: 
+" {} "
+    CREATE TABLE distributors (
+    did      DECIMAL(3),
+    name     VARCHAR(40),
+    CONSTRAINT if_film_exists
+    FOREIGN KEY(did) REFERENCES films
+    ON UPDATE CASCADE ON DELETE CASCADE  
+    );
+   
+" {code} "
+However, foreign keys are not yet implemented (as of version 6.4) in Postgres. 
+
+" {} "Notes" {bold} "
+
+" {} "CREATE TRIGGER" {italic} " is a Postgres language extension. 
+
+Only the relation owner may create a trigger on this relation. 
+
+As of the current release (v6.4), STATEMENT triggers are not implemented. 
+
+Refer to DROP TRIGGER for information on how to remove triggers. "
diff --git a/src/bin/pgaccess/lib/help/create_type.hlp b/src/bin/pgaccess/lib/help/create_type.hlp
new file mode 100644 (file)
index 0000000..9834c1c
--- /dev/null
@@ -0,0 +1,24 @@
+.pgaw:Help.f.t insert end "CREATE TYPE" {bold} " allows the user to register a new user data type with Postgres for use in the current data base. The user who defines a type becomes its owner. Typename is the name of the new \
+type and must be unique within the types defined for this database. 
+
+" {} "Synopsis" {bold} "
+
+CREATE TYPE typename (
+        INPUT          = input_function
+      , OUTPUT         = output_function
+      , INTERNALLENGTH = (internallength | VARIABLE)
+    \[ , EXTERNALLENGTH = (externallength | VARIABLE) \]
+    \[ , ELEMENT        = element \]
+    \[ , DELIMITER      = delimiter \]
+    \[ , DEFAULT        = \"default\" \]
+    \[ , SEND           = send_function \]
+    \[ , RECEIVE        = receive_function \]
+    \[ , PASSEDBYVALUE \]
+)
+
+" {code} "Notes" {bold} "
+
+Refer to DROP TYPE to remove an existing type. 
+
+See also CREATE FUNCTION, CREATE OPERATOR and the chapter on Large Objects in the PostgreSQL Programmer's Guide.
+"
diff --git a/src/bin/pgaccess/lib/help/create_user.hlp b/src/bin/pgaccess/lib/help/create_user.hlp
new file mode 100644 (file)
index 0000000..4adf87f
--- /dev/null
@@ -0,0 +1,50 @@
+.pgaw:Help.f.t insert end "CREATE USER" {bold} " will add a new user to an instance of Postgres. 
+
+The new user will be given a usesysid of: 'SELECT MAX(usesysid) + 1 FROM pg_shadow'. This means that Postgres users' usesysids will not correspond to their operating system(OS) \
+user ids. The exception to this rule is the 'postgres' user, whose OS user id is used as the usesysid during the initdb process. If you still want the OS user id and the usesysid to match for any \
+given user, use the \"createuser\" script provided with the Postgres distribution. 
+
+" {} "Synopsis" {bold} "
+
+CREATE USER username
+    \[ WITH PASSWORD password \]
+    \[ CREATEDB   | NOCREATEDB \]
+    \[ CREATEUSER | NOCREATEUSER \]
+    \[ IN GROUP     groupname \[, ...\] \]
+    \[ VALID UNTIL  'abstime' \]
+    
+
+" {code} "Usage" {bold} "
+
+Create a user with no password: 
+" {} "   CREATE USER jonathan
+" {code} "  
+Create a user with a password: 
+" {} "   CREATE USER davide WITH PASSWORD jw8s0F4
+" {code} "
+Create a user with a password, whose account is valid until the end of 2001. Note that after one second has ticked in 2002, the account is not valid: 
+" {} "   CREATE USER miriam WITH PASSWORD jw8s0F4 VALID UNTIL 'Jan 1 2002'  
+" {code} "
+Create an account where the user can create databases: 
+" {} "   CREATE USER manuel WITH PASSWORD jw8s0F4 CREATEDB
+
+" {code} "Notes" {bold} "
+
+CREATE USER statement is a Postgres language extension. 
+Use DROP USER or ALTER USER statements to remove or modify a user account.
+Refer to the pg_shadow table for further information. 
+" {} "
+   Table    = pg_shadow
+   +--------------------------+--------------------------+-------+
+   |          Field           |          Type            | Length|
+   +--------------------------+--------------------------+-------+
+   | usename                  | name                     |    32 |
+   | usesysid                 | int4                     |     4 |
+   | usecreatedb              | bool                     |     1 |
+   | usetrace                 | bool                     |     1 |
+   | usesuper                 | bool                     |     1 |
+   | usecatupd                | bool                     |     1 |
+   | passwd                   | text                     |   var |
+   | valuntil                 | abstime                  |     4 |
+   +--------------------------+--------------------------+-------+
+" {code}
diff --git a/src/bin/pgaccess/lib/help/create_view.hlp b/src/bin/pgaccess/lib/help/create_view.hlp
new file mode 100644 (file)
index 0000000..416807e
--- /dev/null
@@ -0,0 +1,27 @@
+.pgaw:Help.f.t insert end "CREATE VIEW" {bold} " will define a view of a table. This view is not physically materialized. Specifically, a query rewrite retrieve rule is automatically generated to support retrieve operations on \
+views. 
+
+" {} "Synopsis" {bold} "
+
+CREATE VIEW view
+    AS SELECT query
+
+" {} "Usage" {bold} "
+
+Create a view consisting of all Comedy films: 
+" {} "
+CREATE VIEW kinds AS
+    SELECT *
+    FROM films
+    WHERE kind = 'Comedy';
+
+SELECT * FROM kinds;
+
+code |title                    |did| date_prod|kind      |len
+-----+-------------------------+---+----------+----------+------
+UA502|Bananas                  |105|1971-07-13|Comedy    | 01:22
+C_701|There's a Girl in my Soup|107|1970-06-11|Comedy    | 01:36
+
+" {code} "Notes" {bold} "
+
+Use the DROP VIEW statement to drop views. "
diff --git a/src/bin/pgaccess/lib/help/data_types.hlp b/src/bin/pgaccess/lib/help/data_types.hlp
new file mode 100644 (file)
index 0000000..c2ba891
--- /dev/null
@@ -0,0 +1,48 @@
+.pgaw:Help.f.t configure -tabs {130 300 450}
+.pgaw:Help.f.t insert end \
+"Data types\n\n" {title} \
+"Postgres has a rich set of native data types available to users. Users may add new types to Postgres using the DEFINE TYPE command described elsewhere. 
+
+In the context of data types, the following sections will discuss SQL standards compliance, porting issues, and usage. Some Postgres types correspond directly to SQL92-compatible types. In other cases, data types defined by SQL92 syntax are mapped directly into native Postgres types. Many of the built-in types have obvious external formats. However, several types are either unique to Postgres, such as open and closed paths, or have several possibilities for formats, such as the date and time types. 
+
+" {} \
+"Postgres Type\tSQL92 or SQL3 Type\tDescription\n" {bold} \
+"bool\tboolean\tlogical boolean (true/false)
+box\t\trectangular box in 2D plane\tchar(n)
+character(n)\t\tfixed-length character string
+cidr\t\tIP version 4 network or host address
+circle\t\tcircle in 2D plane
+date\tdate\tcalendar date without time of day
+float4/8\tfloat(p)\tfloating-point number with precision p
+float8\treal, double precision\tdouble-precision floating-point number
+inet\t\tIP version 4 network or host address
+int2\tsmallint\tsigned two-byte integer
+int4\tint, integer\tsigned 4-byte integer
+int4\tdecimal(p,s)\texact numeric for p <= 9, s = 0
+int4\tnumeric(p,s)\texact numeric for p == 9, s = 0
+int8\t\tsigned 8-byte integer
+line\t\tinfinite line in 2D plane
+lseg\t\tline segment in 2D plane
+money\tdecimal(9,2)\tUS-style currency
+path\t\topen and closed geometric path in 2D plane
+point\t\tgeometric point in 2D plane
+polygon\t\tclosed geometric path in 2D plane
+serial\t\tunique id for indexing and cross-reference
+time\ttime\ttime of day
+timespan\tinterval\tgeneral-use time span
+timestamp\ttimestamp with time zone\tdate/time
+varchar(n)\tcharacter varying(n)\tvariable-length character string
+
+Note:  The cidr and inet types are designed to handle any IP type but only ipv4 is handled in the current implementation. Everything here that talks about ipv4 will apply to ipv6 in a future release.
+
+" {} \
+"Postgres Function Constants
+
+Postgres Function\tSQL92 Constant\tDescription" {bold} \
+"
+getpgusername()\tcurrent_user\tuser name in current session
+date('now')\tcurrent_date\tdate of current transaction
+time('now')\tcurrent_time\ttime of current transaction
+timestamp('now')\tcurrent_timestamp\tdate and time of current transaction
+" {}
+
diff --git a/src/bin/pgaccess/lib/help/datefunc.hlp b/src/bin/pgaccess/lib/help/datefunc.hlp
new file mode 100644 (file)
index 0000000..70c7e5e
--- /dev/null
@@ -0,0 +1,58 @@
+.pgaw:Help.f.t insert end \
+"DateTime functions\n\n" {title} \
+"abstime(datetime) " {bold} "
+       Returns: abstime 
+       convert to abstime 
+
+" {} "age(datetime,datetime) " {bold} "
+       Returns: timespan 
+       preserve months and years 
+
+" {} "datetime(abstime) " {bold} "
+       Returns: datetime 
+       convert to datetime 
+
+" {} "datetime(date) " {bold} "
+       Returns: datetime 
+       convert to datetime 
+
+" {} "datetime(date,time) " {bold} "
+       Returns: datetime 
+       convert to datetime 
+
+" {} "date_part(text,datetime) " {bold} "
+       Returns: float8 
+       portion of date 
+
+" {} "date_part(text,timespan) " {bold} "
+       Returns: float8 
+       portion of time 
+
+" {} "date_trunc(text,datetime) " {bold} "
+       Returns: datetime 
+       truncate date 
+
+" {} "isfinite(abstime) " {bold} "
+       Returns: bool 
+       a finite time? 
+
+" {} "isfinite(datetime) " {bold} "
+       Returns: bool 
+       a finite time? 
+
+" {} "isfinite(timespan) " {bold} "
+       Returns: bool 
+       a finite time? 
+
+" {} "reltime(timespan) " {bold} "
+       Returns: reltime 
+       convert to reltime 
+
+" {} "timespan(reltime) " {bold} "
+       Returns: timespan 
+       convert to timespan 
+
+
+" {} \
+"PostgreSQL functions\n" {link pgfunctions} \
+"Next - geometric functions" {link geomfunc}
diff --git a/src/bin/pgaccess/lib/help/declare.hlp b/src/bin/pgaccess/lib/help/declare.hlp
new file mode 100644 (file)
index 0000000..fcc4f7f
--- /dev/null
@@ -0,0 +1,29 @@
+.pgaw:Help.f.t insert end "DECLARE" {bold} " allows a user to create cursors, which can be used to retrieve a small number of rows at a time out of a larger query. Cursors can return data either in text or in binary foramt. 
+
+       Normal cursors return data in text format, either ASCII or another encoding scheme depending on how the Postgres backend was built. Since data is stored natively in binary format, the system \
+must do a conversion to produce the text format. In addition, text formats are often larger in size than the corresponding binary format. Once the information comes back in text form, the client \
+application may have to convert it to a binary format to manipulate it anyway. 
+
+BINARY cursors give you back the data in the native binary representation. So binary cursors will tend to be a little faster since they suffer less conversion overhead. 
+
+" {} "Synopsis" {bold} "
+
+DECLARE cursor \[ BINARY \] \[ INSENSITIVE \] \[ SCROLL \]
+    CURSOR FOR query
+    \[ FOR \[ READ ONLY | UPDATE \[ OF column \[, ...\] \] \]
+
+" {code} "Usage" {bold} "
+
+To declare a cursor: 
+" {} "
+DECLARE liahona CURSOR
+    FOR SELECT * FROM films;
+    
+" {code} "Notes" {bold} "
+
+Cursors are only available in transactions. 
+
+Postgres does not have an explicit OPEN cursor statement; a cursor is considered to be open when it is declared. 
+
+       Note: In SQL92 cursors are only available in embedded applications. ecpg, the embedded SQL preprocessor for Postgres, supports the SQL92 conventions, including those \
+       involving DECLARE and OPEN statements. "
diff --git a/src/bin/pgaccess/lib/help/delete.hlp b/src/bin/pgaccess/lib/help/delete.hlp
new file mode 100644 (file)
index 0000000..6bc94b0
--- /dev/null
@@ -0,0 +1,43 @@
+.pgaw:Help.f.t insert end "DELETE" {bold} " emoves rows which satisfy the WHERE condition, from the specified table.  \
+If the condition is absent, the effect is to delete all rows in the table. The result is a valid, but empty table.  \
+You must have write access to the table in order to modify it, as well as read access to any table whose values are read in the condition. 
+
+" {} "Synopsis" {bold} "
+" {} "
+   DELETE FROM table \[ WHERE condition \]
+   
+" {code} "Usage" {bold} "
+
+Remove all films but musicals: 
+" {} "
+DETETE FROM films WHERE kind <> 'Musical';
+
+SELECT * FROM films;
+
+code |title                    |did| date_prod|kind      |len
+-----+-------------------------+---+----------+----------+------
+UA501|West Side Story          |105|1961-01-03|Musical   | 02:32
+TC901|The King and I           |109|1956-08-11|Musical   | 02:13
+WD101|Bed Knobs and Broomsticks|111|          |Musical   | 01:57
+(3 rows)
+  
+
+Clear the table films: 
+
+DELETE FROM films;
+   
+SELECT * FROM films;
+code|title|did|date_prod|kind|len
+----+-----+---+---------+----+---
+(0 rows)
+
+" {code} "Compatibility" {bold} "
+
+SQL92 
+
+SQL92 allows a positioned DELETE statement: 
+
+DELETE FROM table WHERE CURRENT OF cursor
+   
+
+where cursor identifies an open cursor. Interactive cursors in Postgres are read-only. "
diff --git a/src/bin/pgaccess/lib/help/drop_aggregate.hlp b/src/bin/pgaccess/lib/help/drop_aggregate.hlp
new file mode 100644 (file)
index 0000000..79b00a4
--- /dev/null
@@ -0,0 +1,17 @@
+.pgaw:Help.f.t insert end "DROP AGGREGATE" {bold} " will remove all references to an existing aggregate definition. To execute this command the current user must be the owner of the aggregate. 
+
+" {} "Synopsis" {bold} "
+
+DROP AGGREGATE name type
+
+" {} "Usage" {bold} "
+
+To remove the myavg aggregate for type int4: 
+
+DROP AGGREGATE myavg int4;
+
+" {} "Notes" {bold} "
+
+The DROP AGGREGATE statement is a Postgres language extension. 
+
+Refer to the CREATE AGGREGATE statement to create aggregate functions. "
diff --git a/src/bin/pgaccess/lib/help/drop_database.hlp b/src/bin/pgaccess/lib/help/drop_database.hlp
new file mode 100644 (file)
index 0000000..e804731
--- /dev/null
@@ -0,0 +1,14 @@
+.pgaw:Help.f.t insert end "DROP DATABASE" {bold} " removes the catalog entries for an existing database and deletes the directory containing the data. It can only be executed by the database administrator (See the \
+CREATE DATABASE command for details). 
+
+" {} "Synopsis" {bold} "
+
+DROP DATABASE name
+
+" {} "Notes" {bold} "
+
+DROP DATABASE statement is a Postgres language extension. 
+
+       Tip: This query cannot be executed while connected to the target database. It is usually preferable to use the destroydb script instead. 
+
+Refer to the CREATE DATABASE statement for information on how to create a database. "
diff --git a/src/bin/pgaccess/lib/help/drop_function.hlp b/src/bin/pgaccess/lib/help/drop_function.hlp
new file mode 100644 (file)
index 0000000..f755889
--- /dev/null
@@ -0,0 +1,22 @@
+.pgaw:Help.f.t insert end \
+"DROP FUNCTION" {bold} " will remove references to an existing C function. To execute this command the user must be the owner of the function. The input argument types to the function must be specified, as only the function with the given name and argument types will be removed. 
+
+" {} "Synopsis" {bold} "
+
+DROP FUNCTION name ( \[ type \[, ...\] \] )
+" {code} "
+Inputs 
+" {} "name" {italic} "
+       The name of an existing function. 
+
+" {} "type" {italic} "
+       The type of function parameters. 
+
+Outputs 
+" {} "DROP" {code} "
+
+Message returned if the command completes successfully. 
+
+WARN RemoveFunction: Function \"name\" (\"types\") does not exist
+
+This message is given if the function specified does not exist in the current database."
diff --git a/src/bin/pgaccess/lib/help/drop_index.hlp b/src/bin/pgaccess/lib/help/drop_index.hlp
new file mode 100644 (file)
index 0000000..1b53db3
--- /dev/null
@@ -0,0 +1,17 @@
+.pgaw:Help.f.t insert end "DROP INDEX" {bold} " drops an existing index from the database system. To execute this command you must be the owner of the index. 
+
+" {} "Synopsis" {bold} "
+
+DROP INDEX index_name
+
+" {code} "Usage" {bold} "
+
+This command will remove the title_idx index: 
+" {} "
+DROP INDEX title_idx;
+  
+" {code} "Notes" {bold} "
+
+DROP INDEX is a Postgres language extension. 
+
+Refer to the CREATE INDEX statement for information on how to create indexes. "
diff --git a/src/bin/pgaccess/lib/help/drop_language.hlp b/src/bin/pgaccess/lib/help/drop_language.hlp
new file mode 100644 (file)
index 0000000..77baf90
--- /dev/null
@@ -0,0 +1,17 @@
+.pgaw:Help.f.t insert end "DROP LANGUAGE" {bold} " will remove the definition of the previously registered procedural language having the name 'langname'. 
+
+" {} "Synopsis" {bold} "
+
+DROP PROCEDURAL LANGUAGE 'langname'
+
+" {code} "Usage" {bold} "
+
+This command removes the PL/Sample language: 
+" {} "
+DROP PROCEDURAL LANGUAGE 'plsample'
+
+" {code} "Notes" {bold} "
+
+The DROP PROCEDURAL LANGUAGE statement is a Postgres language extension. 
+
+Refer to CREATE PROCEDURAL LANGUAGE for information on how to create procedural languages. "
diff --git a/src/bin/pgaccess/lib/help/drop_operator.hlp b/src/bin/pgaccess/lib/help/drop_operator.hlp
new file mode 100644 (file)
index 0000000..e664316
--- /dev/null
@@ -0,0 +1,32 @@
+.pgaw:Help.f.t insert end "DROP OPERATOR" {bold} " The DROP OPERATOR statement drops an existing operator from the database. To execute this command you must be the owner of the operator.  \
+The left or right type of a left or right unary operator, respectively, may be specified as NONE. 
+
+" {} "Synopsis" {bold} "
+" {} "
+DROP OPERATOR id ( type | NONE \[,...\] )
+
+" {code} "Usage" {bold} "
+
+Remove power operator a^n for int4: 
+" {} "
+DROP OPERATOR ^ (int4, int4);
+  
+" {code} "
+Remove left unary operator !a for booleans: 
+" {} "
+DROP OPERATOR ! (none, bool);
+  
+" {code} "
+Remove right unary factorial operator a! for int4: 
+" {} "
+DROP OPERATOR ! (int4, none);
+
+
+" {code} "Notes" {bold} "
+
+The DROP OPERATOR statement is a Postgres language extension. 
+
+Refer to CREATE OPERATOR for information on how to create operators. 
+
+It is the user's responsibility to remove any access methods and operator classes that rely on the deleted operator. 
+"
diff --git a/src/bin/pgaccess/lib/help/drop_rule.hlp b/src/bin/pgaccess/lib/help/drop_rule.hlp
new file mode 100644 (file)
index 0000000..1c395f5
--- /dev/null
@@ -0,0 +1,17 @@
+.pgaw:Help.f.t insert end "DROP RULE" {bold} " drops a rule from the specified Postgres rule system. Postgres will immediately cease enforcing it and will purge its definition from the system catalogs. 
+
+" {} "Synopsis" {bold} "
+
+DROP RULE name
+
+" {} "Usage" {bold} "
+
+To drop the rewrite rule newrule: 
+
+   DROP RULE newrule
+   
+" {} "Notes" {bold} "
+
+The DROP RULE statement is a Postgres language extension. 
+
+Refer to CREATE RULE for information on how to create rules. "
diff --git a/src/bin/pgaccess/lib/help/drop_sequence.hlp b/src/bin/pgaccess/lib/help/drop_sequence.hlp
new file mode 100644 (file)
index 0000000..7b2a16c
--- /dev/null
@@ -0,0 +1,17 @@
+.pgaw:Help.f.t insert end "DROP SEQUENCE" {bold} " removes sequence number generators from the data base. With the current implementation of sequences as special tables it works just like the DROP TABLE statement.
+
+" {} "Synopsis" {bold} "
+" {} "
+DROP SEQUENCE seqname \[, ...\]
+
+" {code} "Usage" {bold} "
+
+To remove sequence serial from database: 
+
+DROP SEQUENCE serial
+  
+" {} "Notes" {bold} "
+
+The DROP SEQUENCE statement is a Postgres language extension. 
+
+Refer to the CREATE SEQUENCE statement for information on how to create a sequence. "
diff --git a/src/bin/pgaccess/lib/help/drop_table.hlp b/src/bin/pgaccess/lib/help/drop_table.hlp
new file mode 100644 (file)
index 0000000..1f85e53
--- /dev/null
@@ -0,0 +1,17 @@
+.pgaw:Help.f.t insert end "DROP TABLE" {bold} " removes tables and views from the database. Only its owner may destroy a table or view. A table may be emptied of rows, but not destroyed, by using DELETE. 
+
+If a table being destroyed has secondary indexes on it, they will be removed first. The removal of just a secondary index will not affect the contents of the underlying table. 
+
+" {} "Synopsis" {bold} "
+" {} "
+DROP TABLE table \[, ...\]
+
+" {code} "Usage" {bold} "
+
+To destroy the films and distributors tables: 
+
+DROP TABLE films, distributors
+
+" {} "Notes" {bold} "
+
+Refer to CREATE TABLE and ALTER TABLE for information on how to create or modify tables. "
diff --git a/src/bin/pgaccess/lib/help/drop_trigger.hlp b/src/bin/pgaccess/lib/help/drop_trigger.hlp
new file mode 100644 (file)
index 0000000..8a3d69e
--- /dev/null
@@ -0,0 +1,17 @@
+.pgaw:Help.f.t insert end "DROP TRIGGER" {bold} " will remove all references to an existing trigger definition. To execute this command the current user must be the owner of the trigger. 
+
+" {} "Synopsis" {bold} "
+
+DROP TRIGGER name ON table
+
+" {} "Usage" {bold} "
+
+Destroy the if_dist_exists trigger on table films: 
+
+DROP TRIGGER if_dist_exists ON films;
+
+" {} "Notes" {bold} "
+
+DROP TRIGGER is a Postgres language extension. 
+
+Refer to CREATE TRIGGER for information on how to create triggers. "
diff --git a/src/bin/pgaccess/lib/help/drop_type.hlp b/src/bin/pgaccess/lib/help/drop_type.hlp
new file mode 100644 (file)
index 0000000..dd02b64
--- /dev/null
@@ -0,0 +1,20 @@
+.pgaw:Help.f.t insert end "DROP TYPE" {bold} " will remove a user type from the system catalogs. 
+
+" {} "Synopsis" {bold} "
+
+DROP TYPE typename
+
+" {} "Usage" {bold} "
+
+To remove the box type: 
+
+DROP TYPE box
+
+" {} "Notes" {bold} "
+
+DROP TYPE statement is a Postgres language extension. 
+
+Refer to CREATE TYPE for inforamation on how to create types. 
+
+It is the user's responsibility to remove any operators, functions, aggregates, access methods, subtypes, and classes that use a deleted type. 
+"
diff --git a/src/bin/pgaccess/lib/help/drop_user.hlp b/src/bin/pgaccess/lib/help/drop_user.hlp
new file mode 100644 (file)
index 0000000..578c65f
--- /dev/null
@@ -0,0 +1,19 @@
+.pgaw:Help.f.t insert end "DROP USER" {bold} " removes the specified user from the database, along with any databases owned by the user. It does not remove tables, views, or triggers owned by the named user in databases \
+not owned by the user. This statement can be used in place of the destroyuser script, regardless of how the user was created. 
+
+" {} "Synopsis" {bold} "
+
+DROP USER username
+
+" {} "Usage" {bold} "
+
+To drop a user account: 
+
+DROP USER Jonathan;
+
+" {} "Notes" {bold} "
+
+DROP USER is a Postgres language extension. 
+
+Refer to CREATE USER and ALTER USER for information on how to create or modify user accounts. 
+"
diff --git a/src/bin/pgaccess/lib/help/drop_view.hlp b/src/bin/pgaccess/lib/help/drop_view.hlp
new file mode 100644 (file)
index 0000000..0ad4811
--- /dev/null
@@ -0,0 +1,17 @@
+.pgaw:Help.f.t insert end "DROP VIEW" {bold} " drops an existing view from the database. To execute this command you must be the owner of the view. 
+
+" {} "Synopsis" {bold} "
+
+DROP VIEW view
+
+" {} "Usage" {bold} "
+
+This command will remove the view called kinds: 
+
+DROP VIEW kinds;
+
+" {} "Notes" {bold} "
+
+The Postgres DROP TABLE statement also drops views. 
+
+Refer to CREATE VIEW for information on how to create views. "
diff --git a/src/bin/pgaccess/lib/help/explain.hlp b/src/bin/pgaccess/lib/help/explain.hlp
new file mode 100644 (file)
index 0000000..fccab57
--- /dev/null
@@ -0,0 +1,23 @@
+.pgaw:Help.f.t insert end "EXPLAIN" {bold} " This command outputs details about the supplied query. The default output is the computed query cost. The cost value is only meaningful to the optimizer in comparing various query plans. \
+VERBOSE displays the full query plan and cost to your screen, and pretty-prints the plan to the postmaster log file. 
+
+" {} "Synopsis" {bold} "
+" {} "
+EXPLAIN \[ VERBOSE \] query 
+
+" {code} "Usage" {bold} "
+
+To show a query plan for a simple query: 
+" {} "
+postgres=> explain select * from foo;
+NOTICE:  QUERY PLAN:
+
+Seq Scan on foo  (cost=0.00 rows=0 width=4)
+
+EXPLAIN
+
+" {code} "Notes" {bold} "
+
+There is only sparse documentation on the optimizer's use of cost information in Postgres. General information on cost estimation for query optimization can be found in database textbooks.
+Refer to the Programmer's Guide in the chapters on indexes and the genetic query optimizer for more \
+information."
diff --git a/src/bin/pgaccess/lib/help/fetch.hlp b/src/bin/pgaccess/lib/help/fetch.hlp
new file mode 100644 (file)
index 0000000..b15be45
--- /dev/null
@@ -0,0 +1,62 @@
+.pgaw:Help.f.t insert end "FETCH" {bold} " FETCH allows a user to retrieve rows using a cursor. The number of rows retrieved is specified by #. If the number of rows remaining in the cursor is less than #, then only those available are \
+fetched. Substituting the keyword ALL in place of a number will cause all remaining rows in the cursor to be retrieved. Instances may be fetched in both FORWARD and BACKWARD \
+directions. The default direction is FORWARD. 
+
+       Tip: Negative numbers are now allowed to be specified for the row count. A negative number is equivalent to reversing the sense of the FORWARD and BACKWARD \
+       keywords. For example, FORWARD -1 is the same as BACKWARD 1.
+
+Note that the FORWARD and BACKWARD keywords are Postgres extensions. The SQL92 syntax is also supported, specified in the second form of the command. See below for details on \
+compatibility issues.
+
+Once all rows are fetched, every other fetch access returns no rows.
+
+Updating data in a cursor is not supported by Postgres, because mapping cursor updates back to base tables is not generally possible, as is also the case with VIEW updates. Consequently, \
+users must issue explicit UPDATE commands to replace data.
+
+Cursors may only be used inside of transactions because the data that they store spans multiple user queries.
+
+" {} "Synopsis" {bold} "
+" {} "
+FETCH \[ selector \] \[ count \] 
+    \{ IN | FROM \} cursor
+FETCH \[ RELATIVE \] \[ \{ \[ # | ALL | NEXT | PRIOR \] \} \]
+    FROM \] cursor
+    
+" {code} "Usage" {bold} "
+" {} "
+   --set up and use a cursor:
+   --
+   BEGIN WORK;
+     DECLARE liahona CURSOR
+        FOR SELECT * FROM films;
+
+   --Fetch first 5 rows in the cursor liahona:
+   --
+     FETCH FORWARD 5 IN liahona;
+
+     code |title                  |did| date_prod|kind      |len
+     -----+-----------------------+---+----------+----------+------
+     BL101|The Third Man          |101|1949-12-23|Drama     | 01:44
+     BL102|The African Queen      |101|1951-08-11|Romantic  | 01:43
+     JL201|Une Femme est une Femme|102|1961-03-12|Romantic  | 01:25
+     P_301|Vertigo                |103|1958-11-14|Action    | 02:08
+     P_302|Becket                 |103|1964-02-03|Drama     | 02:28
+
+   --Fetch previous row:
+   --
+     FETCH BACKWARD 1 IN liahona;
+
+     code |title                  |did| date_prod|kind      |len
+     -----+-----------------------+---+----------+----------+------
+     P_301|Vertigo                |103|1958-11-14|Action    | 02:08
+
+   -- close the cursor and commit work:
+   --
+     CLOSE liahona;
+   COMMIT WORK;
+   
+" {code} "Notes" {bold} "
+
+Refer to MOVE statements to change cursor position. Refer to DECLARE statements to declare a cursor. Refer to BEGIN WORK, COMMIT WORK, ROLLBACK WORK statements for \
+further information about transactions."
diff --git a/src/bin/pgaccess/lib/help/form_design.hlp b/src/bin/pgaccess/lib/help/form_design.hlp
new file mode 100644 (file)
index 0000000..0912862
--- /dev/null
@@ -0,0 +1,27 @@
+.pgaw:Help.f.t insert end "Form designing" {title} "
+
+For the moment, it has only some basic widgets : labels, entries, buttons , listboxes\
+, checkboxes and radiobuttons. Also there is a pseudo query widget that allows you\
+to have access to a query results. 
+
+How do you generate widgets : 
+ -select a widget from the toolbox by clicking the appropriate icon 
+ -move to the canvas , point with the mouse at the desired location and click the mouse button to begin 
+ -keeping the mouse-button pressed move the mouse in order to draw a rectangle that will hold the widget 
+ -release the mouse-button 
+
+  In the rectangle that you have designed it will appear the selected object. Move now to the attribute window to change some of its properties. 
+
+  Renaming, resizing items are possible (for the moment) only by modifying appropriate parameters in attribute window. You must press Enter in the edit field after changing a dimension in order to be accepted.  You can also move items by dragging them or delete them by pressing Del key after selecting them. 
+
+  In attribute window, there are some fields named Command and Variable. The field Command have meaning only for Button or checkboxes widgets and holds the command that will be invoked when the button is pressed. Also, there is a \"autoload\" style script for the form that will be executed when form will bne opened.
+
+  The field Variable have meaning only for Buttons, EditField , Label widgets , checkboxes and radiobuttons and it is the name of the global variable that will hold the value for that widget. For checkboxes the values are t and f (from true and false) in order to simplify binding to logical data fields. 
+
+  For radiobuttons, it is usual to assign the same variable to the same radiobuttons within the same group. That variable will contain the value field from the radiobutton that has been pressed. Let's presume that you have entered 3 radiobuttons with values red, green and blue, all of them having the same variable named color. If you will press them, they will assign their names to global variable. 
+
+  In order to make a simple test, put an entry field and set it's variable to v1 and a button who's command is \"set v1 whisky\". Press the button \"Test form\" and click on the button. In that entry should appear whisky. 
+
+  Another test is defining in Script module a script called \"My first script\" having the following commands: 
+" {} "tk_messageBox -title Warning -message \"This is my first message!\" " {code} "
+and then define a button with the command is Scripts::execute \"My first script\". "
diff --git a/src/bin/pgaccess/lib/help/forms.hlp b/src/bin/pgaccess/lib/help/forms.hlp
new file mode 100644 (file)
index 0000000..65f8058
--- /dev/null
@@ -0,0 +1,19 @@
+.pgaw:Help.f.t insert end "Forms" {title} "
+
+  Forms" {bold} " tab is used to inspect, create and design\
+database stored forms that can be later executed.
+
+  Forms are actually Tcl/Tk code stored in the opened database in a special table called \"pga_forms\" \
+and they can be executed by selecting it and pressing the \"Open\" button.
+
+  The design module will allow you do define the graphical layout of the form and\
+to bind Tcl/Tk code to different widgets. You will really need to know Tcl/Tk in\
+order to be able to write PgAccess forms.
+
+  Due to internal limits of PostgreSQL that cannot store more than 8Kb per record\
+and taking into account that pga_forms store one form per record it's possible that\
+too complicated forms cannot be stored into the table. Too complicated code in\
+forms could be stored in scripts instead thought scripts also are limited to the\
+8 Kb size.
+
+  See also " {} "form designing" {link form_design}
diff --git a/src/bin/pgaccess/lib/help/functions.hlp b/src/bin/pgaccess/lib/help/functions.hlp
new file mode 100644 (file)
index 0000000..2bb4318
--- /dev/null
@@ -0,0 +1,32 @@
+.pgaw:Help.f.t insert end "Functions" {title} "
+
+  The Functions tab is used to inspect the user defined functions in the\
+database, to define new functions and to alter the existing ones.
+
+  Press the \"New\" button to define a new function. You should enter the\
+function name, the function parameters (if any) separated by comma. \
+If function returns a value, you should specify the " {} \
+"PostgreSQL data type" {link data_types} " that function will return.
+
+  You must also specify the language that will be used to parse the defined\
+function. You could specify SQL, plpgsql, pgtcl or C. Then you should enter the\
+function body. Press \"Save\" button in order to save it
+
+" {} "Example:" {italic} "
+  We have a table called \"products\" that is indexed on \"id\" (int4) field and\
+contains the float8 field \"price\". We will define a new function \"get_product_price\"\
+that will return the product price for a given id.
+
+  You should enter " {} "get_product_price" {code} " as the function name, " {} \
+"int4" {code} " in parameters entry, " {} "float8" {code} " for returns, " {} \
+"SQL" {code} " for the language. Then go to the function body definition and type:" {} "
+
+SELECT price FROM products where id = \$1" {code} "
+
+  To delete a function, select it from the list box and use the menu command\
+Object/Delete.
+
+  For more information see SQL commands " {} "CREATE FUNCTION" {link create_function} " and " {} \
+"DROP FUNCTION" {link drop_function}
+
+
diff --git a/src/bin/pgaccess/lib/help/geomfunc.hlp b/src/bin/pgaccess/lib/help/geomfunc.hlp
new file mode 100644 (file)
index 0000000..c7a4029
--- /dev/null
@@ -0,0 +1,73 @@
+.pgaw:Help.f.t insert end \
+"Geometric functions\n\n" {title} \
+"area(box) " {bold} "
+       Returns: float8 
+       area of box 
+
+" {} "area(circle) " {bold} "
+       Returns: float8 
+       area of circle 
+
+" {} "box(box,box) " {bold} "
+       Returns: box 
+       boxes to intersection box 
+
+" {} "center(box) " {bold} "
+       Returns: point 
+       center of object 
+
+" {} "center(circle) " {bold} "
+       Returns: point 
+       center of object 
+
+" {} "diameter(circle) " {bold} "
+       Returns: float8 
+       diameter of circle 
+
+" {} "height(box) " {bold} "
+       Returns: float8 
+       vertical size of box 
+
+" {} "isclosed(path) " {bold} "
+       Returns: bool 
+       a closed path? 
+
+" {} "isopen(path) " {bold} "
+       Returns: bool 
+       an open path? 
+
+" {} "length(lseg) " {bold} "
+       Returns: float8 
+       length of line segment 
+
+" {} "length(path) " {bold} "
+       Returns: float8 
+       length of path 
+
+" {} "pclose(path) " {bold} "
+       Returns: path 
+       convert path to closed 
+
+" {} "point(lseg,lseg) " {bold} "
+       Returns: point 
+       intersection 
+
+" {} "points(path) " {bold} "
+       Returns: int4 
+       number of points 
+
+" {} "popen(path) " {bold} "
+       Returns: path 
+       convert path to open 
+
+" {} "radius(circle) " {bold} "
+       Returns: float8 
+       radius of circle 
+
+" {} "width(box) " {bold} "
+       Returns: float8 
+       horizontal size 
+
+" {} \
+"PostgreSQL functions\n" {link pgfunctions} \
+"Next - IP V4 functions" {link ipv4func}
diff --git a/src/bin/pgaccess/lib/help/grant.hlp b/src/bin/pgaccess/lib/help/grant.hlp
new file mode 100644 (file)
index 0000000..e403441
--- /dev/null
@@ -0,0 +1,52 @@
+.pgaw:Help.f.t insert end "GRANT" {bold} " GRANT allows the creator of an object to give specific permissions to all users (PUBLIC) or to a certain user or group. Users other than the creator don't have any access permission unless \
+the creator GRANTs permissions, after the object is created. 
+
+Once a user has a privilege on an object, he is enabled to exercise that privilege. There is no need to GRANT privileges to the creator of an object, the creator automatically holds ALL \
+privileges, and can also drop the object. 
+
+" {} "Synopsis" {bold} "
+" {} "
+      GRANT privilege \[, ...\]
+      ON object \[, ...\]
+      TO \{ PUBLIC | GROUP group | username \}
+
+" {code} "Usage" {bold} "
+" {} "
+        -- grant insert privilege to all users on table films:
+        --
+        GRANT INSERT ON films TO PUBLIC;
+      
+
+        -- grant all privileges to user manuel on view kinds:
+        --
+        GRANT ALL ON kinds TO manuel;
+
+" {code} "Notes" {bold} " 
+
+Use the psql \\z command for further information about permissions on existing objects: 
+" {} "
+          Database    = lusitania
+   +------------------+------------------------------------------------+
+   |  Relation        |            Grant/Revoke Permissions            |
+   +------------------+------------------------------------------------+
+   | mytable          | \{\"=rw\",\"miriam=arwR\",\"group todos=rw\"\} |
+   +------------------+------------------------------------------------+
+   Legend:
+         uname=arwR -- privileges granted to a user
+   group gname=arwR -- privileges granted to a GROUP
+              =arwR -- privileges granted to PUBLIC
+
+                  r -- SELECT
+                  w -- UPDATE/DELETE
+                  a -- INSERT
+                  R -- RULE
+               arwR -- ALL
+" {code} "Tip" {bold} "       
+
+       Tip: Currently, to create a GROUP you have to insert data manually into table pg_group as: 
+
+                     INSERT INTO pg_group VALUES ('todos');
+                     CREATE USER miriam IN GROUP todos;
+                   
+
+       Refer to REVOKE statements to revoke access privileges. "
diff --git a/src/bin/pgaccess/lib/help/history.hlp b/src/bin/pgaccess/lib/help/history.hlp
new file mode 100644 (file)
index 0000000..60ef551
--- /dev/null
@@ -0,0 +1,43 @@
+.pgaw:Help.f.t insert end \
+"PostgreSQL history\n\n" {title} \
+"The Berkeley Postgres project\n" {bold} \
+"Implementation of the Postgres DBMS began in 1986. The initial concepts for the system were presented in The Design of Postgres and the definition of the initial data model appeared in The Postgres Data Model. The design of the rule system at that time was described in The Design of the Postgres Rules System. The rationale and architecture of the storage manager were detailed in The Postgres Storage System.
+
+Postgres has undergone several major releases since then. The first 'demoware' system became operational in 1987 and was shown at the 1988 ACM-SIGMOD Conference. We released Version 1, described in The Implementation of Postgres, to a few external users in June 1989. In response to a critique of the first rule system (A Commentary on the Postgres Rules System), the rule system was redesigned (On Rules, Procedures, Caching and Views in Database Systems) and Version 2 was released in June 1990 with the new rule system. Version 3 appeared in 1991 and added support for multiple storage managers, an improved query executor, and a rewritten rewrite rule system. For the most part, releases since then have focused on portability and reliability.
+
+Postgres has been used to implement many different research and production applications. These include: a financial data analysis system, a jet engine performance monitoring package, an asteroid tracking database, a medical information database, and several geographic information systems. Postgres has also been used as an educational tool at several universities. Finally, Illustra Information Technologies (since merged into Informix) picked up the code and commercialized it. Postgres became the primary data manager for the Sequoia 2000 scientific computing project in late 1992. Furthermore, the size of the external user community nearly doubled during 1993. It became increasingly obvious that maintenance of the prototype code and support was taking up large amounts of time that should have been devoted to database research. In an effort to reduce this support burden, the project officially ended with Version 4.2.
+
+" {} \
+"Postgres95\n" {bold} \
+"In 1994, Andrew Yu and Jolly Chen added a SQL language interpreter to Postgres, and the code was subsequently released to the Web to find its own way in the world. Postgres95 was a public-domain, open source descendant of this original Berkeley code.
+
+Postgres95 is a derivative of the last official release of Postgres (version 4.2). The code is now completely ANSI C and the code size has been trimmed by 25%. There are a lot of internal changes that improve performance and code maintainability. Postgres95 v1.0.x runs about 30-50% faster on the Wisconsin Benchmark compared to v4.2. Apart from bug fixes, these are the major enhancements: 
+
+The query language Postquel has been replaced with SQL (implemented in the server). We do not yet support subqueries (which can be imitated with user defined SQL functions). Aggregates have been re-implemented. We also added support for ``GROUP BY''. The libpq interface is still available for C programs.
+
+In addition to the monitor program, we provide a new program (psql) which supports GNU readline.
+
+We added a new front-end library, libpgtcl, that supports Tcl-based clients. A sample shell, pgtclsh, provides new Tcl commands to interface tcl programs with the Postgres95 backend.
+
+The large object interface has been overhauled. We kept Inversion large objects as the only mechanism for storing large objects. (This is not to be confused with the Inversion file system which has been removed.)
+
+The instance-level rule system has been removed. Rules are still available as rewrite rules.
+
+A short tutorial introducing regular SQL features as well as those of ours is distributed with the source code.
+
+GNU make (instead of BSD make) is used for the build. Also, Postgres95 can be compiled with an unpatched gcc (data alignment of doubles has been fixed).
+
+
+" {} \
+"PostgreSQL\n" {bold} \
+"By 1996, it became clear that the name \"Postgres95\" would not stand the test of time. A new name, PostgreSQL, was chosen to reflect the relationship between original Postgres and the more recent versions with SQL capability. At the same time, the version numbering was reset to start at 6.0, putting the numbers back into the sequence originally begun by the Postgres Project.
+
+The emphasis on development for the v1.0.x releases of Postgres95 was on stabilizing the backend code. With the v6.x series of PostgreSQL, the emphasis has shifted from identifying and understanding existing problems in the backend to augmenting features and capabilities, although work continues in all areas.
+
+Major enhancements include:
+
+- Important backend features, including subselects, defaults, constraints, and triggers, have been implemented.
+- Additional SQL92-compliant language features have been added, including primary keys, quoted identifiers, literal string type coersion, type casting, and binary and hexadecimal integer input.
+- Built-in types have been improved, including new wide-range date/time types and additional geometric type support.
+- Overall backend code speed has been increased by approximately 20-40%, and backend startup time has decreased 80% since v6.0 was released."
+
diff --git a/src/bin/pgaccess/lib/help/index.hlp b/src/bin/pgaccess/lib/help/index.hlp
new file mode 100644 (file)
index 0000000..c2928a4
--- /dev/null
@@ -0,0 +1,19 @@
+.pgaw:Help.f.t insert end \
+"PgAccess help index" {title} \
+"
+
+Topics available:
+" {} \
+"      Tables\n" {link tables} \
+"      Queries\n" {link queries} \
+"      Views\n" {link views} \
+"      Sequences\n" {link sequences} \
+"      Functions\n" {link functions} \
+"      Reports\n" {link reports} \
+"      Forms\n" {link forms} \
+"      Scripts\n" {link scripts} \
+"      Users\n" {link users} \
+"      Schema\n\n" {link schema} \
+"      PostgreSQL\n" {link postgresql} \
+"      The author of PgAccess\n" {link author}
+
diff --git a/src/bin/pgaccess/lib/help/inheritance.hlp b/src/bin/pgaccess/lib/help/inheritance.hlp
new file mode 100644 (file)
index 0000000..b402c30
--- /dev/null
@@ -0,0 +1,49 @@
+.pgaw:Help.f.t insert end \
+"Inheritance" {title} "
+
+Let's create two classes. The capitals class contains state capitals which are also cities. Naturally, the capitals class should inherit from cities. 
+
+" {} "CREATE TABLE cities (
+       name            text,
+       population      float,
+       altitude        int            -- (in ft)
+       );
+
+CREATE TABLE capitals (
+       state           char2
+       ) INHERITS (cities);
+" {code} "
+In this case, an instance of capitals inherits all attributes (name, population, and altitude) from its parent, cities. The type of the attribute name is text, a native Postgres type for variable length ASCII strings. The type of the attribute population is float, a native Postgres type for double precision floating point numbers. State capitals have an extra attribute, state, that shows their state. In Postgres, a class can inherit from zero or more other classes, and a query can reference either all instances of a class or all instances of a class plus all of its descendants. 
+
+" {} "Note" {italic} ": The inheritance hierarchy is a actually a directed acyclic graph.
+
+For example, the following query finds all the cities that are situated at an attitude of 500ft or higher: 
+
+" {} "SELECT name, altitude FROM cities WHERE altitude > 500;
+
++----------+----------+
+|name      | altitude |
++----------+----------+
+|Las Vegas | 2174     |
++----------+----------+
+|Mariposa  | 1953     |
++----------+----------+
+" {code} "
+On the other hand, to find the names of all cities, including state capitals, that are located at an altitude over 500ft, the query is: 
+
+" {} "SELECT c.name, c.altitude        FROM cities* c WHERE c.altitude > 500;
+
+" {code} "which returns:" {} " 
+
++----------+----------+
+|name      | altitude |
++----------+----------+
+|Las Vegas | 2174     |
++----------+----------+
+|Mariposa  | 1953     |
++----------+----------+
+|Madison   | 845      |
++----------+----------+
+" {code} "
+Here the \"*\" after cities indicates that the query should be run over cities and all classes below cities in the inheritance hierarchy. Many of the commands that we have already discussed -- select, update and delete -- support this \"*\" notation, as do others, like alter.
+" {}
diff --git a/src/bin/pgaccess/lib/help/insert.hlp b/src/bin/pgaccess/lib/help/insert.hlp
new file mode 100644 (file)
index 0000000..961fe25
--- /dev/null
@@ -0,0 +1,54 @@
+.pgaw:Help.f.t insert end "INSERT" {bold} "  allows one to insert new rows into a table. One can insert a single row at time or several rows as a result of a query. The columns in the target list may be listed in any order. In every \
+column not present in the target list will be inserted the default value, if column has not a declared default value it will be assumed as NULL. If the expression for each column is not of the \
+correct data type, automatic type coercion will be attempted. 
+
+" {} "Synopsis" {bold} "
+" {} "
+   INSERT INTO table \[ ( column \[, ...\] ) \]
+   \{ VALUES ( expression \[, ...\] ) | SELECT query \}
+
+" {code} "Usage" {bold} "
+" {} "
+                --Insert a single row into table films;
+                --(in the second example the column date_prod is omitted 
+                --therefore will be stored in it a default value of NULL):
+                --
+                INSERT INTO films VALUES
+                ('UA502','Bananas',105,'1971-07-13','Comedy',INTERVAL '82 minute');
+                
+                INSERT INTO films (code, title, did, date_prod, kind)
+                VALUES ('T_601', 'Yojimbo', 106, DATE '1961-06-16', 'Drama');
+          
+
+                --Insert a single row into table distributors, note that
+                --only column \"name\" is specified, to the non specified
+                --column \"did\" will be assigned its default value:
+                --
+                INSERT INTO distributors (name) VALUES ('British Lion');
+          
+
+                --Insert several rows into table films from table tmp:
+                --
+                INSERT INTO films
+                SELECT * FROM tmp;
+          
+
+                --Insert into arrays:
+                --Create an empty 3x3 gameboard for noughts-and-crosses
+                --(all of these queries create the same board attribute)
+                --(Refer to the PostgreSQL User's Guide for further
+                --information about arrays).
+                
+                INSERT INTO tictactoe (game, board\[1:3\]\[1:3\])
+                    VALUES (1,'\{\{\"\",\"\",\"\"\},\{\},\{\"\",\"\"\}\}');
+                INSERT INTO tictactoe (game, board\[3\]\[3\])
+                    VALUES (2,'\{\}');
+                INSERT INTO tictactoe (game, board)
+                    VALUES (3,'\{\{,,\},\{,,\},\{,,\}\}');
+
+" {code} "Compatibility" {bold} "
+
+SQL92 
+
+The INSERT statement is fully compatible with SQL92. Possible limitations in features of the query clause are documented for the SELECT statement. 
+"
diff --git a/src/bin/pgaccess/lib/help/ipv4func.hlp b/src/bin/pgaccess/lib/help/ipv4func.hlp
new file mode 100644 (file)
index 0000000..a920658
--- /dev/null
@@ -0,0 +1,28 @@
+.pgaw:Help.f.t insert end \
+"IP V4 functions\n\n" {title} \
+"broadcast(cidr)" {bold} " 
+       Returns: text 
+       construct broadcast address as text 
+
+" {} "broadcast(inet) " {bold} "
+       Returns: text 
+       construct broadcast address as text 
+
+" {} "host(inet) " {bold} "
+       Returns: text 
+       extract host address as text 
+
+" {} "masklen(cidr) " {bold} "
+       Returns: int4 
+       calculate netmask length 
+
+" {} "masklen(inet) " {bold} "
+       Returns: int4 
+       calculate netmask length 
+
+" {} "netmask(inet) " {bold} "
+       Returns: text 
+       construct netmask as text 
+
+" {} \
+"PostgreSQL functions\n" {link pgfunctions}
diff --git a/src/bin/pgaccess/lib/help/isolation.hlp b/src/bin/pgaccess/lib/help/isolation.hlp
new file mode 100644 (file)
index 0000000..3e51be4
--- /dev/null
@@ -0,0 +1,24 @@
+.pgaw:Help.f.t insert end \
+"Isolation levels" {title} "
+
+" {} "Read Committed Isolation Level" {bold} "
+
+Read Committed is the default isolation level in Postgres. When a transaction runs on this isolation level, a query sees only data committed before the query began and never sees either dirty data or concurrent transaction changes committed during query execution. 
+
+If a row returned by a query while executing an UPDATE statement (or DELETE or SELECT FOR UPDATE) is being updated by a concurrent uncommitted transaction then the second transaction that tries to update this row will wait for the other transaction to commit or rollback. In the case of rollback, the waiting transaction can proceed to change the row. In the case of commit (and if the row still exists; i.e. was not deleted by the other transaction), the query will be re-executed for this row to check that new row version satisfies query search condition. If the new row version satisfies the query search condition then row will be updated (or deleted or marked for update). 
+
+Note that the results of execution of SELECT or INSERT (with a query) statements will not be affected by concurrent transactions. 
+
+
+" {} "Serializable Isolation Level" {bold} "
+
+Serializable provides the highest transaction isolation. When a transaction is on the serializable level, a query sees only data committed before the transaction began and never see either dirty data or concurrent transaction changes committed during transaction execution. So, this level emulates serial transaction execution, as if transactions would be executed one after another, serially, rather than concurrently. 
+
+If a row returned by query while executing a UPDATE (or DELETE or SELECT FOR UPDATE) statement is being updated by a concurrent uncommitted transaction then the second transaction that tries to update this row will wait for the other transaction to commit or rollback. In the case of rollback, the waiting transaction can proceed to change the row. In the case of a concurrent transaction commit, a serializable transaction will be rolled back with the message 
+
+" {} "ERROR:  Can't serialize access due to concurrent update" {code} "
+
+because a serializable transaction cannot modify rows changed by other transactions after the serializable transaction began. 
+
+" {} "Note" {italic} ":  Note that results of execution of SELECT or INSERT (with a query) will not be affected by concurrent transactions. 
+"
diff --git a/src/bin/pgaccess/lib/help/keywords.hlp b/src/bin/pgaccess/lib/help/keywords.hlp
new file mode 100644 (file)
index 0000000..873f448
--- /dev/null
@@ -0,0 +1,85 @@
+.pgaw:Help.f.t insert end \
+"PostgreSQL reserved key words\n\n" {title} \
+"The following are Postgres reserved words which are also SQL92 or SQL3 reserved words: " {} \
+"
+ADD ALL ALTER AND ANY AS ASC
+BEGIN BETWEEN BOTH BY
+CASCADE CAST CHAR CHARACTER CHECK CLOSE 
+COLLATE COLUMN COMMIT CONSTRAINT 
+CREATE CURRENT_DATE CURRENT_TIME 
+CURRENT_TIMESTAMP CURRENT_USER CURSOR
+DECIMAL DECLARE DEFAULT DELETE DESC DISTINCT DROP
+EXECUTE EXISTS EXTRACT
+FETCH FLOAT FOR FROM FULL
+GRANT 
+HAVING
+IN INNER INSERT INTERVAL INTO IS
+JOIN 
+LEADING LEFT LIKE LOCAL
+NAMES NATIONAL NATURAL NCHAR NO NOT NULL NUMERIC
+ON OR OUTER
+PARTIAL PRIMARY PRIVILEGES PROCEDURE PUBLIC
+REFERENCES REVOKE RIGHT ROLLBACK
+SELECT SET SUBSTRING
+TO TRAILING TRIM 
+UNION UNIQUE UPDATE USER USING
+VALUES VARCHAR VARYING VIEW
+WHERE WITH WORK 
+
+" {code} \
+"The following are Postgres reserved words which are neither SQL92 nor SQL3 reserved words. These are allowed to be present as column labels, but not as identifiers: " {} \
+"
+ABORT ANALYZE 
+BINARY 
+CLUSTER CONSTRAINT COPY
+DO 
+EXPLAIN EXTEND
+LISTEN LOAD LOCK 
+MOVE 
+NEW NONE NOTIFY 
+RESET 
+SETOF SHOW
+UNLISTEN UNTIL 
+VACUUM VERBOSE
+
+" {code} \
+"The following are Postgres reserved words which are also SQL92 or SQL3 reserved words, and which are allowed to be present as column labels, but not as identifiers: " {} \
+"
+CASE COALESCE CROSS CURRENT 
+ELSE END
+FALSE FOREIGN 
+GLOBAL GROUP 
+LOCAL
+NULLIF
+ORDER 
+POSITION PRECISION 
+TABLE THEN TRANSACTION TRUE
+WHEN
+
+" {code} \
+"The following are either SQL92 or SQL3 reserved key words which are not key words in Postgres. These have no proscribed usage in Postgres at the time of writing (v6.5) but may become reserved key words in the future: " {} \
+"
+
+Note:  Some of these key words represent functions in SQL92. These functions are defined in Postgres, but the parser does not consider the names to be key words and they are allowed in other contexts. 
+
+ALLOCATE ARE ASSERTION AT AUTHORIZATION AVG 
+BIT BIT_LENGTH
+CASCADED CATALOG COLLATION CONNECT CONNECTION
+CONSTRAINTS CONTINUE CONVERT CORRESPONDING COUNT
+DATE DEALLOCATE DEC DESCRIBE DESCRIPTOR DIAGNOSTICS DISCONNECT DOMAIN 
+END-EXEC ESCAPE EXCEPT EXCEPTION EXEC EXTERNAL 
+FIRST FOUND
+GET GO GOTO 
+IDENTITY IMMEDIATE INDICATOR INITIALLY INPUT INTERSECT ISOLATION 
+LAST LEVEL LOWER 
+MAX MIN MODULE 
+OCTET_LENGTH OPEN OUTPUT OVERLAPS 
+PREPARE PRESERVE 
+RESTRICT ROWS
+SCHEMA SECTION SESSION SESSION_USER SIZE SOME 
+SQL SQLCODE SQLERROR SQLSTATE SUM SYSTEM_USER
+TEMPORARY TRANSLATE TRANSLATION 
+UNKNOWN UPPER USAGE
+VALUE 
+WHENEVER WRITE
+" {code}
diff --git a/src/bin/pgaccess/lib/help/listen.hlp b/src/bin/pgaccess/lib/help/listen.hlp
new file mode 100644 (file)
index 0000000..9771273
--- /dev/null
@@ -0,0 +1,34 @@
+.pgaw:Help.f.t insert end "LISTEN" {bold} " registers the current Postgres backend as a listener on the notify condition notifyname.  \
+
+Whenever the command NOTIFY notifyname is invoked, either by this backend or another one connected to the same database, all the backends currently listening on that notify condition are \
+notified, and each will in turn notify its connected frontend application. See the discussion of NOTIFY for more information.  \
+
+A backend can be deregistered for a given notify condition with the UNLISTEN command. Also, a backend's listen registrations are automatically cleared when the backend process exits.  \
+
+The method a frontend application must use to detect notify events depends on which Postgres application programming interface it uses. With the basic libpq library, the application issues \
+LISTEN as an ordinary SQL command, and then must periodically call the routine PQnotifies to find out whether any notify events have been received. Other interfaces such as libpgtcl provide \
+higher-level methods for handling notify events; indeed, with libpgtcl the application programmer should not even issue LISTEN or UNLISTEN directly. See the documentation for the library \
+you are using for more details. 
+
+The reference page for NOTIFY contains a more extensive discussion of the use of LISTEN and NOTIFY. 
+
+" {} "Synopsis" {bold} "
+
+LISTEN notifyname
+
+" {} "Usage" {bold} "
+" {} "
+                -- Configure and execute a listen/notify sequence from psql
+                postgres=> listen virtual;
+                LISTEN
+                postgres=> notify virtual;
+                NOTIFY
+                ASYNC NOTIFY of 'virtual' from backend pid '11239' received
+                
+" {code} "Notes" {bold} "
+
+notifyname can be any string valid as a name; it need not correspond to the name of any actual table. If notifyname is enclosed in double-quotes, it need not even be a syntactically valid name, \
+but can be any string up to 31 characters long. 
+
+In some previous releases of Postgres, notifyname had to be enclosed in double-quotes when it did not correspond to any existing table name, even if syntactically valid as a name. That is no \
+longer required. "
diff --git a/src/bin/pgaccess/lib/help/load.hlp b/src/bin/pgaccess/lib/help/load.hlp
new file mode 100644 (file)
index 0000000..dd6c1b8
--- /dev/null
@@ -0,0 +1,27 @@
+.pgaw:Help.f.t insert end "LOAD" {bold} " Loads an object (or \".o\") file into the Postgres backend address space. Once a file is loaded, all functions in that file can be accessed. This function is used in support of user-defined types and \
+functions. 
+
+If a file is not loaded using LOAD, the file will be loaded automatically the first time the function is called by Postgres. LOAD can also be used to reload an object file if it has been edited and \
+recompiled. Only objects created from C language files are supported at this time. 
+
+
+" {} "Synopsis" {bold} "
+                  
+          LOAD 'filename'
+          
+" {} "Usage" {bold} "
+
+                --Load the file /usr/postgres/demo/circle.o
+                --
+                LOAD '/usr/postgres/demo/circle.o'
+                
+" {} "Notes" {bold} "
+
+Functions in loaded object files should not call functions in other object files loaded through the LOAD command. For example, all functions in file A should call each other, functions in the \
+standard or math libraries, or in Postgres itself. They should not call functions defined in a different loaded file B. This is because if B is reloaded, the Postgres loader is not able to relocate the \
+calls from the functions in A into the new address space of B. If B is not reloaded, however, there will not be a problem. 
+
+Object files must be compiled to contain position independent code. For example, on DECstations you must use /bin/cc with the -G 0 option when compiling object files to be loaded.  \
+
+Note that if you are porting Postgres to a new platform, LOAD will have to work in order to support ADTs. 
+"
diff --git a/src/bin/pgaccess/lib/help/lock.hlp b/src/bin/pgaccess/lib/help/lock.hlp
new file mode 100644 (file)
index 0000000..b2cba42
--- /dev/null
@@ -0,0 +1,49 @@
+.pgaw:Help.f.t insert end "LOCK" {bold} " Postgres always uses the least restrictive lock mode whenever possible. LOCK TABLE provided for cases when you might need more restrictive locking. 
+
+For example, an application runs a transaction at READ COMMITTED isolation level and needs to ensure the existance of data in a table for the duration of the transaction. To achieve this you \
+could use SHARE lock mode over the table before querying. This will protect data from concurrent changes and provide any further read operations over the table with data in their actual current \
+state, because SHARE lock mode conflicts with any ROW EXCLUSIVE one acquired by writers, and your LOCK TABLE table IN SHARE MODE statement will wait until any concurrent \
+write operations commit or rollback. 
+
+" {} "Synopsis" {bold} "
+" {} "
+LOCK \[ TABLE \] table
+LOCK \[ TABLE \] table IN \[ ROW | ACCESS \] \{ SHARE | EXCLUSIVE \} MODE
+LOCK \[ TABLE \] table IN SHARE ROW EXCLUSIVE MODE
+
+" {code} "Usage" {bold} "
+
+    --
+    -- SHARE lock primary key table when going to perform
+    -- insert into foreign key table.
+    --
+" {} "    BEGIN WORK;
+    LOCK TABLE films IN SHARE MODE;
+    SELECT id FROM films 
+      WHERE name = 'Star Wars: Episode I - The Phantom Menace';
+    --
+    -- Do ROLLBACK if record was not returned
+    --
+    INSERT INTO films_user_comments VALUES 
+      (_id_, 'GREAT! I was waiting for it for so long!');
+    COMMIT WORK;
+  
+
+    --
+    -- SHARE ROW EXCLUSIVE lock primary key table when going to perform
+    -- delete operation.
+    --
+    BEGIN WORK;
+    LOCK TABLE films IN SHARE ROW EXCLUSIVE MODE;
+    DELETE FROM films_user_comments WHERE id IN
+      (SELECT id FROM films WHERE rating < 5);
+    DELETE FROM films WHERE rating < 5;
+    COMMIT WORK;
+
+" {code} "Notes" {bold} "
+
+LOCK is a Postgres language extension. 
+
+Except for ACCESS SHARE/EXCLUSIVE lock modes, all other Postgres lock modes and the LOCK TABLE syntax are compatible with those present in Oracle. 
+
+LOCK works only inside transactions. "
diff --git a/src/bin/pgaccess/lib/help/mathfunc.hlp b/src/bin/pgaccess/lib/help/mathfunc.hlp
new file mode 100644 (file)
index 0000000..f7e9d5d
--- /dev/null
@@ -0,0 +1,34 @@
+.pgaw:Help.f.t insert end \
+"Mathematical functions\n\n" {title} \
+"dexp(float8)" {bold} \
+"
+       Returns: float8 
+       raise e to the specified exponent 
+
+" {} \
+"dpow(float8,float8)" {bold} \
+"
+       Returns: float8 
+       raise a number to the specified exponent 
+
+" {} \
+"float(int)" {bold} \
+"
+       Returns: float8 
+       convert integer to floating point 
+
+" {} \
+"float4(int)" {bold} \
+"
+       Returns: float4
+       convert integer to floating point 
+
+" {} \
+"integer(float)" {bold} \
+"
+       Returns: int 
+       convert floating point to integer 
+
+" {} \
+"PostgreSQL functions\n" {link pgfunctions} \
+"Next - string functions" {link stringfunc}
diff --git a/src/bin/pgaccess/lib/help/move.hlp b/src/bin/pgaccess/lib/help/move.hlp
new file mode 100644 (file)
index 0000000..ab28eff
--- /dev/null
@@ -0,0 +1,43 @@
+.pgaw:Help.f.t insert end "MOVE" {bold} "allows a user to move cursor position a specified number of rows. MOVE works like the FETCH command, but only positions the cursor and does not return rows. 
+
+Refer to the FETCH command for details on syntax and usage. 
+
+" {} "Synopsis" {bold} "
+" {} "
+MOVE \[ selector \] \[ count \] 
+    \{ IN | FROM \} cursor
+FETCH \[ RELATIVE \] \[ \{ \[ # | ALL | NEXT | PRIOR \] \} \] FROM \] cursor
+
+
+" {code} "Usage" {bold} "
+
+                --set up and use a cursor:
+                --
+" {} "          BEGIN WORK;
+                DECLARE liahona CURSOR  FOR SELECT * FROM films;
+                
+                --Skip first 5 rows:
+                --
+                MOVE FORWARD 5 IN liahona;
+                                  MOVE
+                
+                --Fetch 6th row in the cursor liahona:
+                --
+                FETCH 1 IN liahona;
+                                  FETCH
+                  code |title |did| date_prod|kind      |len
+                  -----+------+---+----------+----------+------
+                  P_303|48 Hrs|103|1982-10-22|Action    | 01:37
+                  (1 row)
+                
+                -- close the cursor liahona and commit work:
+                --
+                CLOSE liahona;
+                COMMIT WORK;
+
+" {code} "Notes" {bold} "
+
+MOVE is a Postgres language extension. 
+
+Refer to FETCH for a description of valid arguments. Refer to DECLARE to declare a cursor. Refer to BEGIN WORK, COMMIT WORK, ROLLBACK WORK statements for further \
+information about transactions. "
diff --git a/src/bin/pgaccess/lib/help/mvcc.hlp b/src/bin/pgaccess/lib/help/mvcc.hlp
new file mode 100644 (file)
index 0000000..89d25bc
--- /dev/null
@@ -0,0 +1,13 @@
+.pgaw:Help.f.t insert end \
+"Multi-Version Concurrency Control" {title} "
+
+Multi-Version Concurrency Control (MVCC) is an advanced technique for\
+improving database performance in a multi-user environment. " {} "Vadim Mikheev" {bold} " provided the implementation for Postgres. 
+
+" {} "Introduction" {bold} "
+
+Unlike most other database systems which use locks for concurrency control, Postgres maintains data consistency by using a multiversion model. This means that while querying a database each transaction sees a snapshot of data (a database version) as it was some time ago, regardless of the current state of the underlying data. This protects the transaction from viewing inconsistent data that could be caused by (other) concurrent transaction updates on the same data rows, providing transaction isolation for each database session. 
+
+The main difference between multiversion and lock models is that in MVCC locks acquired for querying (reading) data don't conflict with locks acquired for writing data and so reading never blocks writing and writing never blocks reading. 
+
+" {} "Isolation levels" {link isolation}
diff --git a/src/bin/pgaccess/lib/help/new_query.hlp b/src/bin/pgaccess/lib/help/new_query.hlp
new file mode 100644 (file)
index 0000000..d3cd253
--- /dev/null
@@ -0,0 +1,22 @@
+.pgaw:Help.f.t insert end \
+"Creating a new query" {bold} "
+
+Select the \"Queries\" tab from the main window and press\
+the \"New\" button.
+
+You will need to enter the query name and the SQL command for the query. If\
+you desire, you could use the " {} "visual query designer" {link visual_designer} "
+
+You can design dynamic queries that can include a parameter that will be\
+provided later at query execution time by using the \[parameter \"message\"\] function\
+as in the following examples :" {} "
+
+select * from people where age <= \[parameter \"Maximum age?\"\]
+select * from invoices where received_date = '\[parameter \"Invoice date?\"\]' " {code} "
+
+Before query execution a popup dialog will be displayed in order to get that\
+parameter and to substitute it in the query command.
+
+Checking the \"save this query as a view\" checkbox will create a new view from\
+the current query.
+"
diff --git a/src/bin/pgaccess/lib/help/new_table.hlp b/src/bin/pgaccess/lib/help/new_table.hlp
new file mode 100644 (file)
index 0000000..a43bb17
--- /dev/null
@@ -0,0 +1,31 @@
+.pgaw:Help.f.t insert end \
+"Creating a new table" {bold} "
+
+  Select the \"Tables\" tab from the main window and then press then \"New\" button.\
+A form will be displayed allowing you to define a new table.
+  
+  You should enter the table name and then to define the fields.\
+At this point you can define also a primary key for that table by checking the \"primary key\" checkbox for the fields that will be included in the primary key. Fields selected for the primary key will be displayed with a * in the K column.\
+The \"size\" entry is used in order to specify the dimension for those field types\
+that have variable dimensions (varchar, char). Otherwise, it will be disabled.\
+The \"default value\" entry can be used in order to specify the field's default\
+value that will be assigned if a value is not specified in the insert command.
+
+  The \"check\" entry can be used in order to specify a boolean expression using\
+tables fields or defined functions that will\
+be checked on every insert or update command. The \"constraint\" entry is optional\
+and it's just for naming purposes.
+" {} "Example:" {italic} "
+       (price > 0) and (quantity > 0) and valid_product(product_id)
+" {code} "
+  In the above example, price and quantity are fields from the new table and\
+valid_product(product_id) is a SQL function that will return the boolean value true\
+if the product_id was found in another table \"products\".
+
+  In the \"Inherits\" field you can select one or more tables. They will be separated\
+with commas. The new table will inherit all the fields from the parent tables.\
+Read more " {} "about inheritance here." {link inheritance} "
+
+  Select a field from the listbox and use the \"Move up\" and \"Move down\" buttons in order to rearrange the field order. At the end, press the \"Create\" button to define the table.
+
+  Read also about " {} "CREATE TABLE" {link create_table} " SQL command."
diff --git a/src/bin/pgaccess/lib/help/notify.hlp b/src/bin/pgaccess/lib/help/notify.hlp
new file mode 100644 (file)
index 0000000..9185f23
--- /dev/null
@@ -0,0 +1,57 @@
+.pgaw:Help.f.t insert end "NOTIFY" {bold} " The NOTIFY command sends a notify event to each frontend application that has previously executed LISTEN notifyname for the specified notify condition in the current database. 
+
+The information passed to the frontend for a notify event includes the notify condition name and the notifying backend process's PID. It is up to the database designer to define the condition \
+names that will be used in a given database and what each one means. 
+
+Commonly, the notify condition name is the same as the name of some table in the database, and the notify event essentially means
+\"I changed this table, take a look at it to see what's new\". \
+But no such association is enforced by the NOTIFY and LISTEN commands. For example, a database designer could use several different condition names to signal different sorts of changes \
+to a single table. 
+
+NOTIFY provides a simple form of signal or IPC (interprocess communication) mechanism for a collection of processes accessing the same Postgres database. Higher-level mechanisms can \
+be built by using tables in the database to pass additional data (beyond a mere condition name) from notifier to listener(s). 
+
+When NOTIFY is used to signal the occurrence of changes to a particular table, a useful programming technique is to put the NOTIFY in a rule that is triggered by table updates. In this way, \
+notification happens automatically when the table is changed, and the application programmer can't accidentally forget to do it. 
+
+NOTIFY interacts with SQL transactions in some important ways. Firstly, if a NOTIFY is executed inside a transaction, the notify events are not delivered until and unless the transaction is \
+committed. This is appropriate, since if the transaction is aborted we would like all the commands within it to have had no effect --- including NOTIFY. But it can be disconcerting if one is \
+expecting the notify events to be delivered immediately. Secondly, if a listening backend receives a notify signal while it is within a transaction, the notify event will not be delivered to its \
+connected frontend until just after the transaction is completed (either committed or aborted). Again, the reasoning is that if a notify were delivered within a transaction that was later aborted, \
+one would want the notification to be undone somehow --- but the backend cannot \"take \
+back\" a notify once it has sent it to the frontend. So notify events are only delivered between \
+transactions. The upshot of this is that applications using NOTIFY for real-time signaling should try to keep their transactions short. 
+
+NOTIFY behaves like Unix signals in one important respect: if the same condition name is signaled multiple times in quick succession, recipients may get only one notify event for several \
+executions of NOTIFY. So it is a bad idea to depend on the number of notifies received. Instead, use NOTIFY to wake up applications that need to pay attention to something, and use a \
+database object (such as a sequence) to keep track of what happened or how many times it happened. 
+
+It is common for a frontend that sends NOTIFY to be listening on the same notify name itself. In that case it will get back a notify event, just like all the other listening frontends. Depending on \
+the application logic, this could result in useless work --- for example, re-reading a database table to find the same updates that that frontend just wrote out. In Postgres 6.4 and later, it is \
+possible to avoid such extra work by noticing whether the notifying backend process's PID (supplied in the notify event message) is the same as one's own backend's PID (available from \
+libpq). When they are the same, the notify event is one's own work bouncing back, and can be ignored. (Despite what was said in the preceding paragraph, this is a safe technique. Postgres \
+keeps self-notifies separate from notifies arriving from other backends, so you cannot miss an outside notify by ignoring your own notifies.) 
+
+" {} "Synopsis" {bold} "
+
+NOTIFY notifyname 
+
+" {} "Usage" {bold} "
+
+                -- Configure and execute a listen/notify sequence from psql
+" {} "          postgres=> listen virtual;
+                LISTEN
+                postgres=> notify virtual;
+                NOTIFY
+                ASYNC NOTIFY of 'virtual' from backend pid '11239' received
+                
+" {code} "Notes" {bold} "
+
+notifyname can be any string valid as a name; it need not correspond to the name of any actual table. If notifyname is enclosed in double-quotes, it need not even be a syntactically valid name, \
+but can be any string up to 31 characters long. 
+
+In some previous releases of Postgres, notifyname had to be enclosed in double-quotes when it did not correspond to any existing table name, even if syntactically valid as a name. That is no \
+longer required. 
+
+In Postgres releases prior to 6.4, the backend PID delivered in a notify message was always the PID of the frontend's own backend. So it was not possible to distinguish one's own notifies from \
+other clients' notifies in those earlier releases. "
diff --git a/src/bin/pgaccess/lib/help/open_query.hlp b/src/bin/pgaccess/lib/help/open_query.hlp
new file mode 100644 (file)
index 0000000..e48b8e3
--- /dev/null
@@ -0,0 +1,17 @@
+.pgaw:Help.f.t insert end \
+"Open a query for vieweing" {bold} "
+
+Select the \"Queries\" tab from the main window and select a query from the list. Press on \
+the \"Open\" button.
+
+If the query will return some records (i.e. is not an action query) a query \
+viewer will be displayed and the selected rows from the result will be displayed.
+
+You will not be able to specify a sort field or a filter as you can do it in \
+table viewer. If you want to specify sort fields, go and edit the query command \
+and add there the desired sort order or filter conditions.
+Also, you will not be able to change or to add new records.
+
+If the selected query is an \"action query\" (INSERT INTO, DELETE FROM, UPDATE) \
+a confirmation for the query execution will be requested.
+"
diff --git a/src/bin/pgaccess/lib/help/open_table.hlp b/src/bin/pgaccess/lib/help/open_table.hlp
new file mode 100644 (file)
index 0000000..020d861
--- /dev/null
@@ -0,0 +1,19 @@
+.pgaw:Help.f.t insert end \
+"Opening tables for viewing and editing" {bold} "
+
+  Select the \"Tables\" tab from the main window ,select a table from the listbox and click with the mouse on the \"Open\" button. A new table viewer window will be opened showing you the records from that table
+
+" {} "Note:" {italic} " Due to the fact that the records being displayed are kept in memory, only the first 200 records from that table will be displayed. The maximum number of records being displayed can be changed in the Database/Preference dialog.
+
+You can sort and filter the records being displayed. Go to the \"Sort field\" entry and type the name of the field. Add the desc (descending) keyword if you want records to be sorted in reverse order. If you want to sort the records based on multiple fields just separate them with commas
+
+" {} "Example:" {italic} "
+       Sort field: price
+       Sort field: price desc, customer asc
+" {code} "
+If you want to select for display just some records frm that table go to the \"Filter conditions\" entry and specify a filter criteria.
+
+" {} "Example:" {italic} "
+       Filter conditions: (price > 150) and (not sold)
+       " {code} "
+After specifying a sort field or a filter conditions, pres Enter or the \"Reload\" button."
diff --git a/src/bin/pgaccess/lib/help/pgfunctions.hlp b/src/bin/pgaccess/lib/help/pgfunctions.hlp
new file mode 100644 (file)
index 0000000..5e71ce7
--- /dev/null
@@ -0,0 +1,13 @@
+.pgaw:Help.f.t insert end \
+"PostgreSQL functions" {title} \
+"
+
+Many data types have functions available for conversion to other related types. In addition, there are some type-specific functions. Some functions are also available through operators and may be documented as operators only. 
+
+" {} \
+"\tSQL functions\n" {link sqlfunc} \
+"\tMathematical functions\n" {link mathfunc} \
+"\tString functions\n" {link stringfunc} \
+"\tDate/Time functions\n" {link datefunc} \
+"\tGeometric functions\n" {link geomfunc} \
+"\tIP V4 functions" {link ipv4func}
diff --git a/src/bin/pgaccess/lib/help/postgresql.hlp b/src/bin/pgaccess/lib/help/postgresql.hlp
new file mode 100644 (file)
index 0000000..fe3d8c4
--- /dev/null
@@ -0,0 +1,13 @@
+.pgaw:Help.f.t insert end \
+"PostgreSQL" {title} \
+"\n\n" {} \
+"What is PostgreSQL?\n" {bold} \
+"  PostgreSQL is a object-relational database management system, originally developed at the University of California at Berkeley. PostgreSQL is based on  Postgres release 4.2. The Postgres project, led by Professor Michael Stonebraker, was sponsored by the Defense Advanced Research Projects Agency (DARPA), the Army Research Office (ARO), the National Science Foundation (NSF), and ESL, Inc.\n\n" {} \
+"      History of PostgreSQL\n" {link history} \
+"      Copyrights\n" {link copyrights} \
+"      Y2K statement\n" {link y2k} \
+"      PostgreSQL reserved key words\n" {link keywords} \
+"      Data types" {link data_types} " , " {} "Functions\n" {link pgfunctions} \
+"      Quick guide of PostgreSQL commands\n" {link sql_guide} \
+"      Inheritance\n" {link inheritance} \
+"      Multi-Version Concurency Control\n" {link mvcc}
diff --git a/src/bin/pgaccess/lib/help/queries.hlp b/src/bin/pgaccess/lib/help/queries.hlp
new file mode 100644 (file)
index 0000000..a1f6023
--- /dev/null
@@ -0,0 +1,8 @@
+.pgaw:Help.f.t insert end \
+"Queries" {title} \
+"\n\n" {} \
+"  The following topics are available:\n" {} \
+"      creating a new query\n" {link new_query} \
+"      opening a query for viewing\n" {link open_query} \
+"      visual query designer\n" {link visual_designer}
+
diff --git a/src/bin/pgaccess/lib/help/reports.hlp b/src/bin/pgaccess/lib/help/reports.hlp
new file mode 100644 (file)
index 0000000..2f23513
--- /dev/null
@@ -0,0 +1,10 @@
+.pgaw:Help.f.t insert end "The Reports module is still in alpha stage.
+
+The module should be able to design and execute a report based on a table\
+or from an existing query.
+
+Grouping, sorting, subtotals, expressions should be implemented.
+Report output can be printed as a Postscript file.
+
+For the moment I have no time to do that so volunteers are welcome.
+"
diff --git a/src/bin/pgaccess/lib/help/reset.hlp b/src/bin/pgaccess/lib/help/reset.hlp
new file mode 100644 (file)
index 0000000..481ee09
--- /dev/null
@@ -0,0 +1,21 @@
+.pgaw:Help.f.t insert end "RESET" {bold} " restores variables to the default values. Refer to the SET command for details on allowed values and defaults. RESET is an alternate form for SET variable = DEFAULT
+
+" {} "Synopsis" {bold} "
+
+RESET variable
+
+" {} "Usage" {bold} "
+
+-- reset DateStyle to its default;
+" {} "
+RESET DateStyle;
+
+" {code} "
+-- reset Geqo to its default;
+" {} "RESET GEQO;
+
+" {code} "Notes" {bold} "
+
+The RESET statement is a Postgres language extension. 
+
+Refer to SET/SHOW statements to set/show variable values. "
diff --git a/src/bin/pgaccess/lib/help/revoke.hlp b/src/bin/pgaccess/lib/help/revoke.hlp
new file mode 100644 (file)
index 0000000..a2186f1
--- /dev/null
@@ -0,0 +1,49 @@
+.pgaw:Help.f.t insert end "REVOKE" {bold} " allows creator of an object to revoke permissions granted before, from all users (via PUBLIC) or a certain user or group.
+
+" {} "Synopsis" {bold} "
+" {} "
+REVOKE privilege \[, ...\]
+    ON object \[, ...\]
+    FROM \{ PUBLIC | GROUP ER\">gBLE> | username \}
+    
+" {code} "Usage" {bold} "
+
+-- revoke insert privilege from all users on table films:
+--
+" {} "REVOKE INSERT ON films FROM PUBLIC;
+  
+
+" {code} "  
+-- revoke all privileges from user manuel on view kinds:
+--
+" {} "REVOKE ALL ON kinds FROM manuel;
+
+" {code} "Notes" {bold} "
+
+Refer to psql \\z command for further information about permissions on existing objects: 
+" {} "
+Database    = lusitania
++------------------+-------------------------------------------------+
+|  Relation        |            Grant/Revoke Permissions             |
++------------------+-------------------------------------------------+
+| mytable          | \{\"=rw\",\"miriam=arwR\",\"group todos=rw\"\}  |
++------------------+-------------------------------------------------+
+Legend:
+     uname=arwR -- privileges granted to a user
+     group gname=arwR -- privileges granted to a GROUP
+     =arwR -- privileges granted to PUBLIC
+                  
+     r -- SELECT
+     w -- UPDATE/DELETE
+     a -- INSERT
+     R -- RULE
+     arwR -- ALL
+    
+
+       Tip: Currently, to create a GROUP you have to insert data manually into table pg_group as: 
+
+                 
+       INSERT INTO pg_group VALUES ('todos');
+       CREATE USER miriam IN GROUP todos;
+       
+" {code} 
diff --git a/src/bin/pgaccess/lib/help/rollback.hlp b/src/bin/pgaccess/lib/help/rollback.hlp
new file mode 100644 (file)
index 0000000..04ed8f7
--- /dev/null
@@ -0,0 +1,17 @@
+.pgaw:Help.f.t insert end "ROLLBACK" {bold} " rolls back the current transaction and causes all the updates made by the transaction to be discarded. 
+
+" {} "Synopsis" {bold} "
+" {} "
+ROLLBACK \[ WORK | TRANSACTION \]
+
+" {code} "Usage" {bold} "
+" {} "
+    --To abort all changes:
+    --
+    ROLLBACK WORK;
+    
+" {code} "Notes" {bold} "
+
+The keywords WORK and TRANSACTION are noise and can be omitted. 
+
+Use " {} "COMMIT" {link commit} " to successfully terminate a transaction. "
diff --git a/src/bin/pgaccess/lib/help/schema.hlp b/src/bin/pgaccess/lib/help/schema.hlp
new file mode 100644 (file)
index 0000000..347d37c
--- /dev/null
@@ -0,0 +1,2 @@
+.pgaw:Help.f.t insert end "
+To be written"
diff --git a/src/bin/pgaccess/lib/help/scripts.hlp b/src/bin/pgaccess/lib/help/scripts.hlp
new file mode 100644 (file)
index 0000000..347d37c
--- /dev/null
@@ -0,0 +1,2 @@
+.pgaw:Help.f.t insert end "
+To be written"
diff --git a/src/bin/pgaccess/lib/help/select.hlp b/src/bin/pgaccess/lib/help/select.hlp
new file mode 100644 (file)
index 0000000..0c0b4c6
--- /dev/null
@@ -0,0 +1,136 @@
+.pgaw:Help.f.t insert end "SELECT" {bold} " will return rows from one or more tables. Candidates for selection are rows which satisfy the WHERE condition; if WHERE is omitted, all rows are candidates.
+
+" {} "Synopsis" {bold} "
+" {} "
+SELECT \[ALL|DISTINCT \[ON column\] \]
+    expression \[ AS
+   name \] \[, ...\]
+    \[ INTO \[TEMP\] \[TABLE\] new_table \]
+    \[ FROM table
+   \[alias \] \[, ...\] \]
+    \[ WHERE condition \]
+    \[ GROUP BY column \[, ...\] \]
+    \[ HAVING condition \[, ...\] \]
+    \[ { UNION \[ALL\] | INTERSECT | EXCEPT } select \]
+    \[ ORDER BY column \[ ASC | DESC \] \[, ...\] \]
+    \[ FOR UPDATE \[OF class_name...\]\]
+    \[ LIMIT count \[OFFSET|, count\]\]
+    
+" {code} "Usage" {bold} "
+
+To join the table films with the table distributors: 
+" {} "
+SELECT f.title, f.did, d.name, f.date_prod, f.kind
+    FROM distributors d, films f
+    WHERE f.did = d.did
+
+title                    |did|name            | date_prod|kind
+-------------------------+---+----------------+----------+----------
+The Third Man            |101|British Lion    |1949-12-23|Drama
+The African Queen        |101|British Lion    |1951-08-11|Romantic
+Une Femme est une Femme  |102|Jean Luc Godard |1961-03-12|Romantic
+Vertigo                  |103|Paramount       |1958-11-14|Action
+Becket                   |103|Paramount       |1964-02-03|Drama
+48 Hrs                   |103|Paramount       |1982-10-22|Action
+War and Peace            |104|Mosfilm         |1967-02-12|Drama
+West Side Story          |105|United Artists  |1961-01-03|Musical
+Bananas                  |105|United Artists  |1971-07-13|Comedy
+Yojimbo                  |106|Toho            |1961-06-16|Drama
+There's a Girl in my Soup|107|Columbia        |1970-06-11|Comedy
+Taxi Driver              |107|Columbia        |1975-05-15|Action
+Absence of Malice        |107|Columbia        |1981-11-15|Action
+Storia di una donna      |108|Westward        |1970-08-15|Romantic
+The King and I           |109|20th Century Fox|1956-08-11|Musical
+Das Boot                 |110|Bavaria Atelier |1981-11-11|Drama
+Bed Knobs and Broomsticks|111|Walt Disney     |          |Musical
+  
+
+To sum the column len of all films and group the results by kind: 
+
+SELECT kind, SUM(len) AS total FROM films GROUP BY kind;
+
+    kind      |total
+    ----------+------
+    Action    | 07:34
+    Comedy    | 02:58
+    Drama     | 14:28
+    Musical   | 06:42
+    Romantic  | 04:38
+  
+
+To sum the column len of all films, group the results by kind and show those group totals that are less than 5 hours: 
+
+SELECT kind, SUM(len) AS total
+    FROM films
+    GROUP BY kind
+    HAVING SUM(len) < INTERVAL '5 hour';
+
+    kind      |total
+    ----------+------
+    Comedy    | 02:58
+    Romantic  | 04:38
+  
+
+The following two examples are identical ways of sorting the individual results according to the contents of the second column (name): 
+
+SELECT * FROM distributors ORDER BY name;
+SELECT * FROM distributors ORDER BY 2;
+
+    did|name
+    ---+----------------
+    109|20th Century Fox
+    110|Bavaria Atelier
+    101|British Lion
+    107|Columbia
+    102|Jean Luc Godard
+    113|Luso films
+    104|Mosfilm
+    103|Paramount
+    106|Toho
+    105|United Artists
+    111|Walt Disney
+    112|Warner Bros.
+    108|Westward
+  
+
+This example shows how to obtain the union of the tables distributors and actors, restricting the results to those that begin with letter W in each table. Only distinct rows are to be used, so
+the ALL keyword is omitted: 
+
+    --        distributors:                actors:
+    --        did|name                     id|name
+    --        ---+------------             --+--------------
+    --        108|Westward                  1|Woody Allen
+    --        111|Walt Disney               2|Warren Beatty
+    --        112|Warner Bros.              3|Walter Matthau
+    --        ...                           ...
+
+SELECT distributors.name
+    FROM   distributors
+    WHERE  distributors.name LIKE 'W%'
+UNION
+SELECT actors.name
+    FROM   actors
+    WHERE  actors.name LIKE 'W%'
+
+name
+--------------
+Walt Disney
+Walter Matthau
+Warner Bros.
+Warren Beatty
+Westward
+Woody Allen
+
+" {code} "Compatibility" {bold} "
+
+Extensions 
+
+Postgres allows one to omit the FROM clause from a query. This feature was retained from the original PostQuel query language: 
+" {} "
+SELECT distributors.* WHERE name = 'Westwood';
+
+    did|name
+    ---+----------------
+    108|Westward
+    
+" {code}    
diff --git a/src/bin/pgaccess/lib/help/select_into.hlp b/src/bin/pgaccess/lib/help/select_into.hlp
new file mode 100644 (file)
index 0000000..74c217b
--- /dev/null
@@ -0,0 +1,17 @@
+.pgaw:Help.f.t insert end "SELECT INTO" {bold} " creates a new table from the results of a query. Typically, this query draws data from an existing table, but any SQL query is allowed. 
+
+" {} "Synopsis" {bold} "
+" {} "
+SELECT \[ ALL | DISTINCT \] expression \[ AS name \] \[, ...\]
+    INTO \[TEMP\] \[ TABLE \] new_table \]
+    \[ FROM table \[alias\] \[, ...\] \]
+    \[ WHERE condition \]
+    \[ GROUP BY column \[, ...\] \]
+    \[ HAVING condition \[, ...\] \]
+    \[ { UNION \[ALL\] | INTERSECT | EXCEPT } select\]
+    \[ ORDER BY column \[ ASC | DESC \] \[, ...\] \]
+    \[ FOR UPDATE \[OF class_name...\]\]
+    \[ LIMIT count \[OFFSET|, count\]\]
+    
+" {code} "Note" {bold} "
+CREATE TABLE AS is functionally equivalent to the SELECT INTO command. "
diff --git a/src/bin/pgaccess/lib/help/sequences.hlp b/src/bin/pgaccess/lib/help/sequences.hlp
new file mode 100644 (file)
index 0000000..4d91d45
--- /dev/null
@@ -0,0 +1,15 @@
+.pgaw:Help.f.t insert end "  The " {} "Sequences" {bold} " tab is used to\
+define new sequence number generators or to inspect them.
+
+  Sequences are used sometimes for assigning default values to some unique\
+fields in order to obtain a unique id. Sequences are returning an int4\
+value. For example, a new sequence will be automatically defined if you\
+are adding a 'serial' field type into a table.
+
+  In order to define a new sequence you should supply at least the sequence\
+name. The default increment is 1, the default start value and minvalue is 1.
+
+  Inspecting a sequence will show you the last number generated.
+  
+  For more information see also " {} "CREATE SEQUENCE" {link create_sequence} \
+" SQL command." {}
diff --git a/src/bin/pgaccess/lib/help/set.hlp b/src/bin/pgaccess/lib/help/set.hlp
new file mode 100644 (file)
index 0000000..da4bf99
--- /dev/null
@@ -0,0 +1,54 @@
+.pgaw:Help.f.t insert end "SET" {bold} " will modify configuration parameters for variable during a session. 
+
+" {} "Synopsis" {bold} "
+" {} "
+SET variable \{ TO | = \} \{
+   'value' | DEFAULT \}
+SET TIME ZONE \{ 'timezone' | LOCAL | DEFAULT \};
+SET TRANSACTION ISOLATION LEVEL \{ READ COMMITTED | SERIALIZED \}
+
+" {code} "Usage" {bold} "
+" {} "
+   --Set the style of date to ISO:
+   --
+   SET DATESTYLE TO 'ISO';
+  
+
+   --Enable GEQO for queries with 4 or more tables
+   --
+   SET GEQO ON=4;
+  
+
+   --Set GEQO to default:
+   --
+   SET GEQO = DEFAULT;
+  
+
+   --set the timezone for Berkeley, California:
+   SET TIME ZONE 'PST8PDT';
+   
+   SELECT CURRENT_TIMESTAMP AS today;
+   
+   today
+   ----------------------
+   1998-03-31 07:41:21-08
+  
+
+   --set the timezone for Italy:
+   SET TIME ZONE 'Europe/Rome';
+   
+   SELECT CURRENT_TIMESTAMP AS today;
+   
+   today
+   ----------------------
+   1998-03-31 17:41:31+02
+   
+" {code} "Notes" {bold} "
+
+The SET variable statement is a Postgres language extension. 
+
+Refer to SHOW and RESET to display or reset the current values. "
diff --git a/src/bin/pgaccess/lib/help/show.hlp b/src/bin/pgaccess/lib/help/show.hlp
new file mode 100644 (file)
index 0000000..1e291db
--- /dev/null
@@ -0,0 +1,23 @@
+.pgaw:Help.f.t insert end "will display the current configuration parameters for variable during a session. 
+
+The session can be configured using SET statement, and values can be restored to the defaults using RESET statement. Parameters and values are case-insensitive. 
+
+" {} "Synopsis" {bold} "
+
+SHOW variable
+
+" {} "Usage" {bold} "
+" {} "
+-- show DateStyle;
+SHOW DateStyle;
+NOTICE:DateStyle is Postgres with US (NonEuropean) conventions
+
+-- show Geqo;
+SHOW GEQO;
+NOTICE:GEQO is ON
+
+" {code} "Notes" {bold} "
+
+The SHOW is a Postgres language extension. 
+
+Refer to SET/RESET to set/reset variable values. See also SET TIME ZONE. "
diff --git a/src/bin/pgaccess/lib/help/sql_guide.hlp b/src/bin/pgaccess/lib/help/sql_guide.hlp
new file mode 100644 (file)
index 0000000..711840c
--- /dev/null
@@ -0,0 +1,62 @@
+.pgaw:Help.f.t configure -tabs {170 400}
+.pgaw:Help.f.t insert end \
+"SQL guide\n" {title} \
+"
+" {} "ABORT" {link abort} "    Aborts the current transaction
+" {} "ALTER TABLE" {link alter_table} "        Modifies table properties
+" {} "ALTER USER" {link alter_user} "  Modifies user account information 
+" {} "BEGIN" {link begin} "    Begins a transaction in chained mode 
+" {} "CLOSE" {link close} "    Close a cursor 
+" {} "CLUSTER" {link cluster} "        Gives storage clustering advice to the backend 
+" {} "COMMIT" {link commit} "  Commits the current transaction 
+" {} "COPY" {link copy} "      Copies data between files and tables 
+" {} "CREATE AGGREGATE" {link create_aggregate} "      Defines a new aggregate function 
+" {} "CREATE DATABASE" {link create_database} "        Creates a new database 
+" {} "CREATE FUNCTION" {link create_function} "        Defines a new function 
+" {} "CREATE INDEX" {link create_index} "      Constructs a secondary index 
+" {} "CREATE LANGUAGE" {link create_language} "        Defines a new language for functions 
+" {} "CREATE OPERATOR" {link create_operator} "        Defines a new user operator 
+" {} "CREATE RULE" {link create_rule} "        Defines a new rule 
+" {} "CREATE SEQUENCE" {link create_sequence} "        Creates a new sequence number generator 
+" {} \
+"CREATE TABLE" {link create_table} "   Creates a new table 
+" {} "CREATE TABLE AS" {link create_table_as} "        Creates a new table 
+" {} "CREATE TRIGGER" {link create_trigger} "  Creates a new trigger 
+" {} "CREATE TYPE" {link create_type} "        Defines a new base data type 
+" {} "CREATE USER" {link create_user} "        Creates account information for a new user 
+" {} "CREATE VIEW" {link create_view} "        Constructs a virtual table 
+" {} "DECLARE" {link declare} "        Defines a cursor for table access 
+" {} "DELETE" {link delete} "  Deletes rows from a table 
+" {} "DROP AGGREGATE" {link drop_aggregate} "  Removes the definition of an aggregate function 
+" {} "DROP DATABASE" {link drop_database} "    Destroys an existing database 
+" {} "DROP FUNCTION" {link drop_function} "    Removes a user-defined C function 
+" {} "DROP INDEX" {link drop_index} "  Removes an index from a database 
+" {} "DROP LANGUAGE" {link drop_language} "    Removes a user-defined procedural language 
+" {} "DROP OPERATOR" {link drop_operator} "    Removes an operator from the database 
+" {} "DROP RULE" {link drop_rule} "    Removes an existing rule from the database 
+" {} "DROP SEQUENCE" {link drop_sequence} "    Removes an existing sequence 
+" {} "DROP TABLE" {link drop_table} "  Removes existing tables from a database 
+" {} "DROP TRIGGER" {link drop_trigger} "      Removes the definition of a trigger 
+" {} "DROP TYPE" {link drop_type} "    Removes a user-defined type from the system catalogs 
+" {} "DROP USER" {link drop_user} "    Removes an user account information 
+" {} "DROP VIEW" {link drop_view} "    Removes an existing view from a database 
+" {} "EXPLAIN" {link explain} "        Shows statement execution details
+" {} "FETCH" {link fetch} "    Gets rows using a cursor
+" {} "GRANT" {link grant} "    Grants access privilege to a user, a group or all users 
+" {} "INSERT" {link insert} "  Inserts new rows into a table
+" {} "LISTEN" {link listen} "  Listen for notification on a notify condition
+" {} "LOAD" {link load} "      Dynamically loads an object file 
+" {} "LOCK" {link lock} "      Explicit lock of a table inside a transaction 
+" {} "MOVE" {link move} "      Moves cursor position
+" {} "NOTIFY" {link notify} "  Signals all frontends and backends listening on a notify condition
+" {} "RESET" {link reset} "    Restores run-time parameters for session to default values 
+" {} "REVOKE" {link revoke} "  Revokes access privilege from a user, a group or all users. 
+" {} "ROLLBACK" {link rollback} "      Aborts the current transaction 
+" {} "SELECT" {link select} "  Retrieve rows from a table or view. 
+" {} "SELECT INTO" {link select_into} "        Create a new table from an existing table or view 
+" {} "SET" {link set} "        Set run-time parameters for session 
+" {} "SHOW" {link show} "      Shows run-time parameters for session 
+" {} "UNLISTEN" {link unlisten} "      Stop listening for notification
+" {} "UPDATE" {link update} "  Replaces values of columns in a table
+" {} "VACUUM" {link vacuum} "  Clean and analyze a Postgres database
+"
diff --git a/src/bin/pgaccess/lib/help/sqlfunc.hlp b/src/bin/pgaccess/lib/help/sqlfunc.hlp
new file mode 100644 (file)
index 0000000..5440ec1
--- /dev/null
@@ -0,0 +1,21 @@
+.pgaw:Help.f.t insert end \
+"SQL functions\n\n" {title} \
+"COALESCE(list)" {bold} " 
+       return first non-NULL value in list 
+       Example:
+               COALESCE(a2, c2 + 5, 0)
+
+" {} "IFNULL(input,non-NULL substitute)" {bold} " 
+       return second argument if first is NULL 
+       Example:
+               IFNULL(c1, 'N/A')
+
+" {} "CASE WHEN expr THEN expr \[...\] ELSE expr END" {bold} " 
+       return expression for first true clause 
+       Example:
+               CASE WHEN c1 = 1 THEN 'match' ELSE 'no match' END 
+
+
+" {} \
+"PostgreSQL functions\n" {link pgfunctions} \
+"Next - mathematical functions" {link mathfunc}
diff --git a/src/bin/pgaccess/lib/help/stringfunc.hlp b/src/bin/pgaccess/lib/help/stringfunc.hlp
new file mode 100644 (file)
index 0000000..483a23e
--- /dev/null
@@ -0,0 +1,102 @@
+.pgaw:Help.f.t insert end \
+"String functions\n\n" {title} \
+"SQL92 String Functions" {bold} \
+" - SQL92 defines string functions with specific syntax. Some of these are implemented using other Postgres functions. The supported string types for SQL92 are char, varchar, and text. 
+" {} "
+char_length(string)" {bold} " 
+       Returns: int4 
+       length of string" {} "
+
+character_length(string)" {bold} " 
+       Returns: int4 
+       length of string" {} " 
+
+lower(string)" {bold} " 
+       Returns: string 
+       convert string to lower case" {} " 
+
+octet_length(string)" {bold} " 
+       Returns: int4 
+       storage length of string" {} " 
+
+position(string in string)" {bold} " 
+       Returns: int4 
+       location of specified substring" {} " 
+
+substring(string \[from int\] \[for int\])" {bold} " 
+       Returns: string 
+       extract specified substring" {} " 
+
+trim(\[leading|trailing|both\] \[string\] from string)" {bold} " 
+       Returns: string 
+       trim characters from string" {} " 
+
+upper(text)" {bold} " 
+       Returns: text 
+       convert text to upper case 
+
+Many additional string functions are available for text, varchar(), and char() types. Some are used internally to implement the SQL92 string functions listed above. 
+
+" {} "PostgreSQL String Functions
+
+char(text)" {bold} " 
+       Returns: char 
+       convert text to char type 
+
+" {} "char(varchar)" {bold} " 
+       Returns: char 
+       convert varchar to char type 
+
+" {} "initcap(text)" {bold} " 
+       Returns: text 
+       first letter of each word to upper case 
+
+" {} "lpad(text,int,text)" {bold} " 
+       Returns: text 
+       left pad string to specified length 
+
+" {} "ltrim(text,text)" {bold} " 
+       Returns: text 
+       left trim characters from text 
+
+" {} "textpos(text,text)" {bold} " 
+       Returns:text 
+       locate specified substring 
+
+" {} "rpad(text,int,text)" {bold} "
+       Returns: text
+       right pad string to specified length 
+
+" {} "rtrim(text,text)" {bold} " 
+       Returns: text 
+       right trim characters from text 
+
+" {} "substr(text,int\[,int\])" {bold} " 
+       Returns: text 
+       extract specified substring 
+
+" {} "text(char)" {bold} " 
+       Returns: text 
+       convert char to text type 
+
+" {} "text(varchar)" {bold} " 
+       Returns: text 
+       convert varchar to text type 
+
+" {} "translate(text,from,to)" {bold} " 
+       Returns: text 
+       convert character in string 
+
+" {} "varchar(char)" {bold} " 
+       Returns: varchar 
+       convert char to varchar type 
+
+" {} "varchar(text)" {bold} " 
+       Returns: varchar 
+       convert text to varchar type 
+
+Most functions explicitly defined for text will work for char() and varchar() arguments. 
+
+" {} \
+"PostgreSQL functions\n" {link pgfunctions} \
+"Next - Date/Time functions" {link datefunc}
diff --git a/src/bin/pgaccess/lib/help/tables.hlp b/src/bin/pgaccess/lib/help/tables.hlp
new file mode 100644 (file)
index 0000000..8478341
--- /dev/null
@@ -0,0 +1,8 @@
+.pgaw:Help.f.t insert end \
+"Tables" {title} \
+"\n\n" {} \
+"  The following topics are available:\n" {} \
+"      creating a new table\n" {link new_table} \
+"      opening a table for viewing and editing\n" {link open_table} \
+"      adding new records to an existing table\n" {link add_records} \
+"      viewing and changing table structure\n" {link view_table_structure}
diff --git a/src/bin/pgaccess/lib/help/unlisten.hlp b/src/bin/pgaccess/lib/help/unlisten.hlp
new file mode 100644 (file)
index 0000000..455d733
--- /dev/null
@@ -0,0 +1,32 @@
+.pgaw:Help.f.t insert end "UNLISTEN" {bold} " is used to remove an existing NOTIFY registration. UNLISTEN cancels any existing registration of the current Postgres session as a listener on the notify condition notifyname. \
+The special condition wildcard \"*\" cancels all listener registrations for the current session.
+
+" {} "NOTIFY" {link notify} " contains a more extensive discussion of the use of LISTEN and NOTIFY.
+
+" {} "Synopsis" {bold} "
+" {} "
+UNLISTEN \{ notifyname | * \}
+
+" {code} "Usage" {bold} "
+" {} "
+postgres=> LISTEN virtual;
+LISTEN
+postgres=> NOTIFY virtual;
+NOTIFY
+ASYNC NOTIFY of 'virtual' from backend pid '12317' received
+
+postgres=> UNLISTEN virtual;
+UNLISTEN
+postgres=> NOTIFY virtual;
+NOTIFY
+-- notice no NOTIFY event is received
+postgres=>
+
+" {code} "Notes" {bold} "
+
+classname needs not to be a valid class name but can be any string valid as a name up to 32 characters long.
+
+The backend does not complain if you UNLISTEN something you were not listening for. Each backend will automatically execute UNLISTEN * when exiting.
+
+A restriction in some previous releases of Postgres that a classname which does not correspond to an actual table must be enclosed in double-quotes is no longer present.
+"
diff --git a/src/bin/pgaccess/lib/help/update.hlp b/src/bin/pgaccess/lib/help/update.hlp
new file mode 100644 (file)
index 0000000..7db55b5
--- /dev/null
@@ -0,0 +1,40 @@
+.pgaw:Help.f.t insert end "UPDATE" {bold} " changes the values of the columns specified for all rows which satisfy condition. Only the columns to be modified need appear as column. 
+
+Array references use the same syntax found in SELECT. That is, either single array elements, a range of array elements or the entire array may be replaced with a single query. 
+
+You must have write access to the table in order to modify it, as well as read access to any table whose values are mentioned in the WHERE condition. 
+
+" {} "Synopsis" {bold} "
+" {} "
+UPDATE table SET column = expression \[, ...\]
+    \[ FROM fromlist \]
+    \[ WHERE condition \]
+    
+" {code} "Usage" {bold} "
+" {} "
+   --Change word \"Drama\" with \"Dramatic\" on column kind:
+   --
+   UPDATE films 
+      SET kind = 'Dramatic'
+      WHERE kind = 'Drama';
+
+   SELECT * FROM films WHERE kind = 'Dramatic' OR kind = 'Drama';
+
+   code |title        |did| date_prod|kind      |len
+   -----+-------------+---+----------+----------+------
+   BL101|The Third Man|101|1949-12-23|Dramatic  | 01:44
+   P_302|Becket       |103|1964-02-03|Dramatic  | 02:28
+   M_401|War and Peace|104|1967-02-12|Dramatic  | 05:57
+   T_601|Yojimbo      |106|1961-06-16|Dramatic  | 01:50
+   DA101|Das Boot     |110|1981-11-11|Dramatic  | 02:29
+   
+" {code} "Compatibility" {bold} "
+
+SQL92 
+
+SQL92 defines a different syntax for positioned UPDATE statement: 
+" {} "
+   UPDATE table SET column = expression \[, ...\]
+          WHERE CURRENT OF cursor
+        
+" {code} "where cursor identifies an open cursor. "
diff --git a/src/bin/pgaccess/lib/help/users.hlp b/src/bin/pgaccess/lib/help/users.hlp
new file mode 100644 (file)
index 0000000..347d37c
--- /dev/null
@@ -0,0 +1,2 @@
+.pgaw:Help.f.t insert end "
+To be written"
diff --git a/src/bin/pgaccess/lib/help/vacuum.hlp b/src/bin/pgaccess/lib/help/vacuum.hlp
new file mode 100644 (file)
index 0000000..ec98382
--- /dev/null
@@ -0,0 +1,26 @@
+.pgaw:Help.f.t insert end \
+"VACUUM" {bold} " serves two purposes in Postgres as both a means to reclaim storage and also a means to collect information for the optimizer. 
+
+VACUUM opens every class in the database, cleans out records from rolled back transactions, and updates statistics in the system catalogs. The statistics maintained include the number of tuples and number of pages stored in all classes. Running VACUUM periodically will increase the speed of the database in processing user queries. 
+
+" {} "Notes:" {italic} " The open database is target for VACUUM. 
+
+We recommend that active production databases be cleaned nightly, in order to keep statistics relatively current. The VACUUM query may be executed at any time, however. In particular, after copying a large class into Postgres or after deleting a large number of records, it may be a good idea to issue a VACUUM query. This will update the system catalogs with the results of all recent changes, and allow the Postgres query optimizer to make better choices in planning user queries. 
+
+If the server crashes during a VACUUM command, chances are it will leave a lock file hanging around. Attempts to re-run the VACUUM command result in an error message about the creation of a lock file. If you are sure VACUUM is not running, remove the pg_vlock file in your database directory (i.e. PGDATA/base/dbname/pg_vlock). 
+
+" {} "Synopsis" {bold} "
+VACUUM \[ VERBOSE \] \[ ANALYZE \] \[ table \]
+VACUUM \[ VERBOSE \] ANALYZE \[ table \[ (column \[, ...\] ) \] \]
+
+" {code} "VERBOSE" {italic} "
+       Prints a detailed vacuum activity report for each table. 
+
+" {} "ANALYZE" {italic} "
+       Updates column statistics used by the optimizer to determine the most efficient way to execute a query. The statistics represent the disbursion of the data in each column. This information is valuable when several execution paths are possible. 
+
+" {} "table" {italic} "
+       The name of a specific table to vacuum. Defaults to all tables. 
+
+" {} "column" {italic} "
+       The name of a specific column to analyze. Defaults to all columns. "
diff --git a/src/bin/pgaccess/lib/help/view_table_structure.hlp b/src/bin/pgaccess/lib/help/view_table_structure.hlp
new file mode 100644 (file)
index 0000000..854cae5
--- /dev/null
@@ -0,0 +1,15 @@
+.pgaw:Help.f.t insert end \
+"View and change table structure" {bold} "
+
+   Select the Tables tab from the main window , select the desired table and press the \"Design\" button. You will get a tabbed dialog containing general information for the table, table structure, index information and permissions.
+   
+   You will be able to add new fields, rename the existing ones and add new indexes. In order to add a new index, select the fields that will be included in the index (multiple selections with shift-click) and press the \"Add new index\" button.
+   
+   A confirmation form will be displayed. The index name will be asigned by default by concatenating using underscore the table name with the fields names but you can change it as you will. Checking the \"Is unique?\" check box will force the creation of a unique index.
+   
+   You can inspect the properties of a index by selecting it from the list of defined indexes. You can also delete one of them by selecting the index and then pressing the \"Delete index\" button.\
+You can cluster an index fo the table, more information on " {} "cluster SQL command" {link cluster} "
+
+   Through \"Permissions\" tab you can assign new permissions for the table or alter the existing ones. See also " {} "GRANT" {link grant} " and " {} "REVOKE" {link revoke} " SQL commands."
+
+
diff --git a/src/bin/pgaccess/lib/help/views.hlp b/src/bin/pgaccess/lib/help/views.hlp
new file mode 100644 (file)
index 0000000..347d37c
--- /dev/null
@@ -0,0 +1,2 @@
+.pgaw:Help.f.t insert end "
+To be written"
diff --git a/src/bin/pgaccess/lib/help/visual_designer.hlp b/src/bin/pgaccess/lib/help/visual_designer.hlp
new file mode 100644 (file)
index 0000000..9d089e7
--- /dev/null
@@ -0,0 +1,57 @@
+.pgaw:Help.f.t insert end \
+"Visual query designer" {bold} "
+
+PgAccess is using an advanced tool for visual designing of queries. \
+For those of you that have used Microsoft Access, it will be very familiar.
+
+When a new query is build, an empty canvas will be presented to you. \
+In the bottom of the screen there is the " {} "result" {italic} " zone.
+
+Add new tables on the canvas by selecting them from the drop-down or by entering \
+their names in the \"Add table\" entry and then pressing Enter.
+
+After adding the source tables on the canvas you can make links between fields from \
+different tables by dragging one field and dropping it on the label of the\
+corresponding field in the linked table. Links can be deleted by selecting them\
+(the link line will change it's colour) and then press \"Delete\" key.
+
+In order to delete a table from the canvas, select it by mouse clicking on the\
+name of the table and then press the \"Delete\" key. The tables can be moved\
+on the canvas by dragging them from their name labels. The entire canvas can\
+be panned by dragging it from an empty area.
+
+In order to select fields that will be included in the result, drag the desired \
+field from the table and drop it in the result zone in the desired column.\
+If there is already another field in that column, it will be shifted to the \
+right together with all the remaining fields to the right and the new field will \
+be inserted in the desired column.
+
+You can also specify a condition for records to be included in the result. Go \
+to the result zone and in the \"Criteria\" row enter the condition for the \
+selected field." {} "
+Example:" {italic} "
+       > 150
+we will presume that we entered the above criteria for a numeric field. Or:
+       = 'CPU'
+for a character field.
+
+If you don't want a field to be included in the result and you dropped it into \
+the result area just for adding a selection criteria on it, mouse click on \
+the Yes or No label in the \"Return\" row.
+
+In order to sort the results on a field, mouse click on the 'unsorted' label in \
+the \"Sort\" row.
+
+If you want to remove a field from the result zone, click on it's name and \
+then hit the \"Delete\" key.
+
+Pressing the \"Show SQL\" button will display the SQL command that will be \
+build from the current tables and result columns. Clicking on the canvas will \
+make it dissapear and the table layout will be displayed again.
+
+Check the query execution by pressing on the \"Execute SQL\" button. If the \
+query has been executed without error, a query viewer will be displayed and \
+you will be able to see the selected rows. When everything is ok, save the \
+query command to the query builder by pressing the \"Save to query builder\" \
+button.
+"
diff --git a/src/bin/pgaccess/lib/help/y2k.hlp b/src/bin/pgaccess/lib/help/y2k.hlp
new file mode 100644 (file)
index 0000000..cab9cb9
--- /dev/null
@@ -0,0 +1,16 @@
+.pgaw:Help.f.t insert end \
+"Year 2000 statement\n\n" {title} \
+"Author : " {bold} "Written by Thomas Lockhart on 1998-10-22\n" {} \
+{
+  The PostgreSQL Global Development Team provides the Postgres software code tree as a public service, without warranty and without liability for it's behavior or performance. However, at the time of writing: 
+
+  The author of this statement, a volunteer on the Postgres support team since November, 1996, is not aware of any problems in the Postgres code base related to time transitions around Jan 1, 2000 (Y2K). 
+
+  The author of this statement is not aware of any reports of Y2K problems uncovered in regression testing or in other field use of recent or current versions of Postgres. We might have expected to hear about problems if they existed, given the installed base and the active participation of users on the support mailing lists. 
+
+  To the best of the author's knowledge, the assumptions Postgres makes about dates specified with a two-digit year are documented in the current User's Guide in the chapter on data types. For two-digit years, the significant transition year is 1970, not 2000; e.g. "70-01-01" is interpreted as "1970-01-01", whereas "69-01-01" is interpreted as "2069-01-01". 
+
+  Any Y2K problems in the underlying OS related to obtaining "the current time" may propagate into apparent Y2K problems in Postgres. 
+
+  Refer to The Gnu Project and The Perl Institute for further discussion of Y2K issues, particularly as it relates to open source, no fee software. 
+}
diff --git a/src/bin/pgaccess/lib/languages/deutsch b/src/bin/pgaccess/lib/languages/deutsch
new file mode 100644 (file)
index 0000000..4540d6d
--- /dev/null
@@ -0,0 +1,535 @@
+array set Messages {
+
+"Label" "Beschriftung"
+"Save schema" "Schema speichern"
+"Is unique ?" "Ist eindeutig ?"
+"Report builder" "Berichtgenerator"
+"Criteria" "Kriterien"
+"FATAL ERROR upgrading PgAccess table" "SCHWERER FEHLER beim Aktualisieren der PgAccess-Tabelle"
+"Save this query as a view" "Abfrage als View speichern"
+"Page header" "Seitenkopf"
+"Query name" "Abfragename"
+"Please select an object first!" "Bitte wählen Sie zuerst ein Objekt aus"
+"Fields :" "Felder :"
+"Name" "Name"
+"File name" "Dateiname"
+"Detail record" "Detail Datensatz"
+"Auto-load the last opened database at startup" "Zuletzt geöffnete Datenbank beim Start laden"
+"Maxvalue" "maximaler Wert"
+"Start value" "Startwert"
+"Report fields" "Berichtsfelder"
+"Test form" "Formular testen"
+"Error trying to connect to database '%s' on host %s \n\nPostgreSQL error message:%s" "Fehler beim Verbinden mit der Datenbank '%s' auf Rechner %s \n\nPostgreSQL Fehlercode :%s"
+"No field type ?" "Kein Feldtyp ?"
+"User without name?" "Dieser Benutzer hat keinen Namen ?"
+"You have to supply a name for this schema!" "Sie müssen einen Namen für diese Schema angeben."
+"Last value" "Letzter Wert"
+"Preferences" "Voreinstellungen"
+"View '%s' already exists!\nOverwrite ?" "View '%s' bereits vorhanden.\n Überschreiben ?"
+"You have to select an index!" "Sie müssen einen Index auswählen"
+"Field type" "Feldtyp"
+"Script name" "Skriptname"
+"Reload" "Erneut laden"
+"Remove table %s from query?" "Tabelle %s aus abfrage löschen ?"
+"SQL window" "SQL-Fenster"
+"Allow user to create other users" "Benutzer darf andere Benutzer anlegen"
+"Delete current record ?" "Aktuellen Satz löschen ?"
+"List box" "Listbox"
+"Save to query builder" "In Abfragegenerator speichern"
+"fixed width" "feste Breite"
+"Scripts" "Skripten"
+"Yes" "Ja"
+"Add label" "Beschriftung hinzufügen"
+"Sequence created!" "Zähler erzeugt"
+"Field information" "Feldeigenschaften"
+"Design" "Entwurf"
+"Field" "Feld"
+"You have to supply an external file name!" "Sie müssen einen externen Dateinamen angeben."
+"Increment" "Inkrement"
+"No" "Nein"
+"Form design" "Formularentwurf"
+"You must supply a return type!" "Sie müssen einen Rückgabewert angeben."
+"Remove field from result ?" "Feld aus Ergebnis löschen ?"
+"There is another object (a %s) with the same name.\nPlease change it!" "Es gibt bereits ein Objekt mit Namen %s.\nBitte wählen Sie einen anderen Namen."
+"This query has no commands?" "Die Abfrage enthält keine Anweisungen."
+"Execute query" "Abfrage ausführen"
+"field cannot be null" "Feld darf nicht null sein."
+"Help" "Hilfe"
+"Rename column" "Spalte umbenennen"
+"Database" "Datenbank"
+"Information" "Information"
+"Close" "Schließen"
+"Command" "Befehl"
+"Table" "Tabelle"
+"verify password" "Passwort bestätigen"
+"Vacuum" "Komprimieren"
+"Default value" "Standardwert"
+"Import" "Import"
+"Delete index" "Lösche Index"
+"Move up" "nach oben"
+"index properties" "Index-Eigenschaften"
+"check" "Überprüfe"
+"Create new table" "Neue Tabelle erzeugen"
+"Visual query designer" "Visueller Abfragedesigner"
+"Delete all" "Alle löschen"
+"You are going to delete\n\n %s \n\nProceed?" "Sie sind dabei\n\n %s \n\nzu löschen. Fortsetzen ?"
+"Schema name" "Schema-Name"
+"Error executing query" "Fehler beim Ausführen der Abfrage"
+"Report name" "Berichtname"
+"Add field" "Feld hinzufügen"
+"Field name" "Feldname"
+"FATAL ERROR searching for PgAccess system tables" "FATALER FEHLER Kann PgAccess Systemtabellen nicht finden"
+"A big number of rows displayed in table view will take a lot of memory!" "Die Anzeige vieler Zeilen in der Tabellenansicht benötigt sehr viel Speicher"
+"Preview" "Vorschau"
+"Users" "Benutzer"
+"Owner" "Eigentümer"
+"Form's window internal name" "interner Formularname"
+"Sort field" "Sortierfeld"
+"New name is the same as the old one!" "Neuer und alter Name stimmen überein."
+"Warning" "Warnung"
+"Suggestions at" "Vorschläge an"
+"Functions" "Funktionen"
+"Schema" "Schemata"
+"Open" "Öffnen"
+"size" "Größe"
+"Delete" "Löschen"
+"Returns" "Ergebnistyp"
+"Define new user" "Neuen Benutzer anlegen"
+"Move down" "nach unten"
+"Design script" "Entwurfsskript"
+"Check box" "Check box"
+"FINAL WARNING" "LETZTE WARNUNG"
+"Add table" "Tabelle hinzufügen"
+"Table viewer font" "Schrift zur Tabellenanzeige"
+"The field type is not specified!" "Der Feldtyp ist nicht angegeben"
+"Close test form" "Testformular schließen"
+"Export table" "Tabelle exportieren"
+"Add new index" "Neuen Index hinzufügen"
+"Left" "Links"
+"Field delimiter" "Feldtrennzeichen"
+"Add formula" "Formular hinzufügen"
+"Open database" "Datenbank öffnen"
+"Return" "?Zurück?"
+"Changed fonts may appear in the next working session!" "Die neuen Schrifteinstellungen werden erst beim nächsten Neustart wirksam"
+"Error" "Fehler"
+"Enter a field name" "Bitte geben Sie einen Feldnamen ein"
+"field name" "Feldname"
+"Forms" "Formulare"
+"Cannot add column" "Kann keine Spalte hinzufügen"
+"Clean" "Anzeige löschen"
+"Delete all objects ?" "Alle Objekte löschen ?"
+"Preferred language" "Bevorzugte Sprache"
+"Execute SQL" "SQL ausführen"
+"Sequences" "Zähler"
+"Button" "Knopf"
+"Language" "Sprache"
+"Query '%s' was not found!" "Abfrage '%s' nicht gefunden"
+"Object" "Objekt"
+"Font fixed" "feste Schriftbreite"
+"Table name" "Tabellenname"
+"Export" "Export"
+"Change user" "Benutzer bearbeiten"
+"You must give object a new name!" "Sie müssen dem Objekt einen neuen Namen geben"
+"Query" "Abfrage"
+"User name" "Benutzername"
+"Font normal" "normale Schrift"
+"Import table" "Tabelle importieren"
+"Toolbar" "Toolbar"
+"Radio btn" "Radio"
+"You must supply a name for this function!" "Sie müssen dieser Funktion einen Namen geben"
+"You have to select index fields!" "Sie müssen Index-Felder auswählen."
+"Constraint" "Constraint"
+"The script must have a name" "Das Skript muß einen Namen haben."
+"Save" "Speichern"
+"Exit" "Beenden"
+"Inherits" "Übernehme"
+"Delete field" "Feld löschen"
+"About" "Über"
+"Empty field name ?" "Leerer Feldname ?"
+"All report information will be deleted.\n\nProceed ?" "Alle Berichsdaten werden gelöscht\n\nFortfahren ?"
+"Host" "Rechner"
+"vacuuming database %s ..." "Komprimiere Datenbank %s ..."
+"Indexes defined" "definierte Indizes"
+"You must specify field size!" "Sie müssen eine Feldgröße angeben."
+"Schema '%s' already exists!" "Schema '%s' existiert bereits."
+"There is another field with the same name: '%s'!\n\nReplace it ?" "Es gibt bereits ein Feld mit diesem Namen : '%s'!\n\nSoll es ersetzt werden ?"
+"Contents" "Inhalt"
+"Views" "Views"
+"Variable" "Variable"
+"Error executing query\n\n%s\n\nPostgreSQL error message:\n%s\nPostgreSQL status:%s" "Fehler beim Ausführen der Abfrage\n\n%s\n\nPostgreSQL Fehlercode :\n%s \n PostgreSQL Status :%s"
+"Filter conditions" "Filterbedingung"
+"Error retrieving query definition" "Fehler beim Empfangen der Abfragedefinition"
+"Error deleting view" "Fehler beim Löschen der View"
+"New" "Neu"
+"Tables" "Tabellen"
+"Create" "Erzeugen"
+"Forms need an internal name, only literals, low case" "Formulare benötigen einen internen Namen (nur Kleinbuchstaben)"
+"Do you want to save the form into the database?" "Möchten Sie das Formular in der Datenbank speichern ?"
+"Schema '%s' was not found!" "Schema '%s' nicht gefunden"
+"proportional" "proportional"
+"Function saved!" "Funktion gespeichert"
+"with OIDs" "mit OIDs"
+"Table information" "Information de table"
+"Error inserting new record" "Fehler beim Einfügen des neuen Datensatzes"
+"Column name '%s' already exists in this table!" "Spaltenname '%s' existiert bereits"
+"File" "Datei"
+"Your table has no fields!" "Die Tabelle hat keine Felder."
+"Height" "Höhe"
+"You will always get the latest version at:" "Die aktuellste Version finden Sie unter:"
+"Form must have a name" "Das Formular muß einen Namen haben"
+"Password" "Passwort"
+"Valid until (date)" "Gültig bis (Datum)"
+"Report source" "Datenquelle"
+"Allow user to create databases" "Benutzer darf Datenbanken anlegen"
+"Cancel" "Abbrechen"
+"Is clustered ?" "Clustered ?"
+"Add new column" "Neue Spalte hinzufügen"
+"Show SQL" "SQL anzeigen."
+"New name" "Neuer Name"
+"Table '%s' not found!" "Tabelle '%s' nicht gefunden"
+"Form name" "Formularname"
+"Visual designer" "Visual Designer"
+"You choose to delete index\n\n %s \n\nProceed?" "Soll der Index \n\n %s \n\n wirklich gelöscht werden ?"
+"Error retrieving from" "Fehler beim Empfangen von..."
+"Save query definition" "Abfragedefinition speichern"
+"A Tcl/Tk interface to\nPostgreSQL\nby Constantin Teodorescu" "Ein Tcl/TK Interface für\nPostgreSQL\n von Constantin Teodorescu"
+"Operation completed!" "Operation abgeschlossen"
+"Max rows displayed in table/query view" "maximale Anzahl angezeigter Sätze in Tabellen/Abfragen/Views"
+"Passwords do not match!" "Die Passworte stimmen nicht überein"
+"Rename" "Umbenennen"
+"Entry" "Eintrag"
+"Error retrieving schema definition" "Fehler beim Empfang der Schemadefinition"
+"This is an action query!\n\nExecute it?" "Dies ist ein Aktionsabfrage.\n\nAusführen ?"
+"Error retrieving view definition for" "Fehler beim Ermitteln der Viewdefinition"
+"options" "Optionen"
+"Sequence '%s' not found!" "Zähler '%s' nicht gefunden"
+"Text" "Text"
+"Tcl error executing pg_exec %s\n\n%s" "Tcl-Fehler beim Ausführen von pg_exec %s\n\n%s"
+"Width" "Breite"
+"You have to supply a name for this query!" "Sie müssen einen Namen für die Abfrage eingeben."
+"Accessing data. Please wait ..." "Datenzugriff. Bitte warten ..."
+"Report footer" "Reportfuß"
+"Parameters" "Parameter"
+"Queries" "Abfragen"
+"Query '%s' already exists!" "Diese Abfrage '%s'  existiert bereits."
+"Font bold" "Fettdruck"
+"Query builder" "Abfrageassistent"
+"Error defining view" "Fehler beim definieren der View"
+"Top" "Oben"
+"You must supply a name for your table!" "Sie müssen einen Tabellennamen angeben"
+"Page footer" "Seitenfuß"
+"Font italic" "Kursivschrift"
+"Field name not entered!" "Kein Feldname eingegeben."
+"Index name cannot be null!" "Der Index-Name darf nicht null sein."
+"Sort" "Sortieren"
+"Import-Export table" "Import/Export Tabelle"
+"Point" "Punkt"
+"type" "Typ"
+"You should supply a name for this sequence" "Sie sollten einen Namen für diesen Zähler angeben"
+"Remove link ?" "Verweis löschen?"
+"You have to supply a table name!" "Sie müssen einen Tabellennamen angeben"
+"Report header" "Berichtskopf"
+"Attributes" "Attribute"
+"Table '%s' already in schema" "die Tabelle '%s' ist bereits in diesem
+Schema vorhanden"
+"Username" "Benutzername"
+"Minvalue" "minimaler Wert"
+"Sequence name" "Name des Zählers"
+"Define sequence" "Zähler definieren"
+"Function" "Funktion"
+"Sorting and filtering not (yet) available from queries!\n\nPlease enter them in the query definition!" "Das Sortieren und Filtern aus Abfragen heraus ist derzeit noch nicht möglich\n\nBitte legen Sie sie in der Abfragedefinnition fest!"
+"Reports" "Berichte"
+
+"Columns" "Spalten"
+"Indexes" "Indizes"
+
+"Permissions" "Berechtigungen"
+
+"not null" "nicht null"
+
+"Cluster index" "Cluster index" 
+
+"index columns" "Indexspalten"
+
+"Add user" "Benutzer hinzufügen"
+
+"Change permissions" "Berechtigungen ändern"
+
+"select" "Auswählen"
+
+"update" "Aktualisieren"
+
+"insert" "Einfügen"
+
+"rule" "Regeln"
+
+"Identification" "Identifikation"
+
+"Owner ID" "ID des Eigenümers"
+
+"Has primary key ?" "Primäschlüssel vorhanden ?"
+
+"Has rules ?" "Regeln vorhanden ?"
+
+"Statistics" "Statistik"
+
+"Number of tuples" "Anzahl der Sätze"
+
+"Number of pages" "Anzahl der Seiten"
+
+"Index name" "Indexname"
+
+"Index fields" "Indexfelder"
+
+"Table OID" "OID der Tabelle"
+
+"View system tables" "Systemtabellen anzeigen"
+
+"Back" "Zurück"
+
+"primary key" "Primärschlüssel"
+
+"Comments" "Anmerkungen"
+
+"Print" "Drucken"
+}
+
+
diff --git a/src/bin/pgaccess/lib/languages/francais b/src/bin/pgaccess/lib/languages/francais
new file mode 100644 (file)
index 0000000..62dc80b
--- /dev/null
@@ -0,0 +1,525 @@
+array set Messages {
+
+"Label" "Etiquette"
+"Save schema" "Sauver schémas"
+"Is unique ?" "Est unique ?"
+"Report builder" "Constructeur d'états"
+"Criteria" "Critère"
+"FATAL ERROR upgrading PgAccess table" "ERREUR FATALE en actualisant la table PgAccess"
+"Save this query as a view" "Sauver cette requête comme vue ?"
+"Page header" "En-tête de page"
+"Query name" "Nom de requête"
+"Please select an object first!" "Selectionnez un objet d'abord"
+"Fields :" "Le champs de index"
+"Name" "Nom"
+"File name" "Nom du fichier"
+"Detail record" "Detail d'enregistrement"
+"Auto-load the last opened database at startup" "Chargement automatique de la base au démarrage"
+"Maxvalue" "Valeur maximale"
+"Start value" "Valeur de début"
+"Report fields" "Champs de l'état"
+"Test form" "Tester formulaire"
+"Error trying to connect to database '%s' on host %s \n\nPostgreSQL error message:%s" "Erreur de liaison à la base de données '%s' pour machine %s \n\nMessage d'erreur PostgreSQL :%s"
+"No field type ?" "Type champ inexistant ?"
+"User without name?" "Cette utilisateur a-t-il un nom?"
+"You have to supply a name for this schema!" "Vous devez fournir un nom pour ce schéma !"
+"Last value" "Dernière valeur"
+"Preferences" "Préférences"
+"View '%s' already exists!\nOverwrite ?" "La vue '%s' existe déjà!\n Ecraser ?"
+"You have to select an index!" "Vous devez selectionner un index!"
+"Field type" "Type de champ"
+"Script name" "Nom du script"
+"Reload" "Valider"
+"Remove table %s from query?" "Eliminer table %s de la requête ?"
+"SQL window" "Fenêtre SQL"
+"Allow user to create other users" "Peut créer d'autres utilisateurs"
+"Delete current record ?" "Détruire enregistrement courant ?"
+"List box" "Liste"
+"Save to query builder" "Sauver le constructeur de requêtes"
+"fixed width" "largeur de police fixe"
+"Scripts" "Scripts"
+"Yes" "Oui"
+"Add label" "Ajouter étiquette"
+"Sequence created!" "Le séquence avait été créée"
+"Field information" "Information de champ"
+"Design" "Editer"
+"Field" "Champ"
+"You have to supply an external file name!" "Vous devez fournir un nom du fichier"
+"Increment" "Incrément"
+"No" "Non"
+"Form design" "Création du formulaire"
+"You must supply a return type!" "Vous devez fournir un type de retour"
+"Remove field from result ?" "Eliminer champ du résultat ?"
+"There is another object (a %s) with the same name.\nPlease change it!" "Il y a un autre objet (%s) avec le même nom.\nChangez le SVP!"
+"This query has no commands?" "Cette requête n'a pas de définition?"
+"Execute query" "Execute requête"
+"field cannot be null" "champ ne peut être vide"
+"Help" "Aide"
+"Rename column" "Renomme champ"
+"Database" "Base de données"
+"Information" "Information"
+"Close" "Fermer"
+"Command" "Commande"
+"Table" "Table"
+"verify password" "encore un fois"
+"Vacuum" "Vider"
+"Default value" "Valeur par defaut"
+"Import" "Importer"
+"Delete index" "Détruire index"
+"Move up" "Monter"
+"index properties" "Propriétés d'index"
+"check" "vérifier"
+"Create new table" "Création de nouvelle table"
+"Visual query designer" "Créateur visuel de requêtes"
+"Delete all" "Détruire tous"
+"You are going to delete\n\n %s \n\nProceed?" "Vous allez détruire\n\n %s \n\nD'accord?"
+"Schema name" "Nom de schéma"
+"Error executing query" "Erreur en exécutant la requête"
+"Report name" "Nom de l'état"
+"Add field" "Ajout champ"
+"Field name" "Nom de champ"
+"FATAL ERROR searching for PgAccess system tables" "ERREUR FATALE en cherchant le système de tables PgAccess"
+"A big number of rows displayed in table view will take a lot of memory!" "L'affichage d'un grand nombre de colonnes prend beaucoup de mémoire"
+"Preview" "Pré-visualisation"
+"Users" "Utilisateurs"
+"Owner" "Auteur"
+"Form's window internal name" "Le nom interne de la fenêtre de formulaire"
+"Sort field" "Trier champs"
+"New name is the same as the old one!" "Le nouveau nom est le même que l'ancien"
+"Warning" "Avertissement"
+"Suggestions at" "Suggestions à"
+"Functions" "Fonctions"
+"Schema" "Schéma"
+"Open" "Ouvrir"
+"size" "taille"
+"Delete" "Détruire"
+"Returns" "Retours"
+"Define new user" "Définir nouvel utilisateur"
+"Move down" "Descendre"
+"Design script" "Script de création"
+"Check box" "Case à cocher"
+"FINAL WARNING" "DERNIER AVERTISSEMENT"
+"Add table" "Ajouter table"
+"Table viewer font" "Police de visualisateur de tables"
+"The field type is not specified!" "Le type de champ n'est pas spécifié"
+"Close test form" "Fermer test du formulaire"
+"Export table" "Exporter"
+"Add new index" "Ajout nouvel index"
+"Left" "Gauche"
+"Field delimiter" "Séparateur de champs"
+"Add formula" "Ajouter formule"
+"Open database" "Ouvre la base de données"
+"Return" "Retour"
+"Changed fonts may appear in the next working session!" "Les nouvelles polices apparaîtront à la prochaine session"
+"Error" "Erreur"
+"Enter a field name" "Entrez un nom de champ !"
+"field name" "Nom de champ"
+"Forms" "Formulaires"
+"Cannot add column" "Ne peut ajouter de colonne"
+"Clean" "Nettoyer"
+"Delete all objects ?" "Détruire tous les objets"
+"Preferred language" "Langage préféré"
+"Execute SQL" "Exécute SQL"
+"Sequences" "Séquences"
+"Button" "Bouton"
+"Language" "Langage"
+"Query '%s' was not found!" "La requête '%s' n'a pas été trouvée"
+"Object" "Objet"
+"Font fixed" "Police fixe"
+"Table name" "Nom de table"
+"Export" "Export"
+"Change user" "Changer utilisateur"
+"You must give object a new name!" "Vous devez donner un nouveau nom"
+"Query" "Requête"
+"User name" "Nom d'utilisateur"
+"Font normal" "Police normale"
+"Import table" "Importer"
+"Toolbar" "Outils"
+"Radio btn" "Radio"
+"You must supply a name for this function!" "Vous devez fournir un nom pour la fonction"
+"You have to select index fields!" "Vous devez selectionner le champ pour l'index"
+"Constraint" "Contrainte"
+"The script must have a name" "Le script doit avoir un nom"
+"Save" "Sauver"
+"Exit" "Quitter"
+"Inherits" "Source"
+"Delete field" "Détruire"
+"About" "A propos"
+"Empty field name ?" "Nom de champ inexistant ?"
+"All report information will be deleted.\n\nProceed ?" "Toutes les informations de l'état vont être détruites\n\nContinuer ?"
+"Host" "Machine"
+"vacuuming database %s ..." "Vider base %s ..."
+"Indexes defined" "Index définis"
+"You must specify field size!" "La taille du champ doit être précisée"
+"Schema '%s' already exists!" "Le schéma '%s' existe déjà!"
+"There is another field with the same name: '%s'!\n\nReplace it ?" "Il y a un autre champ avec le même nom : '%s'!\n\nRemplacer?"
+"Contents" "Contient"
+"Views" "Vues"
+"Variable" "Variable"
+"Error executing query\n\n%s\n\nPostgreSQL error message:\n%s\nPostgreSQL status:%s" "Erreur en exécutant la requête\n\n%s\n\nMessage d'erreur PostgreSQL :\n%s \n Statut de PostgreSQL:%s"
+"Filter conditions" "Conditions de filtre"
+"Error retrieving query definition" "Erreur en retrouvant la définition de la requête"
+"Error deleting view" "Erreur en détruisant la vue"
+"New" "Nouveau"
+"Tables" "Tables"
+"Create" "Créer"
+"Forms need an internal name, only literals, low case" "Les formulaires ont besoin d'un nom interne, seulement en lettres minuscules"
+"Do you want to save the form into the database?" "Voulez vous sauver le formulaire dans la base?"
+"Schema '%s' was not found!" "Le schéma '%s' n'a pas été trouvé"
+"proportional" "Proportionnelle"
+"Function saved!" "Le fonction avait ete créée"
+"with OIDs" "avec des OIDs"
+"Table information" "Information de table"
+"Error inserting new record" "Erreur en introduisant le nouvel enregistrement"
+"Column name '%s' already exists in this table!" "Le nom de colonne existe déjà dans cette table !"
+"File" "Fichier"
+"Your table has no fields!" "Cette table n'a pas de champ?"
+"Height" "Hauteur"
+"You will always get the latest version at:" "Le derniere version toujours à"
+"Form must have a name" "Le formulaire doit avoir un nom !"
+"Password" "Mot de passe"
+"Valid until (date)" "Valable jusqu'à"
+"Report source" "Source de l'état"
+"Allow user to create databases" "Peut créer une base"
+"Cancel" "Abandon"
+"Is clustered ?" "Est groupé ?"
+"Add new column" "Ajout nouveau champ"
+"Show SQL" "Montrez le code SQL."
+"New name" "Nouveau nom"
+"Table '%s' not found!" "Le table '%s' n'est pas trouvée"
+"Form name" "Nom du formulaire"
+"Visual designer" "Créateur visuel"
+"You choose to delete index\n\n %s \n\nProceed?" "Vous allez détruire index\n\n %s \n\nConfirmation?"
+"Error retrieving from" "Erreur en retrouvant..."
+"Save query definition" "Sauver la définition de la requête"
+"A Tcl/Tk interface to\nPostgreSQL\nby Constantin Teodorescu" "Une Tcl/Tk interface pour\nPostgreSQL\npar Constantin Teodorescu"
+"Operation completed!" "Opération finie"
+"Max rows displayed in table/query view" "Nombre maximal de colonnes affichées dans la table/vue de requête"
+"Passwords do not match!" "Les mots de passe ne vont pas"
+"Rename" "Renommer"
+"Entry" "Entrée"
+"Error retrieving schema definition" "Erreur en retrouvant la définition du schéma"
+"This is an action query!\n\nExecute it?" "Ceci est une requête d'action !\nExécuter ?"
+"Error retrieving view definition for" "Erreur en lisant la définition pour la vue"
+"options" "options"
+"Sequence '%s' not found!" "Le séquence '%s' n'a pas été trouvée"
+"Text" "Texte"
+"Tcl error executing pg_exec %s\n\n%s" "Erreur Tcl en exécutant %s\n\n%s"
+"Width" "Largeur"
+"You have to supply a name for this query!" "Vous devez donner un nom à cette requête"
+"Accessing data. Please wait ..." "Lit les données. Patience ..."
+"Report footer" "Pied de rapport"
+"Parameters" "Paramètres"
+"Queries" "Requêtes"
+"Query '%s' already exists!" "La requête '%s' existe dejà!"
+"Font bold" "Police grasse"
+"Query builder" "Constructeur de requêtes"
+"Error defining view" "Erreur en définissant la vue"
+"Top" "Haut"
+"You must supply a name for your table!" "Vous devez introduire un nom pour cette table"
+"Page footer" "Pied de page"
+"Font italic" "Police italique"
+"Field name not entered!" "Le nom de champ n'est pas entré"
+"Index name cannot be null!" "Le nom de l'index ne peut être nul"
+"Sort" "Trier"
+"Import-Export table" "Import/Export table"
+"Point" "Point"
+"type" "type"
+"You should supply a name for this sequence" "Vous devez donner un nom à la séquence"
+"Remove link ?" "Détruire cette liaison?"
+"You have to supply a table name!" "Vous devez fournir un nom de table"
+"Report header" "En tête de l'état"
+"Attributes" "Attributs"
+"Table '%s' already in schema" "Le table est déjà dans le schéma"
+"Username" "Utilisateur"
+"Minvalue" "Valeur minimale"
+"Sequence name" "Nom de séquence"
+"Define sequence" "Définir la séquence"
+"Function" "Fonction"
+"Sorting and filtering not (yet) available from queries!\n\nPlease enter them in the query definition!" "Tri et filtrage pas (encore) possible à partir des requêtes!\n\nEntrez les dans la définition de la requête SVP"
+"Reports" "Etats"
+
+"Columns" "Champs"
+
+"Indexes" "Index"
+
+"Permissions" "Permissions"
+
+"not null" "non vide"
+
+"Cluster index" "index groupe" 
+
+"index columns" "index champs"
+
+"Add user" "Ajoute utilisateur"
+
+"Change permissions" "Change droits"
+
+"select" "sélections"
+
+"update" "actualise"
+
+"insert" "introduire"
+
+"rule" "règles"
+
+"Identification" "Identification"
+
+"Owner ID" "ID du propriétaire"
+
+"Has primary key ?" "A une clé primaire ?"
+
+"Has rules ?" "A des règles?"
+
+"Statistics" "Statistiques"
+
+"Number of tuples" "Nombre des enregistrements"
+
+"Number of pages" "Nombres des pages"
+
+"Index name" "Nom d'index"
+
+"Index fields" "Champs d'index"
+
+"Table OID" "OID de table"
+}
+
+
diff --git a/src/bin/pgaccess/lib/languages/italiano b/src/bin/pgaccess/lib/languages/italiano
new file mode 100644 (file)
index 0000000..157dd4f
--- /dev/null
@@ -0,0 +1,539 @@
+array set Messages {
+
+"Label" "Etichetta"
+"Save schema" "Salva lo schema"
+"Is unique ?" "E' unico ?"
+"Report builder" "Report builder"
+"Criteria" "Criterio"
+"FATAL ERROR upgrading PgAccess table" "ERRORE FATALE aggiornando le tabelle PgAccess"
+"Save this query as a view" "Salva questa query come View"
+"Page header" "Testata di pagina"
+"Query name" "Nome query"
+"Please select an object first!" "Seleziona prima un'oggetto!"
+"Fields :" "Campi :"
+"Name" "Nome"
+"File name" "Nome del file"
+"Detail record" "Dettaglio del record"
+"Auto-load the last opened database at startup" "Apertura automatica ultimo database all'avvio"
+"Maxvalue" "Valore massimo"
+"Start value" "Valore d'inizio"
+"Report fields" "Campi disponibili"
+"Test form" "Test form"
+"Error trying to connect to database '%s' on host %s \n\nPostgreSQL error message:%s" "Errore di connessione al database '%s' sull'host %s \n\nMessaggio d'errore di PostgreSQL :%s"
+"No field type ?" "Nessun tipo per il campo?"
+"User without name?" "Utente senza nome ?"
+"You have to supply a name for this schema!" "Devi specificare un nome per lo schema!"
+"Last value" "Ultimo valore"
+"Preferences" "Preferenze"
+"View '%s' already exists!\nOverwrite ?" "View '%s' esiste gia'!\nSovrascrivo ?"
+"You have to select an index!" "Devi scegliere un'indice!"
+"Field type" "Tipo campo"
+"Script name" "Nome dello Script"
+"Reload" "Ricarica"
+"Remove table %s from query?" "Rimuovere la tabella %s dalla query?"
+"SQL window" "Finestra SQL"
+"Allow user to create other users" "L'utente puo' creare altri utenti"
+"Delete current record ?" "Cancello il record corrente? "
+"List box" "Lista"
+"Save to query builder" "Salva nel query builder"
+"fixed width" "larghezza fissa"
+"Scripts" "Scripts"
+"Yes" "Si"
+"Add label" "Aggiungi etichetta"
+"Sequence created!" "Sequenza creata !"
+"Field information" "Informazioni sul campo"
+"Design" "Disegna"
+"Field" "Campo"
+"You have to supply an external file name!" "Devi specificare un nome file esterno!"
+"Increment" "Incremento"
+"No" "No"
+"Form design" "Disegna il Form"
+"You must supply a return type!" "Devi specificare il tipo di dato ritornato"
+"Remove field from result ?" "Eliminare il campo dal risultato ?"
+"There is another object (a %s) with the same name.\nPlease change it!" "Esiste un'altro oggetto (un %s) con lo stesso nome.\nCambia nome!"
+"This query has no commands?" "Questa query non ha comandi ?"
+"Execute query" "Esegui query"
+"field cannot be null" "Il campo non puo' essere nullo"
+"Help" "Aiuto"
+"Rename column" "Rinomina campo"
+"Database" "Database"
+"Information" "Informazioni"
+"Close" "Chiudi"
+"Command" "Comando"
+"Table" "Tabella"
+"verify password" "verifica password"
+"Vacuum" "Vacuum"
+"Default value" "Valore predefinito"
+"Import" "Importa"
+"Delete index" "Cancella indice"
+"Move up" "Muovi su'"
+"index properties" "proprieta' dell'indice"
+"check" "Controlla"
+"Create new table" "Crea una nuova tabella"
+"Visual query designer" "Visual query designer"
+"Delete all" "Cancella tutto"
+"You are going to delete\n\n %s \n\nProceed?" "Stai per cancellare\n\n %s\n\n Procedo?"
+"Schema name" "Nome dello schema"
+"Error executing query" "Errore eseguendo la query"
+"Report name" "Nome del report"
+"Add field" "Aggiungi campo"
+"Field name" "Nome campo"
+"FATAL ERROR searching for PgAccess system tables" "ERRORE FATALE cercando le tabelle PgAccess di sistema"
+"A big number of rows displayed in table view will take a lot of memory!" "Un numero grande di righe visualizzate richiedera' molta memoria!"
+"Preview" "Anteprima"
+"Users" "Utenti"
+"Owner" "Proprietario"
+"Form's window internal name" "Il nome interno del form"
+"Sort field" "Campo ordinato"
+"New name is the same as the old one!" "Nuovo nome uguale al precedente!"
+"Warning" "Attenzione"
+"Suggestions at" "Suggerimenti a"
+"Functions" "Funzioni"
+"Schema" "Schema"
+"Open" "Apri"
+"size" "Dimensione"
+"Delete" "Cancella"
+"Returns" "Risultati"
+"Define new user" "Definisce nuovo utente"
+"Move down" "Muovi Giù"
+"Design script" "Design script"
+"Check box" "Casella si/no"
+"FINAL WARNING" "Ultimo Warning"
+"Add table" "Nuova tabella"
+"Table viewer font" "Carattere del visualizzatore tabelle"
+"The field type is not specified!" "Il tipo del campo non e' stato specificato!"
+"Close test form" "Chiudi test form"
+"Export table" "Esporta tabelle"
+"Add new index" "Aggiungi nuovo indice"
+"Left" "Sinistra"
+"Field delimiter" "Delimitatore di campo"
+"Add formula" "Aggiungi formula"
+"Open database" "Apri il Database"
+"Return" "Risultato"
+"Changed fonts may appear in the next working session!" "I caratteri cambiati saranno visibili nella prossima sessione!"
+"Error" "Errore"
+"Enter a field name" "Inserisci un nome campo"
+"field name" "Nome Campo"
+"Forms" "Forms"
+"Cannot add column" "Non posso aggiungere una colonna"
+"Clean" "Pulisci"
+"Delete all objects ?" "Cancellare tutti gli oggetti ?"
+"Preferred language" "Lingua preferita"
+"Execute SQL" "Esegui SQL"
+"Sequences" "Sequences"
+"Button" "Bottone"
+"Language" "Lingua"
+"Query '%s' was not found!" "La query '%s' non e' stata trovata!"
+"Object" "Oggetto"
+"Font fixed" "Carattere fisso"
+"Table name" "Nome tabella"
+"Export" "Esporta"
+"Change user" "Cambia utente"
+"You must give object a new name!" "Devi dare un nuovo nome all'oggetto!"
+"Query" "Query"
+"User name" "Nome utente"
+"Font normal" "Carattere normale"
+"Import table" "Importa"
+"Toolbar" "Barra degli strumenti"
+"Radio btn" "Bottone a scelta"
+"You must supply a name for this function!" "Devi fornire un nome per questa funzione!"
+"You have to select index fields!" "Devi selezionare i campi dell'indice"
+"Constraint" "Constraint"
+"The script must have a name" "Lo script deve avere un nome"
+"Save" "Salva"
+"Exit" "Esci"
+"Inherits" "Eredita"
+"Delete field" "Cancella campo"
+"About" "Apropos"
+"Empty field name ?" "Nome del campo vuoto?"
+"All report information will be deleted.\n\nProceed ?" "Tutte le informazioni relative al report saranno cancellate.\n\n Procedo ?"
+"Host" "Host"
+"vacuuming database %s ..." "vacuuming database %s ..."
+"Indexes defined" "Indici definiti"
+
+"Owner ID" "Proprietario ID"
+"You must specify field size!" "Devi specificare la dimensione del campo!"
+"Schema '%s' already exists!" "Lo schema '%s' esiste gia'!"
+"There is another field with the same name: '%s'!\n\nReplace it ?" "C'e' un'altro campo con lo stesso nome: '%s'!\n\nSostituisco ? "
+"Contents" "Contenuto"
+"Views" "Views"
+"Variable" "Variabile"
+"Error executing query\n\n%s\n\nPostgreSQL error message:\n%s\nPostgreSQL status:%s" "Errore eseguendo la query\n\n%s\n\nErrore PostgreSQL:\n%s\nPostgreSQL status:%s"
+"Filter conditions" "Condizioni di filtro"
+"Error retrieving query definition" "Errore caricando la definizione della query"
+"Error deleting view" "Errore durante la cancellazione"
+"New" "Nuovo"
+"Tables" "Tabelle"
+"Create" "Crea"
+"Forms need an internal name, only literals, low case" "Il form ha bisogno di un nome interno, solo lettere minuscole"
+"Do you want to save the form into the database?" "Vuoi salvare il form nel database ?"
+"Schema '%s' was not found!" "Lo schema '%s' non e' stato trovato!"
+"proportional" "proporzionale"
+"Function saved!" "Funzione salvata!"
+"with OIDs" "con OIDs"
+"Table information" "Informazioni tabella"
+"Error inserting new record" "Errore inserendo il nuovo record"
+"Column name '%s' already exists in this table!" "Il campo '%s' esiste gia'!"
+"File" "File"
+"Your table has no fields!" "La tabella non ha campi !"
+"Height" "Altezza"
+"You will always get the latest version at:" "Troverai l'ultima versione su:"
+"Form must have a name" "Il form deve avere un nome"
+"Password" "Password"
+"Valid until (date)" "Valido fino a"
+"Report source" "Sorgente del report"
+"Allow user to create databases" "L'utente puo' creare database"
+"Cancel" "Abbandona"
+"Is clustered ?" "Is clustered ?"
+"Add new column" "Aggiungi nuovo campo"
+"Show SQL" "Mostra SQL"
+"New name" "Nuovo nome"
+"Table '%s' not found!" "Tabella '%s' non trovata!"
+"Form name" "Nome form"
+"Visual designer" "Visual Designer"
+"You choose to delete index\n\n %s \n\nProceed?" "Hai scelto di cancellare l'indice\n\n %s \n\nProcedo?"
+"Error retrieving from" "Errore caricando da"
+"Save query definition" "Salva la definizione della query"
+"A Tcl/Tk interface to\nPostgreSQL\nby Constantin Teodorescu" "Una interfaccia Tcl/Tk verso\nPostgreSQL\n di Constantin Teodorescu"
+"Operation completed!" "Operazione completata!"
+"Max rows displayed in table/query view" "Numero massimo di righe nella visualiz. tabella/query"
+"Passwords do not match!" "La password non corrisponde!"
+"Rename" "Rinomina"
+"Entry" "Entry"
+"Error retrieving schema definition" "Errore caricando la definizione dello schema"
+"This is an action query!\n\nExecute it?" "Questa e' una query d'azione\n\nLa eseguo?"
+"Error retrieving view definition for" "Errore caricando la definizione di"
+"options" "opzioni"
+"Sequence '%s' not found!" "Sequence '%s' non trovata!"
+"Text" "Testo"
+"Tcl error executing pg_exec %s\n\n%s" "Errore Tcl eseguendo pg_exec %s\n\n%s"
+"Width" "Larghezza"
+"You have to supply a name for this query!" "Devi specificare un nomer per la query"
+"Accessing data. Please wait ..." "Carico i dati, attendi..."
+"Report footer" "Piede del report"
+"Parameters" "Parametri"
+"Queries" "Queries"
+"Query '%s' already exists!" "La query '%s' esiste gia'!"
+"Font bold" "Carattere grassetto"
+"Query builder" "Query builder"
+"Error defining view" "Errore definendo la query"
+"Top" "Sopra"
+"You must supply a name for your table!" "Devi specificare un nome per la tabella!"
+"Page footer" "Pie' di pagina"
+"Font italic" "Carattere corsivo"
+"Field name not entered!" "Nome del campo non inserito!"
+"Index name cannot be null!" "Il nome dell'indice non puo' essere nullo!"
+"Sort" "Ordina"
+"Import-Export table" "Importa/Esporta tabella"
+"Point" "Punto"
+"type" "tipo"
+"You should supply a name for this sequence" "Tu devi fornire un nome per la sequenza"
+"Remove link ?" "Rimuovere collegamento ?"
+"You have to supply a table name!" "Devi specificare il nome tabella!"
+"Report header" "Testata del report"
+"Attributes" "Attributi"
+"Table '%s' already in schema" "Tabella '%s' esiste gia' nello schema!"
+"Username" "Nome utente"
+"Minvalue" "Valore minimo"
+"Sequence name" "Nome del sequence"
+"Define sequence" "Definisci la sequenza"
+"Function" "Funzione"
+"Sorting and filtering not (yet) available from queries!\n\nPlease enter them in the query definition!" "Ordinamento e filtri non ancora disponibili dalle query!\n\nInseriscili nella definizione della query!"
+"Reports" "Reports"
+
+"primary key" "chiave primaria"
+
+"Visual schema designer" "Ambiente sviluppo relazioni visuale"
+
+Print Stampa
+
+"Print to Postscript" "Stampa Postscript"
+
+Commands Azioni
+
+"Report preview" "Anteprima report"
+
+"The printed image in Postscript is in the file pgaccess-report.ps" "La stampa in Poscript è nel file pgaccess-report.ps"
+
+"Columns" "Campi"
+
+"Indexes" "Indici"
+
+"Permissions" "Autorita"
+
+"not null" "non nullo"
+
+"Cluster index" "Cluster indice"
+
+"index columns" "campi dello indice"
+
+"Add user" "Nuovo utente"
+
+"Change permissions" "Cambiare autorita"
+
+"select" "selezioni"
+
+"update" "update"
+
+"insert" "inserisci"
+
+"rule" "regoli"
+
+"Identification" "Identificatione"
+
+"Owner ID" "ID dello proprieta"
+
+"Has primary key ?" "Chiave primaria ?"
+
+"Has rules ?" "Regoli definiti ?"
+
+"Statistics" "Statistica"
+
+"Number of tuples" "Numero righe"
+
+"Number of pages" "Numero pagine"
+
+"Index name" "Nome indici"
+
+"Index fields" "Campi dello indice"
+
+"Table OID" "Tabella OID"
+
+}
diff --git a/src/bin/pgaccess/lib/languages/magyar b/src/bin/pgaccess/lib/languages/magyar
new file mode 100644 (file)
index 0000000..3293632
--- /dev/null
@@ -0,0 +1,525 @@
+array set Messages {
+
+"Label" "Cimke"
+"Save schema" "Séma mentése"
+"Is unique ?" "Egyedi (UNIQUE) ?"
+"Report builder" "Jelentés szerkesztõ"
+"Criteria" "Feltételek"
+"FATAL ERROR upgrading PgAccess table" "FATÁLIS HIBA keletkezett a PgAccess tábla frissitése közben"
+"Save this query as a view" "Nézetként (VIEW) akarod elmenteni a lekérdezést?"
+"Page header" "Oldal fejléc"
+"Query name" "Lekérdezés név"
+"Please select an object first!" "Elõször válassz egy objektumot!"
+"Fields :" "Mezõk :"
+"Name" "Név"
+"File name" "Fájl név"
+"Detail record" "Részletes bejegyzés"
+"Auto-load the last opened database at startup" "Az utolsóként használt adatbázis automatikus nyitésa inditáskor"
+"Maxvalue" "Maximális érték"
+"Start value" "Kezdõérték"
+"Report fields" "Jelentés mezõk"
+"Test form" "Teszt kérdõiv (FORM)"
+"Error trying to connect to database '%s' on host %s \n\nPostgreSQL error message:%s" "Hiba a(z) '%s' nevû adatbázishoz kapcsolódás közben a(z) '%s' szerveren.\n\nPostgreSQL hibaüzenet:%s"
+"No field type ?" "Nincs a mezõnek tipusa ?"
+"User without name?" "Felhasználó név nélkül ?"
+"You have to supply a name for this schema!" "Nevet kell adj ennek a sémának !"
+"Last value" "Legutóbbi érték"
+"Preferences" "Beállitások"
+"View '%s' already exists!\nOverwrite ?" "A(z) '%s' nevû nézet (VIEW) már létezik!\n Felülirás ?"
+"You have to select an index!" "Választanod kell egy indexet!"
+"Field type" "Mezõtipus"
+"Script name" "Szkript neve"
+"Reload" "Újratölt"
+"Remove table %s from query?" "Törölni akarod a(z) '%s' táblát ebbõl a lekérdezésbõl ?"
+"SQL window" "SQL ablak"
+"Allow user to create other users" "Engedély a felhasználónak új felhasználó készitésére"
+"Delete current record ?" "Az aktuális bejegyzés törlése ?"
+"List box" "Lista"
+"Save to query builder" "Mentsd a lekérdezés szerkesztõbe"
+"fixed width" "fix szélesség"
+"Scripts" "Szkriptek"
+"Yes" "Igen"
+"Add label" "Adj hozzá cimkét"
+"Sequence created!" "A szekvencia (SEQUENCE) elkészült!"
+"Field information" "Mezõ információ"
+
+"Design" "Tervezés"
+"Field" "Mezõ"
+"You have to supply an external file name!" "Meg kell adj egy külsõ fájlnevet!"
+"Increment" "Növelés"
+"No" "Nem"
+"Form design" "Kérdõiv (FORM) tervezés"
+"You must supply a return type!" "Szükség van visszatérési értékre!"
+"Remove field from result ?" "A mezö törlése az eredménybõl ?"
+"There is another object (a %s) with the same name.\nPlease change it!" "Van már ilyen nevû (%s) objektum!\nLégyszives változtasd meg!"
+"This query has no commands?" "Ebben a lekérdezésben nincs parancs?"
+"Execute query" "Lekérdezés futtatása"
+"field cannot be null" "a mezõ nem lehet NULL"
+"Help" "Súgó"
+"Rename column" "Az oszlop átnevezése"
+"Database" "Adatbázis"
+"Information" "Információ"
+"Close" "Zárás"
+"Command" "Utasitás"
+"Table" "Tábla"
+"verify password" "jelszó ellenõrzés"
+"Vacuum" "Porszivózás (VACUUM)"
+"Default value" "Alapérték"
+"Import" "Behozatal"
+"Delete index" "Index törlés"
+"Move up" "Mozgasd fel"
+"index properties" "index tulajdonságok"
+"check" "ellenõrzi"
+"Create new table" "Új tábla készités"
+"Visual query designer" "Lekérdezés tervezõ"
+"Delete all" "Törölni mindet"
+"You are going to delete\n\n %s \n\nProceed?" "Le fogod törölni az alábbit:\n\n %s \n\nFolytatod?"
+"Schema name" "Séma neve"
+"Error executing query" "Hiba a lekérdezés futtatása közben"
+"Report name" "Jelentés neve"
+"Add field" "Mezõ hozzáadás"
+"Field name" "Mezõnév"
+"FATAL ERROR searching for PgAccess system tables" "FATÁLIS HIBA a PgAccess rendszertáblák keresésénél"
+"A big number of rows displayed in table view will take a lot of memory!" "A nézetnél (VIEW) kijelzendõ sorok nagy száma miatt sok memória fog lefoglalódni !"
+"Preview" "Elõzetes nézet"
+"Users" "Felhasználók"
+"Owner" "Tulajdonos"
+"Form's window internal name" "Kérdõiv (FORM) ablakának belsõ használatú neve"
+"Sort field" "Mezõ rendezése"
+"New name is the same as the old one!" "Az új név megegyezik a régivel!"
+"Warning" "Figyelem"
+"Suggestions at" "Javaslatok itt:"
+"Functions" "Függvények"
+"Schema" "Séma"
+"Open" "Nyit"
+"size" "méret"
+"Delete" "Törlés"
+"Returns" "Visszatér"
+"Define new user" "Új felhasználó definiálása"
+"Move down" "Mozgasd le"
+"Design script" "Szkript tervezés"
+"Check box" "Check box"
+"FINAL WARNING" "UTOLSÓ FIGYELMEZTETÉS"
+"Add table" "Tábla hozzáadás"
+"Table viewer font" "Tábla nézõ betûkészlet"
+"The field type is not specified!" "A mezõ tipusa nincs megadva!"
+"Close test form" "Zárd le a teszt kérdõivet (FORM)"
+"Export table" "Tábla kivitel"
+"Add new index" "Ûj index hozzáadás"
+"Left" "Bal"
+"Field delimiter" "Mezõ határoló"
+"Add formula" "Formula hozzáadás"
+"Open database" "Adatbázis megnyitás"
+"Return" "Visszatérés"
+"Changed fonts may appear in the next working session!" "A megváltoztatott betûkészlet a következõ futtatásnál lesz látható!"
+"Error" "Hiba"
+"Enter a field name" "Adj meg egy mezõnevet !"
+"field name" "Mezõnév"
+"Forms" "Kérdõivek"
+"Cannot add column" "Nem lehet oszlopot hozzáadni"
+"Clean" "Törlés"
+"Delete all objects ?" "Minden objektum törlése ?"
+"Preferred language" "Választott nyelv"
+"Execute SQL" "SQL futtatás"
+"Sequences" "Szekvenciák"
+"Button" "Gomb"
+"Language" "Nyelv"
+"Query '%s' was not found!" "A(z) '%s' nevû lekérdezés nem található!"
+"Object" "Objektum"
+"Font fixed" "Fix betûkészlet"
+"Table name" "Táblanév"
+"Export" "Kivitel"
+"Change user" "Felhasználócsere"
+"You must give object a new name!" "Az objektumnak új nevet kell adjál!"
+"Query" "Lekérdezés"
+"User name" "Felhasználónév"
+"Font normal" "Normális betûkészlet"
+"Import table" "Tábla bevitel"
+"Toolbar" "Eszközpult"
+"Radio btn" "Rádiógomb"
+"You must supply a name for this function!" "Hiányzik a függvény neve!"
+"You have to select index fields!" "Az index mezõket kell választanod!"
+"Constraint" "Kényszer (CONSTRAINT)"
+"The script must have a name" "Hiányzik a szkript neve"
+"Save" "Mentés"
+"Exit" "Kilépés"
+"Inherits" "örökli"
+"Delete field" "Mezõ törlés"
+"About" "A programról"
+"Empty field name ?" "Nom de champ inexistant ?"
+"All report information will be deleted.\n\nProceed ?" "Toutes les informations de l'état vont être détruites\n\nContinuer ?"
+"Host" "Szerver"
+"vacuuming database %s ..." "A(z) %s adatbázis porszivózása ..."
+"Indexes defined" "Definiált indexek"
+"You must specify field size!" "Hiányzik a mezõméret!"
+"Schema '%s' already exists!" "A(z) '%s' schéma már létezik!"
+"There is another field with the same name: '%s'!\n\nReplace it ?" "Már van ilyen nevû mezõ: '%s'!\n\nFelülirás ?"
+"Contents" "Tartalom"
+"Views" "Nézetek"
+"Variable" "Változó"
+"Error executing query\n\n%s\n\nPostgreSQL error message:\n%s\nPostgreSQL status:%s" "Hiba a lekérdezés futtatása közben\n\n%s\n\nPostgreSQL hibaüzenet:\n%s\nPostgreSQL státusz:%s"
+"Filter conditions" "Szûrõfeltételek"
+"Error retrieving query definition" "Hiba a lekérdezés definiciójának betöltésénél"
+"Error deleting view" "Hiba a nézet (VIEW) törlésénél"
+"New" "Új"
+"Tables" "Táblák"
+"Create" "Elkészit"
+"Forms need an internal name, only literals, low case" "A kérdõiveknek (FORM) kell egy belsõ név, csak kisbetûkkel"
+"Do you want to save the form into the database?" "El akarod menteni a kérdõivet (FORM) az adatbázisba ?"
+
+"Schema '%s' was not found!" "A(z) '%s' nevû séma nem található!"
+"proportional" "megfelelõ"
+"Function saved!" "A függvény elmentve!"
+"with OIDs" "OID-ekkel"
+"Table information" "Tábla információ"
+"Error inserting new record" "Hiba az üj bejegyzés tárolásával"
+"Column name '%s' already exists in this table!" "A(z) '%s' nevû oszlop már létezik ebben a táblában !"
+"File" "Fájl"
+"Your table has no fields!" "A táblában nincsenek mezõk!"
+"Height" "Magasság"
+"You will always get the latest version at:" "A legfrissebb verzió megszerezhetõ innen:"
+"Form must have a name" "Hiányzik a kérdõiv (FORM) neve !"
+"Password" "Jelszó"
+"Valid until (date)" "Érvényes eddig (dátum)"
+"Report source" "A jelentés forrása"
+"Allow user to create databases" "Engedély a felhasználónak új adatbázis készitésére"
+"Cancel" "Mégsem"
+"Is clustered ?" "CLUSTER-elt ?"
+"Add new column" "Új oszlop hozzáadás"
+"Show SQL" "SQL parancsok"
+"New name" "Új név"
+"Table '%s' not found!" "A(z) '%s' nevû tábla nem található!"
+"Form name" "Kérdõiv (FORM) név"
+"Visual designer" "Tervezõ"
+"You choose to delete index\n\n %s \n\nProceed?" "Biztos, hogy akarod törölni az alábbi indexet?\n\n %s"
+"Error retrieving from" "Hiba a betöltésnél errõl a helyrõl"
+"Save query definition" "A lekérdezés elmentése"
+"A Tcl/Tk interface to\nPostgreSQL\nby Constantin Teodorescu" "Egy Tcl/Tk felület a\nPostgreSQL-hez\nKészitette: Constantin Teodorescu"
+"Operation completed!" "Beavatkozás végrehajtva!"
+"Max rows displayed in table/query view" "Maximális sorok száma a tábláknál/lekérdezéseknél"
+"Passwords do not match!" "A jelszók nem egyeznek!"
+"Rename" "Átnevezés"
+"Entry" "Bejegyzés"
+"Error retrieving schema definition" "Hiba a séma-definició betöltése közben"
+"This is an action query!\n\nExecute it?" "Ez nem lekérdezés, hanem parancs.\nFuttatás ?"
+"Error retrieving view definition for" "Hiba a nézet (VIEW) betöltése közben "
+"options" "beállitások"
+"Sequence '%s' not found!" "A(z) '%s' nevû szekvencia nem található!"
+"Text" "Szöveg"
+"Tcl error executing pg_exec %s\n\n%s" "Tcl hiba a pg_exec futtatásánál %s\n\n%s"
+"Width" "Szélesség"
+"You have to supply a name for this query!" "Hiányzik a lekérdezés neve!"
+"Accessing data. Please wait ..." "Adatelérés. Kis türelmet ..."
+"Report footer" "A jelentés alja"
+"Parameters" "Paraméterek"
+"Queries" "Lekérdezések"
+"Query '%s' already exists!" "A(z) '%s' nevû lekérdezés már létezik!"
+"Font bold" "Vastag betûkészlet"
+"Query builder" "Lekérdezés szerkesztõ"
+"Error defining view" "Hiba a nézet (VIEW) definiálásánál"
+"Top" "Csúcs"
+"You must supply a name for your table!" "Hiányzik a tábla neve!"
+"Page footer" "A lap alja"
+"Font italic" "Dõlt betûkészlet"
+"Field name not entered!" "A mezõnév hiányzik!"
+"Index name cannot be null!" "Az index nem lehet NULL!"
+"Sort" "Rendezés"
+"Import-Export table" "Tábla behozatal/kivitel"
+"Point" "Pont"
+"type" "tipus"
+"You should supply a name for this sequence" "Hiányzik a szekvencia neve!"
+"Remove link ?" "A kapcsolat törlése?"
+"You have to supply a table name!" "Hiányzik a tábla neve!"
+"Report header" "Jelentés fejléc"
+"Attributes" "Attribútumok"
+"Table '%s' already in schema" "A(z) '%s' tábla már szerepel a sémában!"
+"Username" "Felhasználó név"
+"Minvalue" "Minimális érték"
+"Sequence name" "Szekvencianév"
+"Define sequence" "Szekvencia definiálás"
+"Function" "Függvény"
+"Sorting and filtering not (yet) available from queries!\n\nPlease enter them in the query definition!" "A rendezés és szûrés (még) nem megoldott a lekérdezéseknél!\n\nHasználd õket a lekérdezés definiciókban!"
+"Reports" "Jelentések"
+
+"Columns" "Oszlopok"
+
+"Indexes" "Indexek"
+
+"Permissions" "Engedélyek"
+
+"not null" "nem NULL"
+
+"Cluster index" "Index CLUSTER-elés"
+
+"index columns" "indexelt oszlopok"
+
+"Add user" "Felhasználó hozzáadás"
+
+"Change permissions" "Engedélyek megváltoztatása"
+
+"select" "olvasás"
+
+"update" "frissités"
+
+"insert" "tárolás"
+
+"rule" "szabályok"
+
+"Identification" "Azonositás"
+
+"Owner ID" "Tulajdonos azonositó"
+
+"Has primary key ?" "Van elsõdleges kulcsa ?"
+
+"Has rules ?" "Vannak szabályok ?"
+
+"Statistics" "Statisztika"
+
+"Number of tuples" "Bejegyzések száma"
+
+"Number of pages" "Oldalak száma"
+
+"Index name" "Index név"
+
+"Index fields" "Index mezõk"
+
+"Table OID" "Tábla OID"
+}
+
+
diff --git a/src/bin/pgaccess/lib/languages/romana b/src/bin/pgaccess/lib/languages/romana
new file mode 100644 (file)
index 0000000..d234ce3
--- /dev/null
@@ -0,0 +1,526 @@
+array set Messages {
+
+"Label" "Etichetã"
+"Save schema" "Salveazã planul"
+
+"Is unique ?" "Este index unic ?"
+
+"Report builder" "Proiectare rapoarte"
+
+"Criteria" "Conditie"
+
+"FATAL ERROR upgrading PgAccess table" "EROARE FATALA la actualizarea tabelei PgAccess"
+
+"Save this query as a view" "Salveazã aceastã selecþie ca o vedere"
+
+"Page header" "Cap de paginã"
+
+"Query name" "Nume selecþie"
+
+"Please select an object first!" "Selectati mai intai un obiect!"
+
+"Fields :" "Cîmpurile indexului"
+
+"Name" "Nume"
+
+"File name" "Nume fiºier"
+
+"Detail record" "Înregistrãri"
+
+"Auto-load the last opened database at startup" "Încarcã automat la lansare ultima bazã deschisã"
+
+"Maxvalue" "Valoare maximã"
+
+"Start value" "Începe de la"
+
+"Report fields" "Câmpuri disponibile"
+
+"Test form" "Testeazã macheta"
+
+"Error trying to connect to database '%s' on host %s \n\nPostgreSQL error message:%s" "Eroare la conectarea la baza de date '%s' pe masina %s \n\nMesajul de eroare PostgreSQL:%s"
+
+"No field type ?" "Tip cimp necompletat!"
+
+"User without name?" "Utilizatorul asta n-ar si el un nume?"
+
+"You have to supply a name for this schema!" "Trebuie sa dati un nume acestui plan!"
+
+"Last value" "Ultima valoare"
+
+"Preferences" "Preferinþe"
+
+"View '%s' already exists!\nOverwrite ?" "Vederea '%s' mai exista!\nO suprainscriem ?"
+
+"You have to select an index!" "Trebuie sa selectati un index!"
+
+"Field type" "Tip cãmp"
+
+"Script name" "Nume script"
+
+"Reload" "Reîncãrcare"
+
+"Remove table %s from query?" "Eliminati tabela %s din selectie?"
+
+"SQL window" "Comenzi SQL executate"
+
+"Allow user to create other users" "Are voie sã creeze alþi utilizatori"
+
+"Delete current record ?" "Stergeti inregistrarea curenta?"
+
+"List box" "Listã"
+
+"Save to query builder" "Salveazã fraza SQL"
+
+"fixed width" "lãþime fixã"
+
+"Scripts" "Scripturi"
+
+"Yes" "Da"
+
+"Add label" "Adaugã etichetã"
+
+"Sequence created!" "Secventa a fost creata!"
+
+"Field information" "Informaþii despre câmpuri"
+
+"Design" "Proiecteazã"
+
+"Field" "Cimp"
+
+"You have to supply an external file name!" "Trebuie sa introduceti numele fisierului extern!"
+
+"Increment" "Increment"
+
+"No" "Nu"
+
+"Form design" "Proiectare machetã"
+
+"You must supply a return type!" "Trebuie sa introduceti tipul rezultatului"
+
+"Remove field from result ?" "Eliminati acest cimp din rezultat?"
+
+"There is another object (a %s) with the same name.\nPlease change it!" "Mai este un obiect (%s) cu acelasi nume!\nSchimbati-l!"
+
+"This query has no commands?" "Aceasta selectie nu are definitie?"
+
+"Execute query" "Executã selecþia"
+
+"field cannot be null" "obligatoriu de completat"
+
+"Help" "Ajutor"
+
+"Rename column" "Redenumeºte cîmp"
+
+"Database" "Baza de date"
+
+"Information" "Informaþii"
+
+"Close" "Închide"
+
+"Command" "Comandã"
+
+"Table" "Tabela"
+
+"verify password" "verificã parola"
+
+"Vacuum" "Taseazã"
+
+"Default value" "Valoare implicitã"
+
+"Import" "Importã"
+
+"Delete index" "ªterge index"
+
+"Move up" "Urcã"
+
+"index properties" "proprietãþi index"
+
+"check" "verificã"
+
+"Create new table" "Creazã tabelã nouã"
+
+"Visual query designer" "Proiectare vizuala a selectiilor"
+
+"Delete all" "ªterge toate"
+
+"You are going to delete\n\n %s \n\nProceed?" "Urmeaza sa stergeti obiectul\n\n %s \n\nConfirmati?"
+
+"Schema name" "Numele planului"
+
+"Error executing query" "Eroare la executia selectiei"
+
+"Report name" "Nume raport"
+
+"Add field" "Adaugã-l"
+
+"Field name" "Nume câmp"
+
+"FATAL ERROR searching for PgAccess system tables" "EROARE FATALA la citirea tabelelor necesare PgAccess"
+
+"A big number of rows displayed in table view will take a lot of memory!" "Un numãr mare de înregistrãri încãrcate va lua multã memorie"
+
+"Preview" "Încercare"
+
+"Users" "Utilizatori"
+
+"Owner" "Aparþine lui"
+
+"Form's window internal name" "Numele intern al machetei"
+
+"Sort field" "Cîmpuri sortare"
+
+"New name is the same as the old one!" "Numele nou este acelasi cu numele vechi!"
+
+"Warning" "Avertisment"
+
+"Suggestions at" "Sugestii la"
+
+"Functions" "Funcþii"
+
+"Schema" "Plan"
+
+"Open" "Deschide"
+
+"size" "mãrime"
+
+"Delete" "ªterge"
+
+"Returns" "Întoarce"
+
+"Define new user" "Definire utilizator nou"
+
+"Move down" "Coboarã"
+
+"Design script" "Proiecteazã script"
+
+"Check box" "Marcaj"
+
+"FINAL WARNING" "AVERTISMENT FINAL"
+
+"Add table" "Adaugã tabelã"
+
+"Table viewer font" "Fonturi tabele"
+
+"The field type is not specified!" "Tipul cimpului nu a fost specificat"
+
+"Close test form" "Inchide macheta test"
+
+"Export table" "Exportã tabelã"
+
+"Add new index" "Adaugã index nou"
+
+"Left" "Stânga"
+
+"Field delimiter" "Delimitator cîmp"
+
+"Add formula" "Adaugã formulã"
+
+"Open database" "Deschide baza de date"
+
+"Return" "Selectat"
+
+"Changed fonts may appear in the next working session!" "Fonturile se vor schimba la urmãtoarea lansare"
+
+"Error" "Eroare"
+
+"Enter a field name" "Trebuie sa introduceti numele cimpului"
+
+"field name" "Nume cîmp"
+
+"Forms" "Machete"
+
+"Cannot add column" "Nu putem adauga cimpul"
+
+"Clean" "Curãþã"
+
+"Delete all objects ?" "Stergeti toate obiectele?"
+
+"Preferred language" "Limba preferatã"
+
+"Execute SQL" "Executã selecþia"
+
+"Sequences" "Secvenþe"
+
+"Button" "Buton"
+
+"Language" "Limbaj"
+
+"Query '%s' was not found!" "Definitia pentru selectia '%s' nu a fost gasita"
+
+"Object" "Obiect"
+
+"Font fixed" "Font fix"
+
+"Table name" "Nume tabelã"
+
+"Export" "Exportã"
+
+"Change user" "Modificare date utilizator"
+
+"You must give object a new name!" "Trebuie sa introduceti totusi numele nou"
+
+"Query" "Query"
+
+"User name" "Nume utilizator"
+
+"Font normal" "Font normal"
+
+"Import table" "Importã tabelã"
+
+"Toolbar" "Scule"
+
+"Radio btn" "Selector"
+
+"You must supply a name for this function!" "Trebuie sa introduceti un nume pentru aceasta functie"
+
+"You have to select index fields!" "Trebuie sa selectati cimpurile indexului!"
+
+"Constraint" "Cerinþe"
+
+"The script must have a name" "Script-ul ar trebui sa aiba un nume"
+
+"Save" "Salveazã"
+
+"Exit" "Terminare"
+
+"Inherits" "Strãmoºi"
+
+"Delete field" "ªterge cîmp"
+
+"About" "Despre"
+
+"Empty field name ?" "Nume cimp necompletat"
+
+"All report information will be deleted.\n\nProceed ?" "Toate obiectele din raport vor fi sterse!\n\nSinteti de acord?"
+
+"Host" "Maºina"
+
+"vacuuming database %s ..." "Tasãm baza de date %s ..."
+
+"Indexes defined" "Indecºi definiþi"
+
+"You must specify field size!" "Marimea cimpului trebuie specificata"
+
+"Schema '%s' already exists!" "Schema '%s' exista deja!"
+
+"There is another field with the same name: '%s'!\n\nReplace it ?" "Mai exista un cimp cu acelasi nume: '%s'!\n\nIl inlocuim cu descrierea noua?"
+
+"Contents" "Conþinut"
+
+"Views" "Vederi"
+
+"Variable" "Variabilã"
+
+"Error executing query\n\n%s\n\nPostgreSQL error message:\n%s\nPostgreSQL status:%s" "Eroare la executia selectiei:\n\n%s\n\nMesaj de eroare PostgreSQL:\n%s\nStare:%s"
+
+"Filter conditions" "Condiþii de filtrare"
+
+"Error retrieving query definition" "Eroare la citirea definitiei pentru selectie"
+
+"Error deleting view" "Eroare la stergerea vederii"
+
+"New" "Nou"
+
+"Tables" "Tabele"
+
+"Create" "Creazã"
+
+"Forms need an internal name, only literals, low case" "Machetele au nevoie de un nume intern, doar litere mici"
+
+"Do you want to save the form into the database?" "Vrei sa salvezi descrierea machetei in baza de date?"
+
+"Schema '%s' was not found!" "Schema '%s' nu a fost gasita!"
+
+"proportional" "proporþional"
+
+"Function saved!" "Functia a fost salvata!"
+
+"with OIDs" "cu OID-uri"
+
+"Table information" "Informaþii despre tabela"
+
+"Error inserting new record" "Eroare la adaugarea noii inregistrari"
+
+"Column name '%s' already exists in this table!" "Cimpul '%s' exista deja in tabela!"
+
+"File" "Fiºier"
+
+"Your table has no fields!" "Tabela asta nu are nici un cimp ?"
+
+"Height" "Înãlþime"
+
+"You will always get the latest version at:" "Întotdeauna ultima versiune se va gãsi la"
+
+"Form must have a name" "Macheta trebuie sa aiba si ea un nume!"
+
+"Password" "Parolã"
+
+"Valid until (date)" "Valabil pînã la"
+
+"Report source" "Sursa raportului"
+
+"Allow user to create databases" "Are voie sã creeze baze de date"
+
+"Cancel" "Abandon"
+
+"Is clustered ?" "E conglomerat ?"
+
+"Add new column" "Adaugã cîmp nou"
+
+"Show SQL" "Aratã comanda"
+
+"New name" "Nume nou"
+
+"Table '%s' not found!" "Tabela '%s' nu a fost gasita!"
+
+"Form name" "Nume machetã"
+
+"Visual designer" "Proiectare vizualã"
+
+"You choose to delete index\n\n %s \n\nProceed?" "Urmeaza sa stergeti indexul\n\n %s \n\nConfirmati?"
+
+"Error retrieving from" "Eroare la citirea tabelei"
+
+"Save query definition" "Salveazã definiþia selecþiei"
+
+"A Tcl/Tk interface to\nPostgreSQL\nby Constantin Teodorescu" "O interfaþã Tcl/Tk pentru\nPostgreSQL\nde Constantin Teodorescu"
+
+"Operation completed!" "Operatiune terminata!"
+
+"Max rows displayed in table/query view" "Numãr maxim înregistrãri afiºate"
+
+"Passwords do not match!" "Parolele nu se prea potrivesc!"
+
+"Rename" "Redenumeºte"
+
+"Entry" "Cîmp"
+
+"Error retrieving schema definition" "Eroare la citirea definitiei pentru plan"
+
+"This is an action query!\n\nExecute it?" "Aceasta este o comanda nu o selectie!\n\nO executam?"
+
+"Error retrieving view definition for" "Eroare la citirea definitiei pentru vederea"
+
+"options" "opþiuni"
+
+"Sequence '%s' not found!" "Secventa '%s' nu a fost gasita!"
+
+"Text" "Text"
+
+"Tcl error executing pg_exec %s\n\n%s" "Eroare Tcl la executia comenzii %s\n\n%s"
+
+"Width" "Lãþime"
+
+"You have to supply a name for this query!" "Trebuie sa dati totusi un nume acestei selectii"
+
+"Accessing data. Please wait ..." "Citim inregistrarile. Asteptati ..."
+
+"Report footer" "Încheiere raport"
+
+"Parameters" "Parametrii"
+
+"Queries" "Selecþii"
+
+"Query '%s' already exists!" "Selectia '%s' exista deja!"
+
+"Font bold" "Font îngroºat"
+
+"Query builder" "Proiectare selectii"
+
+"Error defining view" "Eroare la definirea vederii"
+
+"Top" "Sus"
+
+"You must supply a name for your table!" "Trebuie sa introduceti un nume pentru aceasta tabela!"
+
+"Page footer" "Încheiere paginã"
+
+"Font italic" "Font înclinat"
+
+"Field name not entered!" "Nu ati introdus numele cimpului!"
+
+"Index name cannot be null!" "Numele indexului trebuie sa fie completat!"
+
+"Sort" "Sortare"
+
+"Import-Export table" "Import/Export tabela"
+
+"Point" "Selecteazã"
+
+"type" "tip"
+
+"You should supply a name for this sequence" "Ar trebui sa dai un nume secventei"
+
+"Remove link ?" "Stergeti aceasta legatura?"
+
+"You have to supply a table name!" "Trebuie sa introduceti numele tabelei!"
+
+"Report header" "Cap de raport"
+
+"Attributes" "Atribute"
+
+"Table '%s' already in schema" "Tabela '%s' exista deja pe plan!"
+
+"Username" "Utilizator"
+
+"Minvalue" "Valoare minimã"
+
+"Sequence name" "Nume secvenþã"
+
+"Define sequence" "Defineºte secvenþã"
+
+"Function" "Funcþie"
+
+"Sorting and filtering not (yet) available from queries!\n\nPlease enter them in the query definition!" "Sortari si filtrari nu se pot face din vizualizare selectii\n\nSpecificati-le in definitia selectiei!"
+
+"Reports" "Rapoarte"
+
+"primary key" "cheie primarã"
+
+"Back" "Inapoi"
+
+"Columns" "Coloane"
+
+"Indexes" "Indecºi"
+
+"Permissions" "Drepturi"
+
+"not null" "nenul"
+
+"Cluster index" "Aglomereazã indexul"
+
+"index columns" "compunerea indexului"
+
+"Add user" "Adaugã utilizator"
+
+"Change permissions" "Schimbã drepturile de acces"
+
+"select" "selecþii"
+
+"update" "actualizãri"
+
+"insert" "inserãri"
+
+"rule" "reguli"
+
+"Identification" "Identificare"
+
+"Owner ID" "ID-ul proprietarului"
+
+"Has primary key ?" "Are cheie primarã ?"
+
+"Has rules ?" "Are reguli definite ?"
+
+"Statistics" "Statistice"
+
+"Number of tuples" "Numãr înregistrãri"
+
+"Number of pages" "Numãr pagini"
+
+"Index name" "Nume index"
+
+"Index fields" "Coloanele indexului"
+
+"Table OID" "OID-ul tabelei"
+}
diff --git a/src/bin/pgaccess/lib/mainlib.tcl b/src/bin/pgaccess/lib/mainlib.tcl
new file mode 100644 (file)
index 0000000..b4379a4
--- /dev/null
@@ -0,0 +1,987 @@
+namespace eval Mainlib {
+
+proc {cmd_Delete} {} {
+global PgAcVar CurrentDB
+if {$CurrentDB==""} return;
+set objtodelete [get_dwlb_Selection]
+if {$objtodelete==""} return;
+set delmsg [format [intlmsg "You are going to delete\n\n %s \n\nProceed?"] $objtodelete]
+if {[tk_messageBox -title [intlmsg "FINAL WARNING"] -parent .pgaw:Main -message $delmsg -type yesno -default no]=="no"} { return }
+switch $PgAcVar(activetab) {
+       Tables {
+               sql_exec noquiet "drop table \"$objtodelete\""
+               sql_exec quiet "delete from pga_layout where tablename='$objtodelete'"
+               cmd_Tables
+       }
+       Schema {
+               sql_exec quiet "delete from pga_schema where schemaname='$objtodelete'"
+               cmd_Schema
+       }
+       Views {
+               sql_exec noquiet "drop view \"$objtodelete\""
+               sql_exec quiet "delete from pga_layout where tablename='$objtodelete'"
+               cmd_Views
+       }
+       Queries {
+               sql_exec quiet "delete from pga_queries where queryname='$objtodelete'"
+               sql_exec quiet "delete from pga_layout where tablename='$objtodelete'"
+               cmd_Queries
+       }
+       Scripts {
+               sql_exec quiet "delete from pga_scripts where scriptname='$objtodelete'"
+               cmd_Scripts
+       }
+       Forms {
+               sql_exec quiet "delete from pga_forms where formname='$objtodelete'"
+               cmd_Forms
+       }
+       Sequences {
+               sql_exec quiet "drop sequence \"$objtodelete\""
+               cmd_Sequences
+       }
+       Functions {
+               delete_function $objtodelete
+               cmd_Functions
+       }
+       Reports {
+               sql_exec noquiet "delete from pga_reports where reportname='$objtodelete'"
+               cmd_Reports
+       }
+       Users {
+               sql_exec noquiet "drop user \"$objtodelete\""
+               cmd_Users
+       }
+}
+}
+
+proc {cmd_Design} {} {
+global PgAcVar CurrentDB
+if {$CurrentDB==""} return;
+if {[.pgaw:Main.lb curselection]==""} return;
+set objname [.pgaw:Main.lb get [.pgaw:Main.lb curselection]]
+set tablename $objname
+switch $PgAcVar(activetab) {
+       Tables  {
+               Tables::design $objname
+       }
+       Schema  {
+               Schema::open $objname
+       }
+       Queries {
+               Queries::design $objname
+       }
+       Views {
+               Views::design $objname
+       }
+       Scripts {
+               Scripts::design $objname
+       }
+       Forms {
+               Forms::design $objname
+       }
+       Functions {
+               Functions::design $objname
+       }
+       Reports {
+               Reports::design $objname
+       }
+       Users {
+               Users::design $objname
+       }
+}
+}
+
+proc {cmd_Forms} {} {
+global CurrentDB
+       setCursor CLOCK
+       .pgaw:Main.lb delete 0 end
+       catch {
+               wpg_select $CurrentDB "select formname from pga_forms order by formname" rec {
+                       .pgaw:Main.lb insert end $rec(formname)
+               }
+       }
+       setCursor DEFAULT
+}
+
+
+proc {cmd_Functions} {} {
+global CurrentDB
+       set maxim 16384
+       setCursor CLOCK
+       catch {
+               wpg_select $CurrentDB "select oid from pg_database where datname='template1'" rec {
+                       set maxim $rec(oid)
+               }
+       }
+       .pgaw:Main.lb delete 0 end
+       catch {
+               wpg_select $CurrentDB "select proname from pg_proc where oid>$maxim order by proname" rec {
+                       .pgaw:Main.lb insert end $rec(proname)
+               }       
+       }
+       setCursor DEFAULT
+}
+
+
+proc {cmd_Import_Export} {how} {
+global PgAcVar CurrentDB
+       if {$CurrentDB==""} return;
+       Window show .pgaw:ImportExport
+       set PgAcVar(impexp,tablename) {}
+       set PgAcVar(impexp,filename) {}
+       set PgAcVar(impexp,delimiter) {}
+       if {$PgAcVar(activetab)=="Tables"} {
+               set tn [get_dwlb_Selection]
+               set PgAcVar(impexp,tablename) $tn
+               if {$tn!=""} {set PgAcVar(impexp,filename) "$tn.txt"}
+       }
+       .pgaw:ImportExport.expbtn configure -text [intlmsg $how]
+}
+
+
+proc {cmd_New} {} {
+global PgAcVar CurrentDB
+if {$CurrentDB==""} return;
+switch $PgAcVar(activetab) {
+       Tables {
+               Tables::new
+       }
+       Schema {
+               Schema::new
+       }
+       Queries {
+               Queries::new
+       }
+       Users {
+               Users::new
+       }
+       Views {
+               Views::new
+       }
+       Sequences {
+               Sequences::new
+       }
+       Reports {
+               Reports::new
+       }
+       Forms {
+               Forms::new
+       }
+       Scripts {
+               Scripts::new
+       }
+       Functions {
+               Functions::new
+       }
+}
+}
+
+
+proc {cmd_Open} {} {
+global PgAcVar CurrentDB
+       if {$CurrentDB==""} return;
+       set objname [get_dwlb_Selection]
+       if {$objname==""} return;
+       switch $PgAcVar(activetab) {
+               Tables          { Tables::open $objname }
+               Schema          { Schema::open $objname }
+               Forms           { Forms::open $objname }
+               Scripts         { Scripts::open $objname }
+               Queries         { Queries::open $objname }
+               Views           { Views::open $objname }
+               Sequences       { Sequences::open $objname }
+               Functions       { Functions::design $objname }
+               Reports         { Reports::open $objname }
+       }
+}
+
+
+
+proc {cmd_Queries} {} {
+global CurrentDB
+       .pgaw:Main.lb delete 0 end
+       catch {
+               wpg_select $CurrentDB "select queryname from pga_queries order by queryname" rec {
+                       .pgaw:Main.lb insert end $rec(queryname)
+               }
+       }
+}
+
+
+proc {cmd_Rename} {} {
+global PgAcVar CurrentDB
+       if {$CurrentDB==""} return;
+       if {$PgAcVar(activetab)=="Views"} return;
+       if {$PgAcVar(activetab)=="Sequences"} return;
+       if {$PgAcVar(activetab)=="Functions"} return;
+       if {$PgAcVar(activetab)=="Users"} return;
+       set temp [get_dwlb_Selection]
+       if {$temp==""} {
+               tk_messageBox -title [intlmsg Warning] -parent .pgaw:Main -message [intlmsg "Please select an object first!"]
+               return;
+       }
+       set PgAcVar(Old_Object_Name) $temp
+       Window show .pgaw:RenameObject
+}
+
+
+proc {cmd_Reports} {} {
+global CurrentDB
+       setCursor CLOCK
+       catch {
+               wpg_select $CurrentDB "select reportname from pga_reports order by reportname" rec {
+               .pgaw:Main.lb insert end "$rec(reportname)"
+               }
+       }
+       setCursor DEFAULT
+}
+
+proc {cmd_Users} {} {
+global CurrentDB
+       setCursor CLOCK
+       .pgaw:Main.lb delete 0 end
+       catch {
+               wpg_select $CurrentDB "select * from pg_user order by usename" rec {
+                       .pgaw:Main.lb insert end $rec(usename)
+               }
+       }
+       setCursor DEFAULT
+}
+
+
+proc {cmd_Scripts} {} {
+global CurrentDB
+       setCursor CLOCK
+       .pgaw:Main.lb delete 0 end
+       catch {
+               wpg_select $CurrentDB "select scriptname from pga_scripts order by scriptname" rec {
+               .pgaw:Main.lb insert end $rec(scriptname)
+               }
+       }
+       setCursor DEFAULT
+}
+
+
+proc {cmd_Sequences} {} {
+global CurrentDB
+
+setCursor CLOCK
+.pgaw:Main.lb delete 0 end
+catch {
+       wpg_select $CurrentDB "select relname from pg_class where (relname not like 'pg_%') and (relkind='S') order by relname" rec {
+               .pgaw:Main.lb insert end $rec(relname)
+       }
+}
+setCursor DEFAULT
+}
+
+proc {cmd_Tables} {} {
+global CurrentDB
+       setCursor CLOCK
+       .pgaw:Main.lb delete 0 end
+       foreach tbl [Database::getTablesList] {.pgaw:Main.lb insert end $tbl}
+       setCursor DEFAULT
+}
+
+proc {cmd_Schema} {} {
+global CurrentDB
+.pgaw:Main.lb delete 0 end
+catch {
+       wpg_select $CurrentDB "select schemaname from pga_schema order by schemaname" rec {
+               .pgaw:Main.lb insert end $rec(schemaname)
+       }
+}
+}
+
+proc {cmd_Views} {} {
+global CurrentDB
+setCursor CLOCK
+.pgaw:Main.lb delete 0 end
+catch {
+       wpg_select $CurrentDB "select c.relname,count(c.relname) from pg_class C, pg_rewrite R where (relname !~ '^pg_') and (r.ev_class = C.oid) and (r.ev_type = '1') group by relname" rec {
+               if {$rec(count)!=0} {
+                       set itsaview($rec(relname)) 1
+               }
+       }
+       wpg_select $CurrentDB "select relname from pg_class where (relname !~ '^pg_') and (relkind='r') and (relhasrules) order by relname" rec {
+               if {[info exists itsaview($rec(relname))]} {
+                       .pgaw:Main.lb insert end $rec(relname)
+               }
+       }
+}
+setCursor DEFAULT
+}
+
+proc {delete_function} {objname} {
+global CurrentDB
+       wpg_select $CurrentDB "select proargtypes,pronargs from pg_proc where proname='$objname'" rec {
+               set PgAcVar(function,parameters) $rec(proargtypes)
+               set nrpar $rec(pronargs)
+       }
+       set lispar {}
+       for {set i 0} {$i<$nrpar} {incr i} {
+               lappend lispar [Database::getPgType [lindex $PgAcVar(function,parameters) $i]]
+       }
+       set lispar [join $lispar ,]
+       sql_exec noquiet "drop function $objname ($lispar)"
+}
+
+
+proc {draw_tabs} {} {
+global PgAcVar
+       set ypos 85
+       foreach tab $PgAcVar(tablist) {
+               label .pgaw:Main.tab$tab -borderwidth 1  -anchor w -relief raised -text [intlmsg $tab]
+               place .pgaw:Main.tab$tab -x 10 -y $ypos -height 25 -width 82 -anchor nw -bordermode ignore
+               lower .pgaw:Main.tab$tab
+               bind .pgaw:Main.tab$tab <Button-1> "Mainlib::tab_click $tab"
+               incr ypos 25
+       }
+       set PgAcVar(activetab) ""
+}
+
+
+proc {get_dwlb_Selection} {} {
+       set temp [.pgaw:Main.lb curselection]
+       if {$temp==""} return "";
+       return [.pgaw:Main.lb get $temp]
+}
+
+
+
+
+proc {sqlw_display} {msg} {
+       if {![winfo exists .pgaw:SQLWindow]} {return}
+       .pgaw:SQLWindow.f.t insert end "$msg\n\n"
+       .pgaw:SQLWindow.f.t see end
+       set nrlines [lindex [split [.pgaw:SQLWindow.f.t index end] .] 0]
+       if {$nrlines>50} {
+               .pgaw:SQLWindow.f.t delete 1.0 3.0
+       }
+}
+
+
+proc {open_database} {} {
+global PgAcVar CurrentDB
+setCursor CLOCK
+if {$PgAcVar(opendb,username)!=""} {
+       if {$PgAcVar(opendb,host)!=""} {
+               set connres [catch {set newdbc [pg_connect -conninfo "host=$PgAcVar(opendb,host) port=$PgAcVar(opendb,pgport) dbname=$PgAcVar(opendb,dbname) user=$PgAcVar(opendb,username) password=$PgAcVar(opendb,password)"]} msg]
+       } else {
+               set connres [catch {set newdbc [pg_connect -conninfo "dbname=$PgAcVar(opendb,dbname) user=$PgAcVar(opendb,username) password=$PgAcVar(opendb,password)"]} msg]
+       }
+} else {
+       set connres [catch {set newdbc [pg_connect $PgAcVar(opendb,dbname) -host $PgAcVar(opendb,host) -port $PgAcVar(opendb,pgport)]} msg]
+}
+if {$connres} {
+       setCursor DEFAULT
+       showError [format [intlmsg "Error trying to connect to database '%s' on host %s \n\nPostgreSQL error message:%s"] $PgAcVar(opendb,dbname) $PgAcVar(opendb,host) $msg"]
+       return $msg
+} else {
+       catch {pg_disconnect $CurrentDB}
+       set CurrentDB $newdbc
+       set PgAcVar(currentdb,host) $PgAcVar(opendb,host)
+       set PgAcVar(currentdb,pgport) $PgAcVar(opendb,pgport)
+       set PgAcVar(currentdb,dbname) $PgAcVar(opendb,dbname)
+       set PgAcVar(currentdb,username) $PgAcVar(opendb,username)
+       set PgAcVar(currentdb,password) $PgAcVar(opendb,password)
+       set PgAcVar(statusline,dbname) $PgAcVar(currentdb,dbname)
+       set PgAcVar(pref,lastdb) $PgAcVar(currentdb,dbname)
+       set PgAcVar(pref,lasthost) $PgAcVar(currentdb,host)
+       set PgAcVar(pref,lastport) $PgAcVar(currentdb,pgport)
+       set PgAcVar(pref,lastusername) $PgAcVar(currentdb,username)
+       Preferences::save
+       catch {setCursor DEFAULT ; Window hide .pgaw:OpenDB}
+       tab_click Tables
+       # Check for pga_ tables
+       foreach {table structure} {pga_queries {queryname varchar(64),querytype char(1),querycommand text,querytables text,querylinks text,queryresults text,querycomments text} pga_forms {formname varchar(64),formsource text} pga_scripts {scriptname varchar(64),scriptsource text} pga_reports {reportname varchar(64),reportsource text,reportbody text,reportprocs text,reportoptions text} pga_schema {schemaname varchar(64),schematables text,schemalinks text}} {
+               set pgres [wpg_exec $CurrentDB "select relname from pg_class where relname='$table'"]
+               if {$PgAcVar(pgsql,status)!="PGRES_TUPLES_OK"} {
+                       showError "[intlmsg {FATAL ERROR searching for PgAccess system tables}] : $PgAcVar(pgsql,errmsg)\nStatus:$PgAcVar(pgsql,status)"
+                       catch {pg_disconnect $CurrentDB}
+                       exit
+               } elseif {[pg_result $pgres -numTuples]==0} {
+                       pg_result $pgres -clear
+                       sql_exec quiet "create table $table ($structure)"
+                       sql_exec quiet "grant ALL on $table to PUBLIC"
+               } else {
+                       foreach fieldspec [split $structure ,] {
+                               set field [lindex [split $fieldspec] 0]
+                               set pgres [wpg_exec $CurrentDB "select \"$field\" from \"$table\""]
+                               if {$PgAcVar(pgsql,status)!="PGRES_TUPLES_OK"} {
+                                       if {![regexp "attribute '$field' not found" $PgAcVar(pgsql,errmsg)]} {
+                                               showError "[intlmsg {FATAL ERROR upgrading PgAccess table}] $table: $PgAcVar(pgsql,errmsg)\nStatus:$PgAcVar(pgsql,status)"
+                                               catch {pg_disconnect $CurrentDB}
+                                               exit
+                                       } else {
+                                               pg_result $pgres -clear
+                                               sql_exec quiet "alter table \"$table\" add column $fieldspec "
+                                       }
+                               }
+                       }
+               }
+               catch {pg_result $pgres -clear}
+       }
+       
+       # searching for autoexec script
+       wpg_select $CurrentDB "select * from pga_scripts where scriptname ~* '^autoexec$'" recd {
+               eval $recd(scriptsource)
+       }
+       return ""
+}
+}
+
+
+proc {tab_click} {tabname} {
+global PgAcVar CurrentDB
+       set w .pgaw:Main.tab$tabname
+       if {$CurrentDB==""} return;
+       set curtab $tabname
+       #if {$PgAcVar(activetab)==$curtab} return;
+       .pgaw:Main.btndesign configure -state disabled
+       if {$PgAcVar(activetab)!=""} {
+               place .pgaw:Main.tab$PgAcVar(activetab) -x 10
+               .pgaw:Main.tab$PgAcVar(activetab) configure -font $PgAcVar(pref,font_normal)
+       }
+       $w configure -font $PgAcVar(pref,font_bold)
+       place $w -x 7
+       place .pgaw:Main.lmask -x 80 -y [expr 86+25*[lsearch -exact $PgAcVar(tablist) $curtab]]
+       set PgAcVar(activetab) $curtab
+       # Tabs where button Design is enabled
+       if {[lsearch {Tables Schema Scripts Queries Functions Views Reports Forms Users} $PgAcVar(activetab)]!=-1} {
+               .pgaw:Main.btndesign configure -state normal
+       }
+       .pgaw:Main.lb delete 0 end
+       cmd_$curtab
+}
+
+
+
+}
+
+
+proc vTclWindow.pgaw:Main {base} {
+global PgAcVar
+       if {$base == ""} {
+               set base .pgaw:Main
+       }
+       if {[winfo exists $base]} {
+               wm deiconify $base; return
+       }
+       toplevel $base -class Toplevel \
+               -background #efefef -cursor left_ptr
+       wm focusmodel $base passive
+       wm geometry $base 332x390+96+172
+       wm maxsize $base 1009 738
+       wm minsize $base 1 1
+       wm overrideredirect $base 0
+       wm resizable $base 0 0
+       wm deiconify $base
+       wm title $base "PostgreSQL access"
+       bind $base <Key-F1> "Help::load index"
+       label $base.labframe \
+               -relief raised 
+       listbox $base.lb \
+               -background #fefefe \
+               -selectbackground #c3c3c3 \
+               -foreground black -highlightthickness 0 -selectborderwidth 0 \
+               -yscrollcommand {.pgaw:Main.sb set} 
+       bind $base.lb <Double-Button-1> {
+               Mainlib::cmd_Open
+       }
+       button $base.btnnew \
+               -borderwidth 1 -command Mainlib::cmd_New -text [intlmsg New]
+       button $base.btnopen \
+               -borderwidth 1 -command Mainlib::cmd_Open -text [intlmsg Open]
+       button $base.btndesign \
+               -borderwidth 1 -command Mainlib::cmd_Design -text [intlmsg Design]
+       label $base.lmask \
+               -borderwidth 0 \
+               -text {  } 
+       frame $base.fm \
+        -borderwidth 1 -height 75 -relief raised -width 125 
+       menubutton $base.fm.mndb \
+               -borderwidth 1 -font $PgAcVar(pref,font_normal) \
+               -menu .pgaw:Main.fm.mndb.01 -padx 4 -pady 3 -text [intlmsg Database]
+       menu $base.fm.mndb.01 \
+               -borderwidth 1 -font $PgAcVar(pref,font_normal) \
+               -tearoff 0 
+       $base.fm.mndb.01 add command \
+               -command {
+Window show .pgaw:OpenDB
+set PgAcVar(opendb,host) $PgAcVar(currentdb,host)
+set PgAcVar(opendb,pgport) $PgAcVar(currentdb,pgport)
+focus .pgaw:OpenDB.f1.e3
+wm transient .pgaw:OpenDB .pgaw:Main
+.pgaw:OpenDB.f1.e3 selection range 0 end} \
+               -label [intlmsg Open] -font $PgAcVar(pref,font_normal)
+       $base.fm.mndb.01 add command \
+               -command {.pgaw:Main.lb delete 0 end
+set CurrentDB {}
+set PgAcVar(currentdb,dbname) {}
+set PgAcVar(statusline,dbname) {}} \
+               -label [intlmsg Close]
+       $base.fm.mndb.01 add command \
+               -command Database::vacuum -label [intlmsg Vacuum]
+       $base.fm.mndb.01 add separator
+       $base.fm.mndb.01 add command \
+               -command {Mainlib::cmd_Import_Export Import} -label [intlmsg {Import table}]
+       $base.fm.mndb.01 add command \
+               -command {Mainlib::cmd_Import_Export Export} -label [intlmsg {Export table}]
+       $base.fm.mndb.01 add separator
+       $base.fm.mndb.01 add command \
+               -command Preferences::configure -label [intlmsg Preferences]
+       $base.fm.mndb.01 add command \
+               -command "Window show .pgaw:SQLWindow" -label [intlmsg "SQL window"]
+       $base.fm.mndb.01 add separator
+       $base.fm.mndb.01 add command \
+               -command {
+set PgAcVar(activetab) {}
+Preferences::save
+catch {pg_disconnect $CurrentDB}
+exit} -label [intlmsg Exit]
+       label $base.lshost \
+               -relief groove -text localhost -textvariable PgAcVar(currentdb,host) 
+       label $base.lsdbname \
+               -anchor w \
+               -relief groove -textvariable PgAcVar(statusline,dbname) 
+       scrollbar $base.sb \
+               -borderwidth 1 -command {.pgaw:Main.lb yview} -orient vert 
+       menubutton $base.fm.mnob \
+               -borderwidth 1 \
+               -menu .pgaw:Main.fm.mnob.m -font $PgAcVar(pref,font_normal) -text [intlmsg Object]
+       menu $base.fm.mnob.m \
+               -borderwidth 1 -font $PgAcVar(pref,font_normal) \
+               -tearoff 0 
+       $base.fm.mnob.m add command \
+               -command Mainlib::cmd_New -font $PgAcVar(pref,font_normal) -label [intlmsg New] 
+       $base.fm.mnob.m add command \
+               -command Mainlib::cmd_Delete -label [intlmsg Delete] 
+       $base.fm.mnob.m add command \
+               -command Mainlib::cmd_Rename -label [intlmsg Rename] 
+       menubutton $base.fm.mnhelp \
+               -borderwidth 1 \
+               -menu .pgaw:Main.fm.mnhelp.m -font $PgAcVar(pref,font_normal) -text [intlmsg Help]
+       menu $base.fm.mnhelp.m \
+               -borderwidth 1 -font $PgAcVar(pref,font_normal) \
+               -tearoff 0 
+       $base.fm.mnhelp.m add command \
+               -label [intlmsg Contents] -command {Help::load index}
+       $base.fm.mnhelp.m add command \
+               -label PostgreSQL  -command {Help::load postgresql}
+       $base.fm.mnhelp.m add separator
+       $base.fm.mnhelp.m add command \
+               -command {Window show .pgaw:About} -label [intlmsg About]
+       place $base.labframe \
+               -x 80 -y 30 -width 246 -height 325 -anchor nw -bordermode ignore 
+       place $base.lb \
+               -x 90 -y 75 -width 210 -height 272 -anchor nw -bordermode ignore 
+       place $base.btnnew \
+               -x 89 -y 40 -width 75 -height 25 -anchor nw -bordermode ignore 
+       place $base.btnopen \
+               -x 166 -y 40 -width 75 -height 25 -anchor nw -bordermode ignore 
+       place $base.btndesign \
+               -x 243 -y 40 -width 76 -height 25 -anchor nw -bordermode ignore 
+       place $base.lmask \
+               -x 1550 -y 4500 -width 10 -height 23 -anchor nw -bordermode ignore 
+       place $base.lshost \
+               -x 3 -y 370 -width 91 -height 20 -anchor nw -bordermode ignore 
+       place $base.lsdbname \
+               -x 95 -y 370 -width 233 -height 20 -anchor nw -bordermode ignore 
+       place $base.sb \
+               -x 301 -y 74 -width 18 -height 274 -anchor nw -bordermode ignore 
+       place $base.fm \
+        -x 1 -y 0 -width 331 -height 25 -anchor nw -bordermode ignore 
+       pack $base.fm.mndb \
+        -in .pgaw:Main.fm -anchor center -expand 0 -fill none -side left 
+       pack $base.fm.mnob \
+        -in .pgaw:Main.fm -anchor center -expand 0 -fill none -side left 
+       pack $base.fm.mnhelp \
+        -in .pgaw:Main.fm -anchor center -expand 0 -fill none -side right 
+}
+
+proc vTclWindow.pgaw:ImportExport {base} {
+       if {$base == ""} {
+               set base .pgaw:ImportExport
+       }
+       if {[winfo exists $base]} {
+               wm deiconify $base; return
+       }
+       toplevel $base -class Toplevel
+       wm focusmodel $base passive
+       wm geometry $base 287x151+259+304
+       wm maxsize $base 1009 738
+       wm minsize $base 1 1
+       wm overrideredirect $base 0
+       wm resizable $base 0 0
+       wm title $base [intlmsg "Import-Export table"]
+       label $base.l1  -borderwidth 0 -text [intlmsg {Table name}]
+       entry $base.e1  -background #fefefe -borderwidth 1 -textvariable PgAcVar(impexp,tablename) 
+       label $base.l2  -borderwidth 0 -text [intlmsg {File name}]
+       entry $base.e2  -background #fefefe -borderwidth 1 -textvariable PgAcVar(impexp,filename) 
+       label $base.l3  -borderwidth 0 -text [intlmsg {Field delimiter}]
+       entry $base.e3  -background #fefefe -borderwidth 1 -textvariable PgAcVar(impexp,delimiter) 
+       button $base.expbtn  -borderwidth 1  -command {if {$PgAcVar(impexp,tablename)==""} {
+       showError [intlmsg "You have to supply a table name!"]
+} elseif {$PgAcVar(impexp,filename)==""} {
+       showError [intlmsg "You have to supply a external file name!"]
+} else {
+       if {$PgAcVar(impexp,delimiter)==""} {
+               set sup ""
+       } else {
+               set sup " USING DELIMITERS '$PgAcVar(impexp,delimiter)'"
+       }
+       if {[.pgaw:ImportExport.expbtn cget -text]=="Import"} {
+               set oper "FROM"
+       } else {
+               set oper "TO"
+       }
+               if {$PgAcVar(impexp,withoids)} {
+                               set sup2 " WITH OIDS "
+               } else {
+                               set sup2 ""
+               }
+       set sqlcmd "COPY \"$PgAcVar(impexp,tablename)\" $sup2 $oper '$PgAcVar(impexp,filename)'$sup"
+       setCursor CLOCK
+       if {[sql_exec noquiet $sqlcmd]} {
+               tk_messageBox -title [intlmsg Information] -parent .pgaw:ImportExport -message [intlmsg "Operation completed!"]
+               Window destroy .pgaw:ImportExport
+       }
+       setCursor DEFAULT
+}}  -text Export 
+       button $base.cancelbtn  -borderwidth 1 -command {Window destroy .pgaw:ImportExport} -text [intlmsg Cancel]
+       checkbutton $base.oicb  -borderwidth 1  -text [intlmsg {with OIDs}] -variable PgAcVar(impexp,withoids) 
+       place $base.l1  -x 15 -y 15 -anchor nw -bordermode ignore 
+       place $base.e1  -x 115 -y 10 -height 22 -anchor nw -bordermode ignore 
+       place $base.l2  -x 15 -y 45 -anchor nw -bordermode ignore 
+       place $base.e2  -x 115 -y 40 -height 22 -anchor nw -bordermode ignore 
+       place $base.l3  -x 15 -y 75 -height 18 -anchor nw -bordermode ignore 
+       place $base.e3  -x 115 -y 74 -width 33 -height 22 -anchor nw -bordermode ignore 
+       place $base.expbtn  -x 60 -y 110 -height 25 -width 75 -anchor nw -bordermode ignore 
+       place $base.cancelbtn  -x 155 -y 110 -height 25 -width 75 -anchor nw -bordermode ignore 
+       place $base.oicb  -x 170 -y 75 -anchor nw -bordermode ignore
+}
+
+
+
+proc vTclWindow.pgaw:RenameObject {base} {
+       if {$base == ""} {
+               set base .pgaw:RenameObject
+       }
+       if {[winfo exists $base]} {
+               wm deiconify $base; return
+       }
+       toplevel $base -class Toplevel
+       wm focusmodel $base passive
+       wm geometry $base 272x105+294+262
+       wm maxsize $base 1009 738
+       wm minsize $base 1 1
+       wm overrideredirect $base 0
+       wm resizable $base 0 0
+       wm title $base [intlmsg "Rename"]
+       label $base.l1  -borderwidth 0 -text [intlmsg {New name}]
+       entry $base.e1  -background #fefefe -borderwidth 1 -textvariable PgAcVar(New_Object_Name) 
+       button $base.b1  -borderwidth 1  -command {
+                       if {$PgAcVar(New_Object_Name)==""} {
+                               showError [intlmsg "You must give object a new name!"]
+                       } elseif {$PgAcVar(activetab)=="Tables"} {
+                               set retval [sql_exec noquiet "alter table \"$PgAcVar(Old_Object_Name)\" rename to \"$PgAcVar(New_Object_Name)\""]
+                               if {$retval} {
+                                       sql_exec quiet "update pga_layout set tablename='$PgAcVar(New_Object_Name)' where tablename='$PgAcVar(Old_Object_Name)'"
+                                       Mainlib::cmd_Tables
+                                       Window destroy .pgaw:RenameObject
+                               }
+                       } elseif {$PgAcVar(activetab)=="Queries"} {
+                               set pgres [wpg_exec $CurrentDB "select * from pga_queries where queryname='$PgAcVar(New_Object_Name)'"]
+                               if {$PgAcVar(pgsql,status)!="PGRES_TUPLES_OK"} {
+                                       showError "[intlmsg {Error retrieving from}] pga_queries\n$PgAcVar(pgsql,errmsg)\n$PgAcVar(pgsql,status)"
+                               } elseif {[pg_result $pgres -numTuples]>0} {
+                                       showError [format [intlmsg "Query '%s' already exists!"] $PgAcVar(New_Object_Name)]
+                               } else {
+                                       sql_exec noquiet "update pga_queries set queryname='$PgAcVar(New_Object_Name)' where queryname='$PgAcVar(Old_Object_Name)'"
+                                       sql_exec noquiet "update pga_layout set tablename='$PgAcVar(New_Object_Name)' where tablename='$PgAcVar(Old_Object_Name)'"
+                                       Mainlib::cmd_Queries
+                                       Window destroy .pgaw:RenameObject
+                               }
+                               catch {pg_result $pgres -clear}
+                       } elseif {$PgAcVar(activetab)=="Forms"} {
+                               set pgres [wpg_exec $CurrentDB "select * from pga_forms where formname='$PgAcVar(New_Object_Name)'"]
+                               if {$PgAcVar(pgsql,status)!="PGRES_TUPLES_OK"} {
+                                       showError "[intlmsg {Error retrieving from}] pga_forms\n$PgAcVar(pgsql,errmsg)\n$PgAcVar(pgsql,status)"
+                               } elseif {[pg_result $pgres -numTuples]>0} {
+                                       showError [format [intlmsg "Form '%s' already exists!"] $PgAcVar(New_Object_Name)]
+                               } else {
+                                       sql_exec noquiet "update pga_forms set formname='$PgAcVar(New_Object_Name)' where formname='$PgAcVar(Old_Object_Name)'"
+                                       Mainlib::cmd_Forms
+                                       Window destroy .pgaw:RenameObject
+                               }
+                               catch {pg_result $pgres -clear}
+                       } elseif {$PgAcVar(activetab)=="Scripts"} {
+                               set pgres [wpg_exec $CurrentDB "select * from pga_scripts where scriptname='$PgAcVar(New_Object_Name)'"]
+                               if {$PgAcVar(pgsql,status)!="PGRES_TUPLES_OK"} {
+                                       showError "[intlmsg {Error retrieving from}] pga_scripts\n$PgAcVar(pgsql,errmsg)\n$PgAcVar(pgsql,status)"
+                               } elseif {[pg_result $pgres -numTuples]>0} {
+                                       showError [format [intlmsg "Script '%s' already exists!"] $PgAcVar(New_Object_Name)]
+                               } else {
+                                       sql_exec noquiet "update pga_scripts set scriptname='$PgAcVar(New_Object_Name)' where scriptname='$PgAcVar(Old_Object_Name)'"
+                                       Mainlib::cmd_Scripts
+                                       Window destroy .pgaw:RenameObject
+                               }
+                               catch {pg_result $pgres -clear}
+                       } elseif {$PgAcVar(activetab)=="Schema"} {
+                               set pgres [wpg_exec $CurrentDB "select * from pga_schema where schemaname='$PgAcVar(New_Object_Name)'"]
+                               if {$PgAcVar(pgsql,status)!="PGRES_TUPLES_OK"} {
+                                       showError "[intlmsg {Error retrieving from}] pga_schema\n$PgAcVar(pgsql,errmsg)\n$PgAcVar(pgsql,status)"
+                               } elseif {[pg_result $pgres -numTuples]>0} {
+                                       showError [format [intlmsg "Schema '%s' already exists!"] $PgAcVar(New_Object_Name)]
+                               } else {
+                                       sql_exec noquiet "update pga_schema set schemaname='$PgAcVar(New_Object_Name)' where schemaname='$PgAcVar(Old_Object_Name)'"
+                                       Mainlib::cmd_Schema
+                                       Window destroy .pgaw:RenameObject
+                               }
+                               catch {pg_result $pgres -clear}
+                       }
+          } -text [intlmsg Rename]
+       button $base.b2  -borderwidth 1 -command {Window destroy .pgaw:RenameObject} -text [intlmsg Cancel]
+       place $base.l1  -x 15 -y 28 -anchor nw -bordermode ignore 
+       place $base.e1  -x 100 -y 25 -anchor nw -bordermode ignore 
+       place $base.b1  -x 55 -y 65 -width 80 -anchor nw -bordermode ignore 
+       place $base.b2  -x 155 -y 65 -width 80 -anchor nw -bordermode ignore
+}
+
+
+proc vTclWindow.pgaw:GetParameter {base} {
+       if {$base == ""} {
+               set base .pgaw:GetParameter
+       }
+       if {[winfo exists $base]} {
+               wm deiconify $base; return
+       }
+       toplevel $base -class Toplevel
+       wm focusmodel $base passive
+       set sw [winfo screenwidth .]
+       set sh [winfo screenheight .]
+       set x [expr ($sw - 297)/2]
+       set y [expr ($sh - 98)/2]
+       wm geometry $base 297x98+$x+$y
+       wm maxsize $base 1009 738
+       wm minsize $base 1 1
+       wm overrideredirect $base 0
+       wm resizable $base 0 0
+       wm deiconify $base
+       wm title $base [intlmsg "Input parameter"]
+       label $base.l1 \
+               -anchor nw -borderwidth 1 \
+               -justify left -relief sunken -textvariable PgAcVar(getqueryparam,msg) -wraplength 200 
+       entry $base.e1 \
+               -background #fefefe -borderwidth 1 -highlightthickness 0 \
+               -textvariable PgAcVar(getqueryparam,var) 
+       bind $base.e1 <Key-KP_Enter> {
+               set PgAcVar(getqueryparam,result) 1
+destroy .pgaw:GetParameter
+       }
+       bind $base.e1 <Key-Return> {
+               set PgAcVar(getqueryparam,result) 1
+destroy .pgaw:GetParameter
+       }
+       button $base.bok \
+               -borderwidth 1 -command {set PgAcVar(getqueryparam,result) 1
+destroy .pgaw:GetParameter} -text Ok 
+       button $base.bcanc \
+               -borderwidth 1 -command {set PgAcVar(getqueryparam,result) 0
+destroy .pgaw:GetParameter} -text [intlmsg Cancel]
+       place $base.l1 \
+               -x 10 -y 5 -width 201 -height 53 -anchor nw -bordermode ignore 
+       place $base.e1 \
+               -x 10 -y 65 -width 200 -height 24 -anchor nw -bordermode ignore 
+       place $base.bok \
+               -x 225 -y 5 -width 61 -height 26 -anchor nw -bordermode ignore 
+       place $base.bcanc \
+               -x 225 -y 35 -width 61 -height 26 -anchor nw -bordermode ignore 
+}
+
+
+proc vTclWindow.pgaw:SQLWindow {base} {
+       if {$base == ""} {
+               set base .pgaw:SQLWindow
+       }
+       if {[winfo exists $base]} {
+               wm deiconify $base; return
+       }
+       toplevel $base -class Toplevel
+       wm focusmodel $base passive
+       wm geometry $base 551x408+192+169
+       wm maxsize $base 1009 738
+       wm minsize $base 1 1
+       wm overrideredirect $base 0
+       wm resizable $base 1 1
+       wm deiconify $base
+       wm title $base [intlmsg "SQL window"]
+       frame $base.f \
+               -borderwidth 1 -height 392 -relief raised -width 396 
+       scrollbar $base.f.01 \
+               -borderwidth 1 -command {.pgaw:SQLWindow.f.t xview} -orient horiz \
+               -width 10 
+       scrollbar $base.f.02 \
+               -borderwidth 1 -command {.pgaw:SQLWindow.f.t yview} -orient vert -width 10 
+       text $base.f.t \
+               -borderwidth 1 \
+               -height 200 -width 200 -wrap word \
+               -xscrollcommand {.pgaw:SQLWindow.f.01 set} \
+               -yscrollcommand {.pgaw:SQLWindow.f.02 set} 
+       button $base.b1 \
+               -borderwidth 1 -command {.pgaw:SQLWindow.f.t delete 1.0 end} -text [intlmsg Clean]
+       button $base.b2 \
+               -borderwidth 1 -command {destroy .pgaw:SQLWindow} -text [intlmsg Close] 
+       grid columnconf $base 0 -weight 1
+       grid columnconf $base 1 -weight 1
+       grid rowconf $base 0 -weight 1
+       grid $base.f \
+               -in .pgaw:SQLWindow -column 0 -row 0 -columnspan 2 -rowspan 1 
+       grid columnconf $base.f 0 -weight 1
+       grid rowconf $base.f 0 -weight 1
+       grid $base.f.01 \
+               -in .pgaw:SQLWindow.f -column 0 -row 1 -columnspan 1 -rowspan 1 -sticky ew 
+       grid $base.f.02 \
+               -in .pgaw:SQLWindow.f -column 1 -row 0 -columnspan 1 -rowspan 1 -sticky ns 
+       grid $base.f.t \
+               -in .pgaw:SQLWindow.f -column 0 -row 0 -columnspan 1 -rowspan 1 \
+               -sticky nesw 
+       grid $base.b1 \
+               -in .pgaw:SQLWindow -column 0 -row 1 -columnspan 1 -rowspan 1 
+       grid $base.b2 \
+               -in .pgaw:SQLWindow -column 1 -row 1 -columnspan 1 -rowspan 1 
+}
+
+proc vTclWindow.pgaw:About {base} {
+       if {$base == ""} {
+               set base .pgaw:About
+       }
+       if {[winfo exists $base]} {
+               wm deiconify $base; return
+       }
+       toplevel $base -class Toplevel
+       wm focusmodel $base passive
+       wm geometry $base 471x177+168+243
+       wm maxsize $base 1009 738
+       wm minsize $base 1 1
+       wm overrideredirect $base 0
+       wm resizable $base 1 1
+       wm title $base [intlmsg "About"]
+       label $base.l1  -borderwidth 3 -font -Adobe-Helvetica-Bold-R-Normal-*-*-180-*-*-*-*-*  -relief ridge -text PgAccess 
+       label $base.l2  -relief groove  -text [intlmsg "A Tcl/Tk interface to\nPostgreSQL\nby Constantin Teodorescu"]
+       label $base.l3  -borderwidth 0 -relief sunken -text {v 0.98}
+       label $base.l4  -relief groove  -text "[intlmsg {You will always get the latest version at:}]
+http://www.flex.ro/pgaccess
+
+[intlmsg {Suggestions at}] : teo@flex.ro"
+       button $base.b1  -borderwidth 1 -command {Window destroy .pgaw:About} -text Ok 
+       place $base.l1  -x 10 -y 10 -width 196 -height 103 -anchor nw -bordermode ignore 
+       place $base.l2  -x 10 -y 115 -width 198 -height 55 -anchor nw -bordermode ignore 
+       place $base.l3  -x 145 -y 80 -anchor nw -bordermode ignore 
+       place $base.l4  -x 215 -y 10 -width 246 -height 103 -anchor nw -bordermode ignore 
+       place $base.b1  -x 295 -y 130 -width 105 -height 28 -anchor nw -bordermode ignore
+}
+
+proc vTclWindow.pgaw:OpenDB {base} {
+       if {$base == ""} {
+               set base .pgaw:OpenDB
+       }
+       if {[winfo exists $base]} {
+               wm deiconify $base; return
+       }
+       toplevel $base -class Toplevel
+       wm focusmodel $base passive
+       wm geometry $base 283x172+119+210
+       wm maxsize $base 1009 738
+       wm minsize $base 1 1
+       wm overrideredirect $base 0
+       wm resizable $base 0 0
+       wm deiconify $base
+       wm title $base [intlmsg "Open database"]
+       frame $base.f1 \
+               -borderwidth 2 -height 75 -width 125 
+       label $base.f1.l1 \
+               -borderwidth 0 -relief raised -text [intlmsg Host]
+       entry $base.f1.e1 \
+               -background #fefefe -borderwidth 1 -textvariable PgAcVar(opendb,host) -width 200 
+       bind $base.f1.e1 <Key-KP_Enter> {
+               focus .pgaw:OpenDB.f1.e2
+       }
+       bind $base.f1.e1 <Key-Return> {
+               focus .pgaw:OpenDB.f1.e2
+       }
+       label $base.f1.l2 \
+               -borderwidth 0 -relief raised -text [intlmsg Port]
+       entry $base.f1.e2 \
+               -background #fefefe -borderwidth 1 -textvariable PgAcVar(opendb,pgport) -width 200 
+       bind $base.f1.e2 <Key-Return> {
+               focus .pgaw:OpenDB.f1.e3
+       }
+       label $base.f1.l3 \
+               -borderwidth 0 -relief raised -text [intlmsg Database]
+       entry $base.f1.e3 \
+               -background #fefefe -borderwidth 1 -textvariable PgAcVar(opendb,dbname) -width 200 
+       bind $base.f1.e3 <Key-Return> {
+               focus .pgaw:OpenDB.f1.e4
+       }
+       label $base.f1.l4 \
+               -borderwidth 0 -relief raised -text [intlmsg Username]
+       entry $base.f1.e4 \
+               -background #fefefe -borderwidth 1 -textvariable PgAcVar(opendb,username) \
+               -width 200 
+       bind $base.f1.e4 <Key-Return> {
+               focus .pgaw:OpenDB.f1.e5
+       }
+       label $base.f1.ls2 \
+               -borderwidth 0 -relief raised -text { } 
+       label $base.f1.l5 \
+               -borderwidth 0 -relief raised -text [intlmsg Password]
+       entry $base.f1.e5 \
+               -background #fefefe -borderwidth 1 -show x -textvariable PgAcVar(opendb,password) \
+               -width 200 
+       bind $base.f1.e5 <Key-Return> {
+               focus .pgaw:OpenDB.fb.btnopen
+       }
+       frame $base.fb \
+               -height 75 -relief groove -width 125 
+       button $base.fb.btnopen \
+               -borderwidth 1 -command Mainlib::open_database -padx 9 \
+               -pady 3 -text [intlmsg Open]
+       button $base.fb.btncancel \
+               -borderwidth 1 -command {Window hide .pgaw:OpenDB} \
+               -padx 9 -pady 3 -text [intlmsg Cancel]
+       place $base.f1 \
+               -x 9 -y 5 -width 265 -height 126 -anchor nw -bordermode ignore 
+       grid columnconf $base.f1 2 -weight 1
+       grid $base.f1.l1 \
+               -in .pgaw:OpenDB.f1 -column 0 -row 0 -columnspan 1 -rowspan 1 -sticky w 
+       grid $base.f1.e1 \
+               -in .pgaw:OpenDB.f1 -column 2 -row 0 -columnspan 1 -rowspan 1 -pady 2 
+       grid $base.f1.l2 \
+               -in .pgaw:OpenDB.f1 -column 0 -row 2 -columnspan 1 -rowspan 1 -sticky w 
+       grid $base.f1.e2 \
+               -in .pgaw:OpenDB.f1 -column 2 -row 2 -columnspan 1 -rowspan 1 -pady 2 
+       grid $base.f1.l3 \
+               -in .pgaw:OpenDB.f1 -column 0 -row 4 -columnspan 1 -rowspan 1 -sticky w 
+       grid $base.f1.e3 \
+               -in .pgaw:OpenDB.f1 -column 2 -row 4 -columnspan 1 -rowspan 1 -pady 2 
+       grid $base.f1.l4 \
+               -in .pgaw:OpenDB.f1 -column 0 -row 6 -columnspan 1 -rowspan 1 -sticky w 
+       grid $base.f1.e4 \
+               -in .pgaw:OpenDB.f1 -column 2 -row 6 -columnspan 1 -rowspan 1 -pady 2 
+       grid $base.f1.ls2 \
+               -in .pgaw:OpenDB.f1 -column 1 -row 0 -columnspan 1 -rowspan 1 
+       grid $base.f1.l5 \
+               -in .pgaw:OpenDB.f1 -column 0 -row 7 -columnspan 1 -rowspan 1 -sticky w 
+       grid $base.f1.e5 \
+               -in .pgaw:OpenDB.f1 -column 2 -row 7 -columnspan 1 -rowspan 1 -pady 2 
+       place $base.fb \
+               -x 0 -y 135 -width 283 -height 40 -anchor nw -bordermode ignore 
+       grid $base.fb.btnopen \
+               -in .pgaw:OpenDB.fb -column 0 -row 0 -columnspan 1 -rowspan 1 -padx 5 
+       grid $base.fb.btncancel \
+               -in .pgaw:OpenDB.fb -column 1 -row 0 -columnspan 1 -rowspan 1 -padx 5 
+}
+
+
diff --git a/src/bin/pgaccess/lib/preferences.tcl b/src/bin/pgaccess/lib/preferences.tcl
new file mode 100644 (file)
index 0000000..c752e03
--- /dev/null
@@ -0,0 +1,273 @@
+namespace eval Preferences {
+
+proc {load} {} {
+global PgAcVar
+       setDefaultFonts
+       setGUIPreferences
+       # Set some default values for preferences
+       set PgAcVar(pref,rows) 200
+       set PgAcVar(pref,tvfont) clean
+       set PgAcVar(pref,autoload) 1
+       set PgAcVar(pref,systemtables) 0
+       set PgAcVar(pref,lastdb) {}
+       set PgAcVar(pref,lasthost) localhost
+       set PgAcVar(pref,lastport) 5432
+       set PgAcVar(pref,username) {}
+       set PgAcVar(pref,password) {}
+       set PgAcVar(pref,language) english
+       set retval [catch {set fid [open "~/.pgaccessrc" r]} errmsg]
+       if {! $retval} {
+               while {![eof $fid]} {
+                       set pair [gets $fid]
+                       set PgAcVar([lindex $pair 0]) [lindex $pair 1]
+               }
+               close $fid
+               setGUIPreferences
+       }
+       # The following preferences values will be ignored from the .pgaccessrc file
+       set PgAcVar(pref,typecolors) {black red brown #007e00 #004e00 blue orange yellow pink purple cyan  magenta lightblue lightgreen gray lightyellow}
+       set PgAcVar(pref,typelist) {text bool bytea float8 float4 int4 char name int8 int2 int28 regproc oid tid xid cid}
+       loadInternationalMessages
+}
+       
+       
+proc {save} {} {
+global PgAcVar
+       catch {
+               set fid [open "~/.pgaccessrc" w]
+               foreach key [array names PgAcVar pref,*] { puts $fid "$key {$PgAcVar($key)}" }
+               close $fid
+       }
+       if {$PgAcVar(activetab)=="Tables"} {
+               Mainlib::tab_click Tables
+       }
+}
+
+proc {configure} {} {
+global PgAcVar
+       Window show .pgaw:Preferences
+       foreach language  [lsort $PgAcVar(AVAILABLE_LANGUAGES)] {.pgaw:Preferences.fpl.flb.llb insert end $language}
+       wm transient .pgaw:Preferences .pgaw:Main
+}
+
+
+proc {loadInternationalMessages} {} {
+global Messages PgAcVar
+       set PgAcVar(AVAILABLE_LANGUAGES) {english}
+       foreach filename [glob -nocomplain [file join $PgAcVar(PGACCESS_HOME) lib languages *]] {
+               lappend PgAcVar(AVAILABLE_LANGUAGES) [file tail $filename]
+       }
+       catch { unset Messages }
+       catch { source [file join $PgAcVar(PGACCESS_HOME) lib languages $PgAcVar(pref,language)] }
+}
+
+
+proc {changeLanguage} {} {
+global PgAcVar
+       set sel [.pgaw:Preferences.fpl.flb.llb curselection]
+       if {$sel==""} {return}
+       set desired [.pgaw:Preferences.fpl.flb.llb get $sel]
+       if {$desired==$PgAcVar(pref,language)} {return}
+       set PgAcVar(pref,language) $desired
+       loadInternationalMessages
+       return
+       foreach wid [winfo children .pgaw:Main] {
+               set wtext {}
+               catch { set wtext [$wid cget -text] }
+               if {$wtext != ""} {
+                       $wid configure -text [intlmsg $wtext]
+               }
+       }
+}
+
+
+proc {setDefaultFonts} {} {
+global PgAcVar tcl_platform
+if {[string toupper $tcl_platform(platform)]=="WINDOWS"} {
+       set PgAcVar(pref,font_normal) {"MS Sans Serif" 8}
+       set PgAcVar(pref,font_bold) {"MS Sans Serif" 8 bold}
+       set PgAcVar(pref,font_fix) {Terminal 8}
+       set PgAcVar(pref,font_italic) {"MS Sans Serif" 8 italic}
+} else {
+       set PgAcVar(pref,font_normal) -Adobe-Helvetica-Medium-R-Normal-*-*-120-*-*-*-*-*
+       set PgAcVar(pref,font_bold) -Adobe-Helvetica-Bold-R-Normal-*-*-120-*-*-*-*-*
+       set PgAcVar(pref,font_italic) -Adobe-Helvetica-Medium-O-Normal-*-*-120-*-*-*-*-*
+       set PgAcVar(pref,font_fix) -*-Clean-Medium-R-Normal-*-*-130-*-*-*-*-*
+}
+}
+
+
+proc {setGUIPreferences} {} {
+global PgAcVar
+       foreach wid {Label Text Button Listbox Checkbutton Radiobutton} {
+               option add *$wid.font $PgAcVar(pref,font_normal)
+       }
+       option add *Entry.background #fefefe
+       option add *Entry.foreground #000000
+       option add *Button.BorderWidth 1
+}
+
+}
+
+
+################### END OF NAMESPACE PREFERENCES #################
+
+proc vTclWindow.pgaw:Preferences {base} {
+       if {$base == ""} {
+               set base .pgaw:Preferences
+       }
+       if {[winfo exists $base]} {
+               wm deiconify $base; return
+       }
+       toplevel $base -class Toplevel
+       wm focusmodel $base passive
+       wm geometry $base 450x360+100+213
+       wm maxsize $base 1009 738
+       wm minsize $base 1 1
+       wm overrideredirect $base 0
+       wm resizable $base 0 0
+       wm deiconify $base
+       wm title $base [intlmsg "Preferences"]
+       bind $base <Key-Escape> "Window destroy .pgaw:Preferences"
+       frame $base.fl \
+               -height 75 -relief groove -width 10 
+       frame $base.fr \
+               -height 75 -relief groove -width 10 
+       frame $base.f1 \
+               -height 80 -relief groove -width 125 
+       label $base.f1.l1 \
+               -borderwidth 0 -relief raised \
+               -text [intlmsg {Max rows displayed in table/query view}]
+       entry $base.f1.erows \
+               -background #fefefe -borderwidth 1 -textvariable PgAcVar(pref,rows) -width 7 
+       frame $base.f2 \
+               -height 75 -relief groove -width 125 
+       label $base.f2.l \
+               -borderwidth 0 -relief raised -text [intlmsg {Table viewer font}]
+       label $base.f2.ls \
+               -borderwidth 0 -relief raised -text {      } 
+       radiobutton $base.f2.pgaw:rb1 \
+               -borderwidth 1 -text [intlmsg {fixed width}] -value clean \
+               -variable PgAcVar(pref,tvfont) 
+       radiobutton $base.f2.pgaw:rb2 \
+               -borderwidth 1 -text [intlmsg proportional] -value helv -variable PgAcVar(pref,tvfont) 
+       frame $base.ff \
+               -height 75 -relief groove -width 125 
+       label $base.ff.l1 \
+               -borderwidth 0 -relief raised -text [intlmsg {Font normal}]
+       entry $base.ff.e1 \
+               -background #fefefe -borderwidth 1 -textvariable PgAcVar(pref,font_normal) \
+               -width 200 
+       label $base.ff.l2 \
+               -borderwidth 0 -relief raised -text [intlmsg {Font bold}]
+       entry $base.ff.e2 \
+               -background #fefefe -borderwidth 1 -textvariable PgAcVar(pref,font_bold) \
+               -width 200 
+       label $base.ff.l3 \
+               -borderwidth 0 -relief raised -text [intlmsg {Font italic}]
+       entry $base.ff.e3 \
+               -background #fefefe -borderwidth 1 -textvariable PgAcVar(pref,font_italic) \
+               -width 200 
+       label $base.ff.l4 \
+               -borderwidth 0 -relief raised -text [intlmsg {Font fixed}]
+       entry $base.ff.e4 \
+               -background #fefefe -borderwidth 1 -textvariable PgAcVar(pref,font_fix) \
+               -width 200 
+       frame $base.fls \
+               -borderwidth 1 -height 2 -relief sunken -width 125 
+       frame $base.fal \
+               -height 75 -relief groove -width 125 
+       checkbutton $base.fal.al \
+               -borderwidth 1 -text [intlmsg {Auto-load the last opened database at startup}] \
+        -variable PgAcVar(pref,autoload) -anchor w
+       checkbutton $base.fal.st \
+               -borderwidth 1 -text [intlmsg {View system tables}] \
+        -variable PgAcVar(pref,systemtables) -anchor w
+       frame $base.fpl \
+               -height 49 -relief groove -width 125 
+       label $base.fpl.lt \
+               -borderwidth 0 -relief raised -text [intlmsg {Preferred language}]
+       frame $base.fpl.flb \
+               -height 75 -relief sunken -width 125 
+       listbox $base.fpl.flb.llb \
+               -borderwidth 1 -height 6 -yscrollcommand {.pgaw:Preferences.fpl.flb.vsb set} 
+       scrollbar $base.fpl.flb.vsb \
+               -borderwidth 1 -command {.pgaw:Preferences.fpl.flb.llb yview} -orient vert 
+       frame $base.fb \
+        -height 75 -relief groove -width 125 
+       button $base.fb.btnsave \
+               -command {if {$PgAcVar(pref,rows)>200} {
+       tk_messageBox -title [intlmsg Warning] -parent .pgaw:Preferences -message [intlmsg "A big number of rows displayed in table view will take a lot of memory!"]
+}
+Preferences::changeLanguage
+Preferences::save
+Window destroy .pgaw:Preferences
+tk_messageBox -title [intlmsg Warning] -parent .pgaw:Main -message [intlmsg "Changed fonts may appear in the next working session!"]} \
+               -padx 9 -pady 3 -text [intlmsg Save]
+       button $base.fb.btncancel \
+               -command {Window destroy .pgaw:Preferences} -padx 9 -pady 3 -text [intlmsg Cancel]
+       pack $base.fl \
+               -in .pgaw:Preferences -anchor center -expand 0 -fill y -side left 
+       pack $base.fr \
+               -in .pgaw:Preferences -anchor center -expand 0 -fill y -side right 
+       pack $base.f1 \
+               -in .pgaw:Preferences -anchor center -expand 0 -fill x -pady 5 -side top 
+       pack $base.f1.l1 \
+               -in .pgaw:Preferences.f1 -anchor center -expand 0 -fill none -side left 
+       pack $base.f1.erows \
+               -in .pgaw:Preferences.f1 -anchor center -expand 0 -fill none -side left 
+       pack $base.f2 \
+               -in .pgaw:Preferences -anchor center -expand 0 -fill x -pady 5 -side top 
+       pack $base.f2.l \
+               -in .pgaw:Preferences.f2 -anchor center -expand 0 -fill none -side left 
+       pack $base.f2.ls \
+               -in .pgaw:Preferences.f2 -anchor center -expand 0 -fill none -side left 
+       pack $base.f2.pgaw:rb1 \
+               -in .pgaw:Preferences.f2 -anchor center -expand 0 -fill none -side left 
+       pack $base.f2.pgaw:rb2 \
+               -in .pgaw:Preferences.f2 -anchor center -expand 0 -fill none -side left 
+       pack $base.ff \
+               -in .pgaw:Preferences -anchor center -expand 0 -fill x -side top 
+       grid columnconf $base.ff 1 -weight 1
+       grid $base.ff.l1 \
+               -in .pgaw:Preferences.ff -column 0 -row 0 -columnspan 1 -rowspan 1 -sticky w 
+       grid $base.ff.e1 \
+               -in .pgaw:Preferences.ff -column 1 -row 0 -columnspan 1 -rowspan 1 -pady 1 
+       grid $base.ff.l2 \
+               -in .pgaw:Preferences.ff -column 0 -row 2 -columnspan 1 -rowspan 1 -sticky w 
+       grid $base.ff.e2 \
+               -in .pgaw:Preferences.ff -column 1 -row 2 -columnspan 1 -rowspan 1 -pady 1 
+       grid $base.ff.l3 \
+               -in .pgaw:Preferences.ff -column 0 -row 4 -columnspan 1 -rowspan 1 -sticky w 
+       grid $base.ff.e3 \
+               -in .pgaw:Preferences.ff -column 1 -row 4 -columnspan 1 -rowspan 1 -pady 1 
+       grid $base.ff.l4 \
+               -in .pgaw:Preferences.ff -column 0 -row 6 -columnspan 1 -rowspan 1 -sticky w 
+       grid $base.ff.e4 \
+               -in .pgaw:Preferences.ff -column 1 -row 6 -columnspan 1 -rowspan 1 -pady 1 
+       pack $base.fls \
+               -in .pgaw:Preferences -anchor center -expand 0 -fill x -pady 5 -side top 
+       pack $base.fal \
+               -in .pgaw:Preferences -anchor center -expand 0 -fill x -side top 
+       pack $base.fal.al \
+               -in .pgaw:Preferences.fal -anchor center -expand 0 -fill x -side top -anchor w 
+       pack $base.fal.st \
+               -in .pgaw:Preferences.fal -anchor center -expand 0 -fill x -side top -anchor w
+       pack $base.fpl \
+               -in .pgaw:Preferences -anchor center -expand 0 -fill x -side top 
+       pack $base.fpl.lt \
+               -in .pgaw:Preferences.fpl -anchor center -expand 0 -fill none -side top 
+       pack $base.fpl.flb \
+               -in .pgaw:Preferences.fpl -anchor center -expand 0 -fill none -side top 
+       pack $base.fpl.flb.llb \
+               -in .pgaw:Preferences.fpl.flb -anchor center -expand 0 -fill none -side left 
+       pack $base.fpl.flb.vsb \
+               -in .pgaw:Preferences.fpl.flb -anchor center -expand 0 -fill y -side right 
+       pack $base.fb \
+               -in .pgaw:Preferences -anchor center -expand 0 -fill none -side bottom 
+       grid $base.fb.btnsave \
+               -in .pgaw:Preferences.fb -column 0 -row 0 -columnspan 1 -rowspan 1 
+       grid $base.fb.btncancel \
+               -in .pgaw:Preferences.fb -column 1 -row 0 -columnspan 1 -rowspan 1 
+}
+
diff --git a/src/bin/pgaccess/lib/qed b/src/bin/pgaccess/lib/qed
new file mode 100755 (executable)
index 0000000..4db7a01
--- /dev/null
@@ -0,0 +1,7 @@
+#!/bin/bash
+for fisier in *.tcl ; do
+       echo $fisier ;
+       sed -e "s/show_error/showError/g" <$fisier >temp
+       mv temp $fisier
+done
+
diff --git a/src/bin/pgaccess/lib/queries.tcl b/src/bin/pgaccess/lib/queries.tcl
new file mode 100644 (file)
index 0000000..fd880df
--- /dev/null
@@ -0,0 +1,228 @@
+namespace eval Queries {
+
+
+proc {new} {} {
+global PgAcVar
+               Window show .pgaw:QueryBuilder
+               PgAcVar:clean query,*
+               set PgAcVar(query,oid) 0
+               set PgAcVar(query,name) {}
+               set PgAcVar(query,asview) 0
+               set PgAcVar(query,tables) {}
+               set PgAcVar(query,links) {}
+               set PgAcVar(query,results) {}
+               .pgaw:QueryBuilder.saveAsView configure -state normal
+}
+
+
+proc {open} {queryname} {
+global PgAcVar
+       if {! [loadQuery $queryname]} return;
+       if {$PgAcVar(query,type)=="S"} then {
+               set wn [Tables::getNewWindowName]
+               set PgAcVar(mw,$wn,query) [subst $PgAcVar(query,sqlcmd)]
+               set PgAcVar(mw,$wn,updatable) 0
+               set PgAcVar(mw,$wn,isaquery) 1
+               Tables::createWindow
+               wm title $wn "Query result: $PgAcVar(query,name)"
+               Tables::loadLayout $wn $PgAcVar(query,name)
+               Tables::selectRecords $wn $PgAcVar(mw,$wn,query)
+       } else {
+               set answ [tk_messageBox -title [intlmsg Warning] -type yesno -message "This query is an action query!\n\n[string range $PgAcVar(query,sqlcmd) 0 30] ...\n\nDo you want to execute it?"]
+               if {$answ} {
+                       if {[sql_exec noquiet $PgAcVar(query,sqlcmd)]} {
+                               tk_messageBox -title Information -message "Your query has been executed without error!"
+                       }
+               }
+       }
+}
+
+
+proc {design} {queryname} {
+global PgAcVar
+       if {! [loadQuery $queryname]} return;
+       Window show .pgaw:QueryBuilder
+       .pgaw:QueryBuilder.text1 delete 0.0 end
+       .pgaw:QueryBuilder.text1 insert end $PgAcVar(query,sqlcmd)
+       .pgaw:QueryBuilder.text2 delete 0.0 end
+       .pgaw:QueryBuilder.text2 insert end $PgAcVar(query,comments)    
+}
+
+
+proc {loadQuery} {queryname} {
+global PgAcVar CurrentDB
+       set PgAcVar(query,name) $queryname
+       if {[set pgres [wpg_exec $CurrentDB "select querycommand,querytype,querytables,querylinks,queryresults,querycomments,oid from pga_queries where queryname='$PgAcVar(query,name)'"]]==0} then {
+               showError [intlmsg "Error retrieving query definition"]
+               return 0
+       }
+       if {[pg_result $pgres -numTuples]==0} {
+               showError [format [intlmsg "Query '%s' was not found!"] $PgAcVar(query,name)]
+               pg_result $pgres -clear
+               return 0
+       }
+       set tuple [pg_result $pgres -getTuple 0]
+       set PgAcVar(query,sqlcmd)   [lindex $tuple 0]
+       set PgAcVar(query,type)     [lindex $tuple 1]
+       set PgAcVar(query,tables)   [lindex $tuple 2]
+       set PgAcVar(query,links)    [lindex $tuple 3]
+       set PgAcVar(query,results)  [lindex $tuple 4]
+       set PgAcVar(query,comments) [lindex $tuple 5]
+       set PgAcVar(query,oid)      [lindex $tuple 6]
+       pg_result $pgres -clear
+       return 1
+}
+
+
+proc {visualDesigner} {} {
+global PgAcVar
+       Window show .pgaw:VisualQuery
+       VisualQueryBuilder::loadVisualLayout
+       focus .pgaw:VisualQuery.fb.entt
+}
+
+
+proc {save} {} {
+global PgAcVar CurrentDB
+if {$PgAcVar(query,name)==""} then {
+       showError [intlmsg "You have to supply a name for this query!"]
+       focus .pgaw:QueryBuilder.eqn
+} else {
+       set qcmd [.pgaw:QueryBuilder.text1 get 1.0 end]
+       set PgAcVar(query,comments) [.pgaw:QueryBuilder.text2 get 1.0 end]
+       regsub -all "\n" $qcmd " " qcmd
+       if {$qcmd==""} then {
+       showError [intlmsg "This query has no commands?"]
+       } else {
+               if { [lindex [split [string toupper [string trim $qcmd]]] 0] == "SELECT" } {
+                       set qtype S
+               } else {
+                       set qtype A
+               }
+               if {$PgAcVar(query,asview)} {
+                       wpg_select $CurrentDB "select pg_get_viewdef('$PgAcVar(query,name)') as vd" tup {
+                               if {$tup(vd)!="Not a view"} {
+                                       if {[tk_messageBox -title [intlmsg Warning] -message [format [intlmsg "View '%s' already exists!\nOverwrite ?"] $PgAcVar(query,name)] -type yesno -default no]=="yes"} {
+                                               set pg_res [wpg_exec $CurrentDB "drop view \"$PgAcVar(query,name)\""]
+                                               if {$PgAcVar(pgsql,status)!="PGRES_COMMAND_OK"} {
+                                                       showError "[intlmsg {Error deleting view}] '$PgAcVar(query,name)'"
+                                               }
+                                       }
+                               }
+                       }
+                       set pgres [wpg_exec $CurrentDB "create view \"$PgAcVar(query,name)\" as $qcmd"]
+                       if {$PgAcVar(pgsql,status)!="PGRES_COMMAND_OK"} {
+                               showError "[intlmsg {Error defining view}]\n\n$PgAcVar(pgsql,errmsg)"
+                       } else {
+                               Mainlib::tab_click Views
+                               Window destroy .pgaw:QueryBuilder
+                       }
+                       catch {pg_result $pgres -clear}
+               } else {
+                       regsub -all "'" $qcmd "''" qcmd
+                       regsub -all "'" $PgAcVar(query,comments) "''" PgAcVar(query,comments)
+                       regsub -all "'" $PgAcVar(query,results) "''" PgAcVar(query,results)
+                       setCursor CLOCK
+                       if {$PgAcVar(query,oid)==0} then {
+                               set pgres [wpg_exec $CurrentDB "insert into pga_queries values ('$PgAcVar(query,name)','$qtype','$qcmd','$PgAcVar(query,tables)','$PgAcVar(query,links)','$PgAcVar(query,results)','$PgAcVar(query,comments)')"]
+                       } else {
+                               set pgres [wpg_exec $CurrentDB "update pga_queries set queryname='$PgAcVar(query,name)',querytype='$qtype',querycommand='$qcmd',querytables='$PgAcVar(query,tables)',querylinks='$PgAcVar(query,links)',queryresults='$PgAcVar(query,results)',querycomments='$PgAcVar(query,comments)' where oid=$PgAcVar(query,oid)"]
+                       }
+                       setCursor DEFAULT
+                       if {$PgAcVar(pgsql,status)!="PGRES_COMMAND_OK"} then {
+                               showError "[intlmsg {Error executing query}]\n$PgAcVar(pgsql,errmsg)"
+                       } else {
+                               Mainlib::tab_click Queries
+                               if {$PgAcVar(query,oid)==0} {set PgAcVar(query,oid) [pg_result $pgres -oid]}
+                       }
+               }
+               catch {pg_result $pgres -clear}
+       }
+}
+}
+
+
+proc {execute} {} {
+global PgAcVar
+set qcmd [.pgaw:QueryBuilder.text1 get 0.0 end]
+regsub -all "\n" [string trim $qcmd] " " qcmd
+if {[lindex [split [string toupper $qcmd]] 0]!="SELECT"} {
+       if {[tk_messageBox -title [intlmsg Warning] -parent .pgaw:QueryBuilder -message [intlmsg "This is an action query!\n\nExecute it?"] -type yesno -default no]=="yes"} {
+               sql_exec noquiet $qcmd
+       }
+} else {
+       set wn [Tables::getNewWindowName]
+       set PgAcVar(mw,$wn,query) [subst $qcmd]
+       set PgAcVar(mw,$wn,updatable) 0
+       set PgAcVar(mw,$wn,isaquery) 1
+       Tables::createWindow
+       Tables::loadLayout $wn $PgAcVar(query,name)
+       Tables::selectRecords $wn $PgAcVar(mw,$wn,query)
+}
+}
+
+proc {close} {} {
+global PgAcVar
+       .pgaw:QueryBuilder.saveAsView configure -state normal
+       set PgAcVar(query,asview) 0
+       set PgAcVar(query,name) {}
+       .pgaw:QueryBuilder.text1 delete 1.0 end
+       Window destroy .pgaw:QueryBuilder
+}
+
+
+}
+
+
+proc vTclWindow.pgaw:QueryBuilder {base} {
+global PgAcVar
+       if {$base == ""} {
+               set base .pgaw:QueryBuilder
+       }
+       if {[winfo exists $base]} {
+               wm deiconify $base; return
+       }
+       toplevel $base -class Toplevel
+       wm focusmodel $base passive
+       wm geometry $base 542x364+150+150
+       wm maxsize $base 1009 738
+       wm minsize $base 1 1
+       wm overrideredirect $base 0
+       wm resizable $base 0 0
+       wm deiconify $base
+       wm title $base [intlmsg "Query builder"]
+       bind $base <Key-F1> "Help::load queries"
+       label $base.lqn  -borderwidth 0 -text [intlmsg {Query name}]
+       entry $base.eqn  -background #fefefe -borderwidth 1 -foreground #000000  -highlightthickness 1 -selectborderwidth 0 -textvariable PgAcVar(query,name) 
+       text $base.text1  -background #fefefe -borderwidth 1  -font $PgAcVar(pref,font_normal) -foreground #000000 -highlightthickness 1 -wrap word 
+       label $base.lcomm -borderwidth 0 -text [intlmsg Comments]
+       text $base.text2  -background #fefefe -borderwidth 1  -font $PgAcVar(pref,font_normal) -foreground #000000 -highlightthickness 1 -wrap word 
+       checkbutton $base.saveAsView  -borderwidth 1  -text [intlmsg {Save this query as a view}] -variable PgAcVar(query,asview) 
+       frame $base.frb \
+               -height 75 -relief groove -width 125 
+       button $base.frb.savebtn -command {Queries::save} \
+               -borderwidth 1 -text [intlmsg {Save query definition}]
+       button $base.frb.execbtn -command {Queries::execute} \
+               -borderwidth 1 -text [intlmsg {Execute query}]
+       button $base.frb.pgaw:VisualQueryshow -command {Queries::visualDesigner} \
+               -borderwidth 1 -text [intlmsg {Visual designer}]
+       button $base.frb.termbtn -command {Queries::close} \
+               -borderwidth 1 -text [intlmsg Close]
+       place $base.lqn  -x 5 -y 5 -anchor nw -bordermode ignore 
+       place $base.eqn  -x 100 -y 1 -width 335 -height 24 -anchor nw -bordermode ignore 
+       place $base.frb \
+               -x 5 -y 55 -width 530 -height 35 -anchor nw -bordermode ignore 
+       pack $base.frb.savebtn \
+               -in $base.frb -anchor center -expand 0 -fill none -side left 
+       pack $base.frb.execbtn \
+               -in $base.frb -anchor center -expand 0 -fill none -side left 
+       pack $base.frb.pgaw:VisualQueryshow \
+               -in $base.frb -anchor center -expand 0 -fill none -side left 
+       pack $base.frb.termbtn \
+               -in $base.frb -anchor center -expand 0 -fill none -side right 
+       place $base.text1  -x 5 -y 90 -width 530 -height 160 -anchor nw -bordermode ignore 
+       place $base.lcomm -x 5 -y 255
+       place $base.text2  -x 5 -y 270 -width 530 -height 86 -anchor nw -bordermode ignore 
+       place $base.saveAsView  -x 5 -y 30 -height 25 -anchor nw -bordermode ignore 
+}
+
diff --git a/src/bin/pgaccess/lib/reports.tcl b/src/bin/pgaccess/lib/reports.tcl
new file mode 100644 (file)
index 0000000..c526ca9
--- /dev/null
@@ -0,0 +1,599 @@
+namespace eval Reports {
+
+
+proc {new} {} {
+global PgAcVar
+       Window show .pgaw:ReportBuilder
+       tkwait visibility .pgaw:ReportBuilder
+       init
+       set PgAcVar(report,reportname) {}
+       set PgAcVar(report,justpreview) 0
+       focus .pgaw:ReportBuilder.e2
+}
+
+
+proc {open} {reportname} {
+global PgAcVar CurrentDB
+       Window show .pgaw:ReportBuilder
+       #tkwait visibility .pgaw:ReportBuilder
+       Window hide .pgaw:ReportBuilder
+       Window show .pgaw:ReportPreview
+       init
+       set PgAcVar(report,reportname) $reportname
+       loadReport
+       tkwait visibility .pgaw:ReportPreview
+       set PgAcVar(report,justpreview) 1
+       preview
+}
+
+
+proc {design} {reportname} {
+global PgAcVar
+       Window show .pgaw:ReportBuilder
+       tkwait visibility .pgaw:ReportBuilder
+       init
+       set PgAcVar(report,reportname) $reportname
+       loadReport
+       set PgAcVar(report,justpreview) 0
+}
+
+
+proc {drawReportAreas} {} {
+global PgAcVar
+foreach rg $PgAcVar(report,regions) {
+       .pgaw:ReportBuilder.c delete bg_$rg
+       .pgaw:ReportBuilder.c create line 0 $PgAcVar(report,y_$rg) 5000 $PgAcVar(report,y_$rg) -tags [subst {bg_$rg}]
+       .pgaw:ReportBuilder.c create rectangle 6 [expr $PgAcVar(report,y_$rg)-3] 12 [expr $PgAcVar(report,y_$rg)+3] -fill black -tags [subst {bg_$rg mov reg}]
+       .pgaw:ReportBuilder.c lower bg_$rg
+}
+}
+
+proc {toggleAlignMode} {} {
+set bb [.pgaw:ReportBuilder.c bbox hili]
+if {[.pgaw:ReportBuilder.balign cget -text]=="left"} then {
+       .pgaw:ReportBuilder.balign configure -text right
+       .pgaw:ReportBuilder.c itemconfigure hili -anchor ne
+       .pgaw:ReportBuilder.c move hili [expr [lindex $bb 2]-[lindex $bb 0]-3] 0
+} else {
+       .pgaw:ReportBuilder.balign configure -text left
+       .pgaw:ReportBuilder.c itemconfigure hili -anchor nw
+       .pgaw:ReportBuilder.c move hili [expr [lindex $bb 0]-[lindex $bb 2]+3] 0
+}
+}
+
+proc {getBoldStatus} {} {
+       if {[.pgaw:ReportBuilder.lbold cget -relief]=="raised"} then {return Medium} else {return Bold}
+}
+
+proc {getItalicStatus} {} {
+       if {[.pgaw:ReportBuilder.lita cget -relief]=="raised"} then {return R} else {return O}
+}
+
+proc {toggleBold} {} {
+       if {[getBoldStatus]=="Bold"} {
+          .pgaw:ReportBuilder.lbold configure -relief raised
+       } else {
+          .pgaw:ReportBuilder.lbold configure -relief sunken
+       }
+       setObjectFont
+}
+
+
+proc {toggleItalic} {} {
+       if {[getItalicStatus]=="O"} {
+          .pgaw:ReportBuilder.lita configure -relief raised
+       } else {
+          .pgaw:ReportBuilder.lita configure -relief sunken
+       }
+       setObjectFont
+}
+
+
+proc {setFont} {} {
+       set temp [.pgaw:ReportBuilder.bfont cget -text]
+       if {$temp=="Courier"} then {
+         .pgaw:ReportBuilder.bfont configure -text Helvetica
+       } else {
+         .pgaw:ReportBuilder.bfont configure -text Courier
+       }
+       setObjectFont
+}
+
+
+proc {getSourceFields} {} {
+global PgAcVar CurrentDB
+       .pgaw:ReportBuilder.lb delete 0 end
+       if {$PgAcVar(report,tablename)==""} return ;
+       #setCursor CLOCK
+       wpg_select $CurrentDB "select attnum,attname from pg_class,pg_attribute where (pg_class.relname='$PgAcVar(report,tablename)') and (pg_class.oid=pg_attribute.attrelid) and (attnum>0) order by attnum" rec {
+               .pgaw:ReportBuilder.lb insert end $rec(attname)
+       }
+       #setCursor DEFAULT
+}
+
+
+proc {hasTag} {id tg} {
+       if {[lsearch [.pgaw:ReportBuilder.c itemcget $id -tags] $tg]==-1} then {return 0 } else {return 1}
+}
+
+
+proc {init} {} {
+global PgAcVar
+       set PgAcVar(report,xl_auto) 10
+       set PgAcVar(report,xf_auto) 10
+       set PgAcVar(report,regions) {rpthdr pghdr detail pgfoo rptfoo}
+       set PgAcVar(report,y_rpthdr) 30
+       set PgAcVar(report,y_pghdr) 60
+       set PgAcVar(report,y_detail) 90
+       set PgAcVar(report,y_pgfoo) 120
+       set PgAcVar(report,y_rptfoo) 150
+       set PgAcVar(report,e_rpthdr) [intlmsg {Report header}]
+       set PgAcVar(report,e_pghdr) [intlmsg {Page header}]
+       set PgAcVar(report,e_detail) [intlmsg {Detail record}]
+       set PgAcVar(report,e_pgfoo) [intlmsg {Page footer}]
+       set PgAcVar(report,e_rptfoo) [intlmsg {Report footer}]
+       drawReportAreas
+}
+
+proc {loadReport} {} {
+global PgAcVar CurrentDB
+       .pgaw:ReportBuilder.c delete all
+       wpg_select $CurrentDB "select * from pga_reports where reportname='$PgAcVar(report,reportname)'" rcd {
+               eval $rcd(reportbody)
+       }
+       getSourceFields
+       drawReportAreas
+}
+
+
+proc {preview} {} {
+global PgAcVar CurrentDB
+Window show .pgaw:ReportPreview
+.pgaw:ReportPreview.fr.c delete all
+set ol [.pgaw:ReportBuilder.c find withtag ro]
+set fields {}
+foreach objid $ol {
+       set tags [.pgaw:ReportBuilder.c itemcget $objid -tags]
+       lappend fields [string range [lindex $tags [lsearch -glob $tags f-*]] 2 64]
+       lappend fields [lindex [.pgaw:ReportBuilder.c coords $objid] 0]
+       lappend fields [lindex [.pgaw:ReportBuilder.c coords $objid] 1]
+       lappend fields $objid
+       lappend fields [lindex $tags [lsearch -glob $tags t_*]]
+}
+# Parsing page header
+set py 10
+foreach {field x y objid objtype} $fields {
+       if {$objtype=="t_l"} {
+               .pgaw:ReportPreview.fr.c create text $x [expr $py+$y] -text [.pgaw:ReportBuilder.c itemcget $objid -text]  -font [.pgaw:ReportBuilder.c itemcget $objid -font] -anchor nw
+       }
+}
+incr py [expr $PgAcVar(report,y_pghdr)-$PgAcVar(report,y_rpthdr)]
+# Parsing detail group
+set di [lsearch $PgAcVar(report,regions) detail]
+set y_hi $PgAcVar(report,y_detail)
+set y_lo $PgAcVar(report,y_[lindex $PgAcVar(report,regions) [expr $di-1]])
+wpg_select $CurrentDB "select * from \"$PgAcVar(report,tablename)\"" rec {
+       foreach {field x y objid objtype} $fields {
+               if {($y>=$y_lo) && ($y<=$y_hi)} then {
+               if {$objtype=="t_f"} {
+                       .pgaw:ReportPreview.fr.c create text $x [expr $py+$y] -text $rec($field) -font [.pgaw:ReportBuilder.c itemcget $objid -font] -anchor [.pgaw:ReportBuilder.c itemcget $objid -anchor]
+               }
+               if {$objtype=="t_l"} {
+                       .pgaw:ReportPreview.fr.c create text $x [expr $py+$y] -text [.pgaw:ReportBuilder.c itemcget $objid -text]  -font [.pgaw:ReportBuilder.c itemcget $objid -font] -anchor nw
+               }
+               }
+       }
+       incr py [expr $PgAcVar(report,y_detail)-$PgAcVar(report,y_pghdr)]
+}
+.pgaw:ReportPreview.fr.c configure -scrollregion [subst {0 0 1000 $py}]
+}
+
+
+proc {print} {} {
+       set bb [.pgaw:ReportPreview.fr.c bbox all]
+       .pgaw:ReportPreview.fr.c postscript -file "pgaccess-report.ps" -width [expr 10+[lindex $bb 2]-[lindex $bb 0]] -height [expr 10+[lindex $bb 3]-[lindex $bb 1]]
+       tk_messageBox -title Information -parent .pgaw:ReportBuilder -message "The printed image in Postscript is in the file pgaccess-report.ps"
+}
+
+
+proc {save} {} {
+global PgAcVar
+set prog "set PgAcVar(report,tablename) \"$PgAcVar(report,tablename)\""
+foreach region $PgAcVar(report,regions) {
+       set prog "$prog ; set PgAcVar(report,y_$region) $PgAcVar(report,y_$region)"
+}
+foreach obj [.pgaw:ReportBuilder.c find all] {
+       if {[.pgaw:ReportBuilder.c type $obj]=="text"} {
+               set bb [.pgaw:ReportBuilder.c bbox $obj]
+               if {[.pgaw:ReportBuilder.c itemcget $obj -anchor]=="nw"} then {set x [expr [lindex $bb 0]+1]} else {set x [expr [lindex $bb 2]-2]}
+               set prog "$prog ; .pgaw:ReportBuilder.c create text $x [lindex $bb 1] -font [.pgaw:ReportBuilder.c itemcget $obj -font] -anchor [.pgaw:ReportBuilder.c itemcget $obj -anchor] -text {[.pgaw:ReportBuilder.c itemcget $obj -text]} -tags {[.pgaw:ReportBuilder.c itemcget $obj -tags]}"
+       }
+}
+sql_exec noquiet "delete from pga_reports where reportname='$PgAcVar(report,reportname)'"
+sql_exec noquiet "insert into pga_reports (reportname,reportsource,reportbody) values ('$PgAcVar(report,reportname)','$PgAcVar(report,tablename)','$prog')"
+}
+
+
+proc {addField} {} {
+global PgAcVar
+       set fldname [.pgaw:ReportBuilder.lb get [.pgaw:ReportBuilder.lb curselection]]
+       set newid [.pgaw:ReportBuilder.c create text $PgAcVar(report,xf_auto) [expr $PgAcVar(report,y_rpthdr)+5] -text $fldname -tags [subst {t_l mov ro}] -anchor nw -font $PgAcVar(pref,font_normal)]
+       .pgaw:ReportBuilder.c create text $PgAcVar(report,xf_auto) [expr $PgAcVar(report,y_pghdr)+5] -text $fldname -tags [subst {f-$fldname t_f rg_detail mov ro}] -anchor nw -font $PgAcVar(pref,font_normal)
+       set bb [.pgaw:ReportBuilder.c bbox $newid]
+       incr PgAcVar(report,xf_auto) [expr 5+[lindex $bb 2]-[lindex $bb 0]]
+}
+
+
+proc {addLabel} {} {
+global PgAcVar
+       set fldname $PgAcVar(report,labeltext)
+       set newid [.pgaw:ReportBuilder.c create text $PgAcVar(report,xl_auto) [expr $PgAcVar(report,y_rpthdr)+5] -text $fldname -tags [subst {t_l mov ro}] -anchor nw -font $PgAcVar(pref,font_normal)]
+       set bb [.pgaw:ReportBuilder.c bbox $newid]
+       incr PgAcVar(report,xl_auto) [expr 5+[lindex $bb 2]-[lindex $bb 0]]
+}
+
+
+proc {setObjectFont} {} {
+global PgAcVar
+       .pgaw:ReportBuilder.c itemconfigure hili -font -Adobe-[.pgaw:ReportBuilder.bfont cget -text]-[getBoldStatus]-[getItalicStatus]-Normal--*-$PgAcVar(report,pointsize)-*-*-*-*-*-*
+}
+
+
+proc {deleteObject} {} {
+       if {[tk_messageBox -title [intlmsg Warning] -parent .pgaw:ReportBuilder -message "Delete current report object?" -type yesno -default no]=="no"} return;
+       .pgaw:ReportBuilder.c delete hili
+}
+
+
+proc {dragMove} {w x y} {
+global PgAcVar
+       # Showing current region
+       foreach rg $PgAcVar(report,regions) {
+               set PgAcVar(report,msg) $PgAcVar(report,e_$rg)
+               if {$PgAcVar(report,y_$rg)>$y} break;
+       }
+       set temp {}
+       catch {set temp $PgAcVar(draginfo,obj)}
+       if {"$temp" != ""} {
+               set dx [expr $x - $PgAcVar(draginfo,x)]
+               set dy [expr $y - $PgAcVar(draginfo,y)]
+               if {$PgAcVar(draginfo,region)!=""} {
+                       set x $PgAcVar(draginfo,x) ; $w move bg_$PgAcVar(draginfo,region) 0 $dy
+               } else {
+                       $w move $PgAcVar(draginfo,obj) $dx $dy
+               }
+               set PgAcVar(draginfo,x) $x
+               set PgAcVar(draginfo,y) $y
+       }
+}
+
+
+proc {dragStart} {w x y} {
+global PgAcVar
+focus .pgaw:ReportBuilder.c
+catch {unset draginfo}
+set obj {}
+# Only movable objects start dragging
+foreach id [$w find overlapping $x $y $x $y] {
+       if {[hasTag $id mov]} {
+               set obj $id
+               break
+       }
+}
+if {$obj==""} return;
+set PgAcVar(draginfo,obj) $obj
+set taglist [.pgaw:ReportBuilder.c itemcget $obj -tags]
+set i [lsearch -glob $taglist bg_*]
+if {$i==-1} {
+       set PgAcVar(draginfo,region) {}
+} else {
+       set PgAcVar(draginfo,region) [string range [lindex $taglist $i] 3 64]
+} 
+.pgaw:ReportBuilder configure -cursor hand1
+.pgaw:ReportBuilder.c itemconfigure [.pgaw:ReportBuilder.c find withtag hili] -fill black
+.pgaw:ReportBuilder.c dtag [.pgaw:ReportBuilder.c find withtag hili] hili
+.pgaw:ReportBuilder.c addtag hili withtag $PgAcVar(draginfo,obj)
+.pgaw:ReportBuilder.c itemconfigure hili -fill blue
+set PgAcVar(draginfo,x) $x
+set PgAcVar(draginfo,y) $y
+set PgAcVar(draginfo,sx) $x
+set PgAcVar(draginfo,sy) $y
+# Setting font information
+if {[.pgaw:ReportBuilder.c type hili]=="text"} {
+       set fnta [split [.pgaw:ReportBuilder.c itemcget hili -font] -]
+       .pgaw:ReportBuilder.bfont configure -text [lindex $fnta 2]
+       if {[lindex $fnta 3]=="Medium"} then {.pgaw:ReportBuilder.lbold configure -relief raised} else {.pgaw:ReportBuilder.lbold configure -relief sunken}
+       if {[lindex $fnta 4]=="R"} then {.pgaw:ReportBuilder.lita configure -relief raised} else {.pgaw:ReportBuilder.lita configure -relief sunken}
+       set PgAcVar(report,pointsize) [lindex $fnta 8]
+       if {[hasTag $obj t_f]} {set PgAcVar(report,info) "Database field"}
+       if {[hasTag $obj t_l]} {set PgAcVar(report,info) "Label"}
+       if {[.pgaw:ReportBuilder.c itemcget $obj -anchor]=="nw"} then {.pgaw:ReportBuilder.balign configure -text left} else {.pgaw:ReportBuilder.balign configure -text right}
+}
+}
+
+proc {dragStop} {x y} {
+global PgAcVar
+# when click Close, ql window is destroyed but event ButtonRelease-1 is fired
+if {![winfo exists .pgaw:ReportBuilder]} return;
+.pgaw:ReportBuilder configure -cursor left_ptr
+set este {}
+catch {set este $PgAcVar(draginfo,obj)}
+if {$este==""} return
+# Erase information about object beeing dragged
+if {$PgAcVar(draginfo,region)!=""} {
+       set dy 0
+       foreach rg $PgAcVar(report,regions) {
+               .pgaw:ReportBuilder.c move rg_$rg 0 $dy
+               if {$rg==$PgAcVar(draginfo,region)} {
+                       set dy [expr $y-$PgAcVar(report,y_$PgAcVar(draginfo,region))]
+               }
+               incr PgAcVar(report,y_$rg) $dy
+       }
+#    .pgaw:ReportBuilder.c move det 0 [expr $y-$PgAcVar(report,y_$PgAcVar(draginfo,region))]
+       set PgAcVar(report,y_$PgAcVar(draginfo,region)) $y
+       drawReportAreas
+} else {
+       # Check if object beeing dragged is inside the canvas
+       set bb [.pgaw:ReportBuilder.c bbox $PgAcVar(draginfo,obj)]
+       if {[lindex $bb 0] < 5} {
+               .pgaw:ReportBuilder.c move $PgAcVar(draginfo,obj) [expr 5-[lindex $bb 0]] 0
+       }
+}
+set PgAcVar(draginfo,obj) {}
+PgAcVar:clean draginfo,*
+}
+
+
+proc {deleteAllObjects} {} {
+       if {[tk_messageBox -title [intlmsg Warning] -parent .pgaw:ReportBuilder -message [intlmsg "All report information will be deleted.\n\nProceed ?"] -type yesno -default no]=="yes"} then {
+               .pgaw:ReportBuilder.c delete all
+               init
+               drawReportAreas
+       }
+}
+
+}
+
+################################################################
+
+
+proc vTclWindow.pgaw:ReportBuilder {base} {
+global PgAcVar
+       if {$base == ""} {
+               set base .pgaw:ReportBuilder
+       }
+       if {[winfo exists $base]} {
+               wm deiconify $base; return
+       }
+       toplevel $base -class Toplevel
+       wm focusmodel $base passive
+       wm geometry $base 652x426+96+120
+       wm maxsize $base 1009 738
+       wm minsize $base 1 1
+       wm overrideredirect $base 0
+       wm resizable $base 0 0
+       wm deiconify $base
+       wm title $base [intlmsg "Report builder"]
+       label $base.l1 \
+               -borderwidth 1 \
+               -relief raised -text [intlmsg {Report fields}]
+       listbox $base.lb \
+               -background #fefefe -foreground #000000 -borderwidth 1 \
+               -selectbackground #c3c3c3 \
+               -highlightthickness 1 -selectborderwidth 0 \
+               -yscrollcommand {.pgaw:ReportBuilder.sb set} 
+       bind $base.lb <ButtonRelease-1> {
+               Reports::addField
+       }
+       canvas $base.c \
+               -background #fffeff -borderwidth 2 -height 207 -highlightthickness 0 \
+               -relief ridge -takefocus 1 -width 295 
+       bind $base.c <Button-1> {
+               Reports::dragStart %W %x %y
+       }
+       bind $base.c <ButtonRelease-1> {
+               Reports::dragStop %x %y
+       }
+       bind $base.c <Key-Delete> {
+               Reports::deleteObject
+       }
+       bind $base.c <Motion> {
+               Reports::dragMove %W %x %y
+       }
+       button $base.bt2 \
+               -command Reports::deleteAllObjects \
+               -text [intlmsg {Delete all}]
+       button $base.bt4 \
+               -command Reports::preview \
+               -text [intlmsg Preview]
+       button $base.bt5 \
+               -borderwidth 1 -command {Window destroy .pgaw:ReportBuilder} \
+               -text [intlmsg Close]
+       scrollbar $base.sb \
+               -borderwidth 1 -command {.pgaw:ReportBuilder.lb yview} -orient vert 
+       label $base.lmsg \
+               -anchor w \
+               -relief groove -text [intlmsg {Report header}] -textvariable PgAcVar(report,msg) 
+       entry $base.e2 \
+               -background #fefefe -borderwidth 1 -highlightthickness 0 \
+               -textvariable PgAcVar(report,tablename) 
+       bind $base.e2 <Key-Return> {
+               Reports::getSourceFields
+       }
+       entry $base.elab \
+               -background #fefefe -borderwidth 1 -highlightthickness 0 \
+               -textvariable PgAcVar(report,labeltext) 
+       button $base.badl \
+               -borderwidth 1 -command Reports::addLabel \
+               -text [intlmsg {Add label}]
+       label $base.lbold \
+               -borderwidth 1 -relief raised -text B 
+       bind $base.lbold <Button-1> {
+               Reports::toggleBold
+       }
+       label $base.lita \
+               -borderwidth 1 \
+               -font $PgAcVar(pref,font_italic) \
+               -relief raised -text i 
+       bind $base.lita <Button-1> {
+               Reports::toggleItalic
+       }
+       entry $base.eps \
+               -background #fefefe -highlightthickness 0 -relief groove \
+               -textvariable PgAcVar(report,pointsize) 
+       bind $base.eps <Key-Return> {
+               Reports::setObjectFont
+       }
+       label $base.linfo \
+               -anchor w  \
+               -relief groove -text {Database field} -textvariable PgAcVar(report,info) 
+       label $base.llal \
+               -borderwidth 0 -text Align 
+       button $base.balign \
+               -borderwidth 0 -command Reports::toggleAlignMode \
+               -relief groove -text right 
+       button $base.savebtn \
+               -borderwidth 1 -command Reports::save \
+               -text [intlmsg Save]
+       label $base.lfn \
+               -borderwidth 0 -text Font 
+       button $base.bfont \
+               -borderwidth 0 \
+               -command Reports::setFont \
+               -relief groove -text Courier 
+       button $base.bdd \
+               -borderwidth 1 \
+               -command {if {[winfo exists .pgaw:ReportBuilder.ddf]} {
+       destroy .pgaw:ReportBuilder.ddf
+} else {
+       create_drop_down .pgaw:ReportBuilder 405 22 200
+       focus .pgaw:ReportBuilder.ddf.sb
+       foreach tbl [Database::getTablesList] {.pgaw:ReportBuilder.ddf.lb insert end $tbl}
+       bind .pgaw:ReportBuilder.ddf.lb <ButtonRelease-1> {
+               set i [.pgaw:ReportBuilder.ddf.lb curselection]
+               if {$i!=""} {set PgAcVar(report,tablename) [.pgaw:ReportBuilder.ddf.lb get $i]}
+               destroy .pgaw:ReportBuilder.ddf
+               Reports::getSourceFields
+               break
+       }
+}} \
+               -highlightthickness 0 -image dnarw 
+       label $base.lrn \
+               -borderwidth 0 -text [intlmsg {Report name}]
+       entry $base.ern \
+               -background #fefefe -borderwidth 1 -highlightthickness 0 \
+               -textvariable PgAcVar(report,reportname) 
+       bind $base.ern <Key-F5> {
+               loadReport
+       }
+       label $base.lrs \
+               -borderwidth 0 -text [intlmsg {Report source}]
+       label $base.ls \
+               -borderwidth 1 -relief raised 
+       entry $base.ef \
+               -background #fefefe -borderwidth 1 -highlightthickness 0 \
+               -textvariable PgAcVar(report,formula) 
+       button $base.baf \
+               -borderwidth 1 \
+               -text [intlmsg {Add formula}]
+       place $base.l1 \
+               -x 5 -y 55 -width 131 -height 18 -anchor nw -bordermode ignore 
+       place $base.lb \
+               -x 5 -y 70 -width 118 -height 121 -anchor nw -bordermode ignore 
+       place $base.c \
+               -x 140 -y 75 -width 508 -height 345 -anchor nw -bordermode ignore 
+       place $base.bt2 \
+               -x 5 -y 365 -width 64 -height 26 -anchor nw -bordermode ignore 
+       place $base.bt4 \
+               -x 70 -y 365 -width 66 -height 26 -anchor nw -bordermode ignore 
+       place $base.bt5 \
+               -x 70 -y 395 -width 66 -height 26 -anchor nw -bordermode ignore 
+       place $base.sb \
+               -x 120 -y 70 -width 18 -height 122 -anchor nw -bordermode ignore 
+       place $base.lmsg \
+               -x 142 -y 55 -width 151 -height 18 -anchor nw -bordermode ignore 
+       place $base.e2 \
+               -x 405 -y 4 -width 129 -height 18 -anchor nw -bordermode ignore 
+       place $base.elab \
+               -x 5 -y 225 -width 130 -height 18 -anchor nw -bordermode ignore 
+       place $base.badl \
+               -x 5 -y 243 -width 132 -height 26 -anchor nw -bordermode ignore 
+       place $base.lbold \
+               -x 535 -y 55 -width 18 -height 18 -anchor nw -bordermode ignore 
+       place $base.lita \
+               -x 555 -y 55 -width 18 -height 18 -anchor nw -bordermode ignore 
+       place $base.eps \
+               -x 500 -y 55 -width 30 -height 18 -anchor nw -bordermode ignore 
+       place $base.linfo \
+               -x 295 -y 55 -width 91 -height 18 -anchor nw -bordermode ignore 
+       place $base.llal \
+               -x 575 -y 56 -anchor nw -bordermode ignore 
+       place $base.balign \
+               -x 610 -y 54 -width 35 -height 21 -anchor nw -bordermode ignore 
+       place $base.savebtn \
+               -x 5 -y 395 -width 64 -height 26 -anchor nw -bordermode ignore 
+       place $base.lfn \
+               -x 405 -y 56 -anchor nw -bordermode ignore 
+       place $base.bfont \
+               -x 435 -y 54 -width 65 -height 21 -anchor nw -bordermode ignore 
+       place $base.bdd \
+               -x 535 -y 4 -width 15 -height 20 -anchor nw -bordermode ignore 
+       place $base.lrn \
+               -x 5 -y 5 -anchor nw -bordermode ignore 
+       place $base.ern \
+               -x 80 -y 4 -width 219 -height 18 -anchor nw -bordermode ignore 
+       place $base.lrs \
+               -x 320 -y 5 -anchor nw -bordermode ignore 
+       place $base.ls \
+               -x 5 -y 30 -width 641 -height 2 -anchor nw -bordermode ignore 
+       place $base.ef \
+               -x 5 -y 280 -width 130 -height 18 -anchor nw -bordermode ignore 
+       place $base.baf \
+               -x 5 -y 298 -width 132 -height 26 -anchor nw -bordermode ignore 
+}
+
+proc vTclWindow.pgaw:ReportPreview {base} {
+       if {$base == ""} {
+               set base .pgaw:ReportPreview
+       }
+       if {[winfo exists $base]} {
+               wm deiconify $base; return
+       }
+       toplevel $base -class Toplevel
+       wm focusmodel $base passive
+       wm geometry $base 495x500+230+50
+       wm maxsize $base 1009 738
+       wm minsize $base 1 1
+       wm overrideredirect $base 0
+       wm resizable $base 1 1
+       wm title $base "Report preview"
+       frame $base.fr \
+               -borderwidth 2 -height 75 -relief groove -width 125 
+       canvas $base.fr.c \
+               -background #fcfefe -borderwidth 2 -height 207 -relief ridge \
+               -scrollregion {0 0 1000 824} -width 295 \
+               -yscrollcommand {.pgaw:ReportPreview.fr.sb set} 
+       scrollbar $base.fr.sb \
+               -borderwidth 1 -command {.pgaw:ReportPreview.fr.c yview} -highlightthickness 0 \
+               -orient vert -width 12 
+       frame $base.f1 \
+               -borderwidth 2 -height 75 -width 125 
+       button $base.f1.button18 \
+               -borderwidth 1 -command {if {$PgAcVar(report,justpreview)} then {Window destroy .pgaw:ReportBuilder} ; Window destroy .pgaw:ReportPreview} \
+               -text [intlmsg Close] 
+       button $base.f1.button17 \
+               -borderwidth 1 -command Reports::print \
+               -text Print 
+       pack $base.fr \
+               -in .pgaw:ReportPreview -anchor center -expand 1 -fill both -side top 
+       pack $base.fr.c \
+               -in .pgaw:ReportPreview.fr -anchor center -expand 1 -fill both -side left 
+       pack $base.fr.sb \
+               -in .pgaw:ReportPreview.fr -anchor center -expand 0 -fill y -side right 
+       pack $base.f1 \
+               -in .pgaw:ReportPreview -anchor center -expand 0 -fill none -side top 
+       pack $base.f1.button18 \
+               -in .pgaw:ReportPreview.f1 -anchor center -expand 0 -fill none -side right 
+       pack $base.f1.button17 \
+               -in .pgaw:ReportPreview.f1 -anchor center -expand 0 -fill none -side left 
+}
diff --git a/src/bin/pgaccess/lib/schema.tcl b/src/bin/pgaccess/lib/schema.tcl
new file mode 100644 (file)
index 0000000..d3e40ef
--- /dev/null
@@ -0,0 +1,585 @@
+namespace eval Schema {
+
+
+proc {new} {} {
+global PgAcVar
+       init
+       Window show .pgaw:Schema
+       set PgAcVar(schema,oid) 0
+       set PgAcVar(schema,name) {}
+       set PgAcVar(schema,tables) {}
+       set PgAcVar(schema,links) {}
+       set PgAcVar(schema,results) {}
+       focus .pgaw:Schema.f.e
+}
+
+
+proc {open} {obj} {
+global PgAcVar CurrentDB
+       init
+       set PgAcVar(schema,name) $obj
+       if {[set pgres [wpg_exec $CurrentDB "select schematables,schemalinks,oid from pga_schema where schemaname='$PgAcVar(schema,name)'"]]==0} then {
+               showError [intlmsg "Error retrieving schema definition"]
+               return
+       }
+       if {[pg_result $pgres -numTuples]==0} {
+               showError [format [intlmsg "Schema '%s' was not found!"] $PgAcVar(schema,name)]
+               pg_result $pgres -clear
+               return
+       }
+       set tuple [pg_result $pgres -getTuple 0]
+       set tables [lindex $tuple 0]
+       set links [lindex $tuple 1]
+       set PgAcVar(schema,oid) [lindex $tuple 2]
+       pg_result $pgres -clear
+       Window show .pgaw:Schema
+       foreach {t x y} $tables { 
+               set PgAcVar(schema,newtablename) $t
+               addNewTable $x $y
+       }
+       set PgAcVar(schema,links) $links
+       drawLinks
+}
+
+
+proc {addNewTable} {{tabx 0} {taby 0}} {
+global PgAcVar CurrentDB
+
+if {$PgAcVar(schema,newtablename)==""} return
+if {$PgAcVar(schema,newtablename)=="*"} {
+       set tbllist [Database::getTablesList]
+       foreach tn [array names PgAcVar schema,tablename*] {
+               if { [set linkid [lsearch $tbllist $PgAcVar($tn)]] != -1 } {
+                       set tbllist [lreplace $tbllist $linkid $linkid]
+               }
+       }
+       foreach t $tbllist {
+               set PgAcVar(schema,newtablename) $t
+               addNewTable
+       }
+       return
+}
+
+foreach tn [array names PgAcVar schema,tablename*] {
+       if {$PgAcVar(schema,newtablename)==$PgAcVar($tn)} {
+               showError [format [intlmsg "Table '%s' already in schema"] $PgAcVar($tn)]
+               return
+       }
+}
+set fldlist {}
+setCursor CLOCK
+wpg_select $CurrentDB "select attnum,attname,typname from pg_class,pg_attribute,pg_type where (pg_class.relname='$PgAcVar(schema,newtablename)') and (pg_class.oid=pg_attribute.attrelid) and (attnum>0) and (atttypid=pg_type.oid) order by attnum" rec {
+               lappend fldlist $rec(attname) $rec(typname)
+}
+setCursor DEFAULT
+if {$fldlist==""} {
+       showError [format [intlmsg "Table '%s' not found!"] $PgAcVar(schema,newtablename)]
+       return
+}
+set PgAcVar(schema,tablename$PgAcVar(schema,ntables)) $PgAcVar(schema,newtablename)
+set PgAcVar(schema,tablestruct$PgAcVar(schema,ntables)) $fldlist
+set PgAcVar(schema,tablex$PgAcVar(schema,ntables)) $tabx
+set PgAcVar(schema,tabley$PgAcVar(schema,ntables)) $taby
+incr PgAcVar(schema,ntables)
+if {$PgAcVar(schema,ntables)==1} {
+   drawAll
+} else {
+   drawTable [expr $PgAcVar(schema,ntables)-1]
+}
+lappend PgAcVar(schema,tables) $PgAcVar(schema,newtablename)  $PgAcVar(schema,tablex[expr $PgAcVar(schema,ntables)-1]) $PgAcVar(schema,tabley[expr $PgAcVar(schema,ntables)-1])
+set PgAcVar(schema,newtablename) {}
+focus .pgaw:Schema.f.e
+}
+
+proc {drawAll} {} {
+global PgAcVar
+       .pgaw:Schema.c delete all
+       for {set it 0} {$it<$PgAcVar(schema,ntables)} {incr it} {
+               drawTable $it
+       }
+       .pgaw:Schema.c lower rect
+       drawLinks
+
+       .pgaw:Schema.c bind mov <Button-1> {Schema::dragStart %W %x %y}
+       .pgaw:Schema.c bind mov <B1-Motion> {Schema::dragMove %W %x %y}
+       bind .pgaw:Schema.c <ButtonRelease-1> {Schema::dragStop %x %y}
+       bind .pgaw:Schema <Button-1> {Schema::canvasClick %x %y %W}
+       bind .pgaw:Schema <B1-Motion> {Schema::canvasPanning %x %y}
+       bind .pgaw:Schema <Key-Delete> {Schema::deleteObject}
+}
+
+
+proc {drawTable} {it} {
+global PgAcVar
+
+if {$PgAcVar(schema,tablex$it)==0} {
+       set posy $PgAcVar(schema,nexty)
+       set posx $PgAcVar(schema,nextx)
+       set PgAcVar(schema,tablex$it) $posx
+       set PgAcVar(schema,tabley$it) $posy
+} else {
+       set posx [expr int($PgAcVar(schema,tablex$it))]
+       set posy [expr int($PgAcVar(schema,tabley$it))]
+}
+set tablename $PgAcVar(schema,tablename$it)
+.pgaw:Schema.c create text $posx $posy -text "$tablename" -anchor nw -tags [subst {tab$it f-oid mov tableheader}] -font $PgAcVar(pref,font_bold)
+incr posy 16
+foreach {fld ftype} $PgAcVar(schema,tablestruct$it) {
+   if {[set cindex [lsearch $PgAcVar(pref,typelist) $ftype]] == -1} {set cindex 1}
+   .pgaw:Schema.c create text $posx $posy -text $fld -fill [lindex $PgAcVar(pref,typecolors) $cindex] -anchor nw -tags [subst {f-$fld tab$it mov}] -font $PgAcVar(pref,font_normal)
+   incr posy 14
+}
+set reg [.pgaw:Schema.c bbox tab$it]
+.pgaw:Schema.c create rectangle [lindex $reg 0] [lindex $reg 1] [lindex $reg 2] [lindex $reg 3] -fill #EEEEEE -tags [subst {rect outer tab$it}]
+.pgaw:Schema.c create line [lindex $reg 0] [expr [lindex $reg 1]+15] [lindex $reg 2] [expr [lindex $reg 1]+15] -tags [subst {rect tab$it}]
+.pgaw:Schema.c lower tab$it
+.pgaw:Schema.c lower rect
+set reg [.pgaw:Schema.c bbox tab$it]
+
+
+set nexty [lindex $reg 1]
+set nextx [expr 20+[lindex $reg 2]]
+if {$nextx > [winfo width .pgaw:Schema.c] } {
+       set nextx 10
+       set allbox [.pgaw:Schema.c bbox rect]
+       set nexty [expr 20 + [lindex $allbox 3]]
+}
+set PgAcVar(schema,nextx) $nextx
+set PgAcVar(schema,nexty) $nexty
+
+}
+
+proc {deleteObject} {} {
+global PgAcVar
+# Checking if there 
+set obj [.pgaw:Schema.c find withtag hili]
+if {$obj==""} return
+# Is object a link ?
+if {[getTagInfo $obj link]=="s"} {
+       if {[tk_messageBox -title [intlmsg Warning] -icon question -parent .pgaw:Schema -message [intlmsg "Remove link ?"] -type yesno -default no]=="no"} return
+       set linkid [getTagInfo $obj lkid]
+       set PgAcVar(schema,links) [lreplace $PgAcVar(schema,links) $linkid $linkid]
+       .pgaw:Schema.c delete links
+       drawLinks
+       return
+}
+# Is object a table ?
+set tablealias [getTagInfo $obj tab]
+set tablename $PgAcVar(schema,tablename$tablealias)
+if {"$tablename"==""} return
+if {[tk_messageBox -title [intlmsg Warning] -icon question -parent .pgaw:Schema -message [format [intlmsg "Remove table %s from query?"] $tablename] -type yesno -default no]=="no"} return
+for {set i [expr [llength $PgAcVar(schema,links)]-1]} {$i>=0} {incr i -1} {
+       set thelink [lindex $PgAcVar(schema,links) $i]
+       if {($tablealias==[lindex $thelink 0]) || ($tablealias==[lindex $thelink 2])} {
+               set PgAcVar(schema,links) [lreplace $PgAcVar(schema,links) $i $i]
+       }
+}
+for {set i 0} {$i<$PgAcVar(schema,ntables)} {incr i} {
+       set temp {}
+       catch {set temp $PgAcVar(schema,tablename$i)}
+       if {"$temp"=="$tablename"} {
+               unset PgAcVar(schema,tablename$i)
+               unset PgAcVar(schema,tablestruct$i)
+               break
+       }
+}
+#incr PgAcVar(schema,ntables) -1
+.pgaw:Schema.c delete tab$tablealias
+.pgaw:Schema.c delete links
+drawLinks
+}
+
+
+proc {dragMove} {w x y} {
+global PgAcVar
+       if {"$PgAcVar(draginfo,obj)" == ""} {return}
+       set dx [expr $x - $PgAcVar(draginfo,x)]
+       set dy [expr $y - $PgAcVar(draginfo,y)]
+       if {$PgAcVar(draginfo,is_a_table)} {
+               $w move $PgAcVar(draginfo,tabletag) $dx $dy
+               drawLinks
+       } else {
+               $w move $PgAcVar(draginfo,obj) $dx $dy
+       }
+       set PgAcVar(draginfo,x) $x
+       set PgAcVar(draginfo,y) $y
+}
+
+
+proc {dragStart} {w x y} {
+global PgAcVar
+PgAcVar:clean draginfo,*
+set PgAcVar(draginfo,obj) [$w find closest $x $y]
+if {[getTagInfo $PgAcVar(draginfo,obj) r]=="ect"} {
+       # If it'a a rectangle, exit
+       set PgAcVar(draginfo,obj) {}
+       return
+}
+.pgaw:Schema configure -cursor hand1
+.pgaw:Schema.c raise $PgAcVar(draginfo,obj)
+set PgAcVar(draginfo,table) 0
+if {[getTagInfo $PgAcVar(draginfo,obj) table]=="header"} {
+       set PgAcVar(draginfo,is_a_table) 1
+       set taglist [.pgaw:Schema.c gettags $PgAcVar(draginfo,obj)]
+       set PgAcVar(draginfo,tabletag) [lindex $taglist [lsearch -regexp $taglist "^tab\[0-9\]*"]]
+       .pgaw:Schema.c raise $PgAcVar(draginfo,tabletag)
+       .pgaw:Schema.c itemconfigure [.pgaw:Schema.c find withtag hili] -fill black
+       .pgaw:Schema.c dtag [.pgaw:Schema.c find withtag hili] hili
+       .pgaw:Schema.c addtag hili withtag $PgAcVar(draginfo,obj)
+       .pgaw:Schema.c itemconfigure hili -fill blue
+} else {
+       set PgAcVar(draginfo,is_a_table) 0
+}
+set PgAcVar(draginfo,x) $x
+set PgAcVar(draginfo,y) $y
+set PgAcVar(draginfo,sx) $x
+set PgAcVar(draginfo,sy) $y
+}
+
+proc {dragStop} {x y} {
+global PgAcVar
+# when click Close, schema window is destroyed but event ButtonRelease-1 is fired
+if {![winfo exists .pgaw:Schema]} return;
+.pgaw:Schema configure -cursor left_ptr
+set este {}
+catch {set este $PgAcVar(draginfo,obj)}
+if {$este==""} return
+# Re-establish the normal paint order so
+# information won't be overlapped by table rectangles
+# or link lines
+.pgaw:Schema.c lower $PgAcVar(draginfo,obj)
+.pgaw:Schema.c lower rect
+.pgaw:Schema.c lower links
+set PgAcVar(schema,panstarted) 0
+if {$PgAcVar(draginfo,is_a_table)} {
+       set tabnum [getTagInfo $PgAcVar(draginfo,obj) tab]
+       foreach w [.pgaw:Schema.c find withtag $PgAcVar(draginfo,tabletag)] {
+               if {[lsearch [.pgaw:Schema.c gettags $w] outer] != -1} {
+                       foreach [list PgAcVar(schema,tablex$tabnum) PgAcVar(schema,tabley$tabnum) x1 y1] [.pgaw:Schema.c coords $w] {}
+                       break
+               }
+       }
+       set PgAcVar(draginfo,obj) {}
+       .pgaw:Schema.c delete links
+       drawLinks
+       return
+} 
+# not a table
+.pgaw:Schema.c move $PgAcVar(draginfo,obj) [expr $PgAcVar(draginfo,sx)-$x] [expr $PgAcVar(draginfo,sy)-$y]
+set droptarget [.pgaw:Schema.c find overlapping $x $y $x $y]
+set targettable {}
+foreach item $droptarget {
+       set targettable $PgAcVar(schema,tablename[getTagInfo $item tab])
+       set targetfield [getTagInfo $item f-]
+       if {($targettable!="") && ($targetfield!="")} {
+               set droptarget $item
+               break
+       }
+}
+# check if target object isn't a rectangle
+if {[getTagInfo $droptarget rec]=="t"} {set targettable {}}
+if {$targettable!=""} {
+       # Target has a table
+       # See about originate table
+       set sourcetable $PgAcVar(schema,tablename[getTagInfo $PgAcVar(draginfo,obj) tab])
+       if {$sourcetable!=""} {
+               # Source has also a tab .. tag
+               set sourcefield [getTagInfo $PgAcVar(draginfo,obj) f-]
+               if {$sourcetable!=$targettable} {
+                       lappend PgAcVar(schema,links) [list $sourcetable $sourcefield $targettable $targetfield]
+                       drawLinks
+               }
+       }
+}
+# Erase information about object beeing dragged
+set PgAcVar(draginfo,obj) {}
+}
+
+proc {drawLinks} {} {
+global PgAcVar
+.pgaw:Schema.c delete links
+set i 0
+foreach link $PgAcVar(schema,links) {
+       set sourcenum -1
+       set targetnum -1
+       # Compute the source and destination right edge
+       foreach t [array names PgAcVar schema,tablename*] {
+               if {[regexp "^$PgAcVar($t)$" [lindex $link 0] ]} {
+                       set sourcenum [string range $t 16 end]
+               } elseif {[regexp "^$PgAcVar($t)$" [lindex $link 2] ]} {
+                       set targetnum [string range $t 16 end]
+               } 
+       }       
+       set sb [findField $sourcenum [lindex $link 1]]
+       set db [findField $targetnum [lindex $link 3]]
+       if {($sourcenum == -1 )||($targetnum == -1)||($sb ==-1)||($db==-1)} { 
+               set PgAcVar(schema,links) [lreplace $PgAcVar(schema,links) $i $i]
+               showError "Link from [lindex $link 0].[lindex $link 1] to [lindex $link 2].[lindex $link 3] not found!"
+       } else {
+
+               set sre [lindex [.pgaw:Schema.c bbox tab$sourcenum] 2]
+               set dre [lindex [.pgaw:Schema.c bbox tab$targetnum] 2]
+               # Compute field bound boxes
+               set sbbox [.pgaw:Schema.c bbox $sb]
+               set dbbox [.pgaw:Schema.c bbox $db]
+               # Compute the auxiliary lines
+               if {[lindex $sbbox 2] < [lindex $dbbox 0]} {
+                       # Source object is on the left of target object
+                       set x1 $sre
+                       set y1 [expr ([lindex $sbbox 1]+[lindex $sbbox 3])/2]
+                       .pgaw:Schema.c create line $x1 $y1 [expr $x1+10] $y1 \
+                               -tags [subst {links lkid$i}] -width 3
+                       set x2 [lindex $dbbox 0]
+                       set y2 [expr ([lindex $dbbox 1]+[lindex $dbbox 3])/2]
+                       .pgaw:Schema.c create line [expr $x2-10] $y2 $x2 $y2 \
+                               -tags [subst {links lkid$i}] -width 3
+                       .pgaw:Schema.c create line [expr $x1+10] $y1 [expr $x2-10] $y2 \
+                               -tags [subst {links lkid$i}] -width 2
+               } else {
+                       # source object is on the right of target object
+                       set x1 [lindex $sbbox 0]
+                       set y1 [expr ([lindex $sbbox 1]+[lindex $sbbox 3])/2]
+                       .pgaw:Schema.c create line $x1 $y1 [expr $x1-10] $y1 \
+                               -tags [subst {links lkid$i}] -width 3
+                       set x2 $dre
+                       set y2 [expr ([lindex $dbbox 1]+[lindex $dbbox 3])/2]
+                       .pgaw:Schema.c create line $x2 $y2 [expr $x2+10] $y2 -width 3 \
+                               -tags [subst {links lkid$i}]
+                       .pgaw:Schema.c create line [expr $x1-10] $y1 [expr $x2+10] $y2 \
+                               -tags [subst {links lkid$i}] -width 2
+               }
+               incr i
+       }
+}
+.pgaw:Schema.c lower links
+.pgaw:Schema.c bind links <Button-1> {Schema::linkClick %x %y}
+}
+
+
+proc {getSchemaTabless} {} {
+global PgAcVar
+       set tablelist {}
+       foreach key [array names PgAcVar schema,tablename*] {
+               regsub schema,tablename $key "" num
+               lappend tablelist $PgAcVar($key) $PgAcVar(schema,tablex$num) $PgAcVar(schema,tabley$num)
+       }
+       return $tablelist
+}
+
+
+proc {findField} {alias field} {
+foreach obj [.pgaw:Schema.c find withtag f-${field}] {
+       if {[lsearch [.pgaw:Schema.c gettags $obj] tab$alias] != -1} {return $obj}
+       }
+return -1
+}
+
+
+proc {addLink} {sourcetable sourcefield targettable targetfield} {
+global PgAcVar
+       lappend PgAcVar(schema,links) [list $sourcetable $sourcefield $targettable $targetfield]
+}
+
+
+proc {getTagInfo} {obj prefix} {
+       set taglist [.pgaw:Schema.c gettags $obj]
+       set tagpos [lsearch -regexp $taglist "^$prefix"]
+       if {$tagpos==-1} {return ""}
+       set thattag [lindex $taglist $tagpos]
+       return [string range $thattag [string length $prefix] end]
+}
+
+
+proc {init} {} {
+global PgAcVar
+       PgAcVar:clean schema,*
+       set PgAcVar(schema,nexty) 10
+       set PgAcVar(schema,nextx) 10
+       set PgAcVar(schema,links) {}
+       set PgAcVar(schema,ntables) 0
+       set PgAcVar(schema,newtablename) {}
+}
+
+
+proc {linkClick} {x y} {
+global PgAcVar
+       set obj [.pgaw:Schema.c find closest $x $y 1 links]
+       if {[getTagInfo $obj link]!="s"} return
+       .pgaw:Schema.c itemconfigure [.pgaw:Schema.c find withtag hili] -fill black
+       .pgaw:Schema.c dtag [.pgaw:Schema.c find withtag hili] hili
+       .pgaw:Schema.c addtag hili withtag $obj
+       .pgaw:Schema.c itemconfigure $obj -fill blue
+}
+
+
+proc {canvasPanning} {x y} {
+global PgAcVar
+       set panstarted 0
+       catch {set panstarted $PgAcVar(schema,panstarted) }
+       if {!$panstarted} return
+       set dx [expr $x-$PgAcVar(schema,panstartx)]
+       set dy [expr $y-$PgAcVar(schema,panstarty)]
+       set PgAcVar(schema,panstartx) $x
+       set PgAcVar(schema,panstarty) $y
+       if {$PgAcVar(schema,panobject)=="tables"} {
+               .pgaw:Schema.c move mov $dx $dy
+               .pgaw:Schema.c move links $dx $dy
+               .pgaw:Schema.c move rect $dx $dy
+       } else {
+               .pgaw:Schema.c move resp $dx 0
+               .pgaw:Schema.c move resgrid $dx 0
+               .pgaw:Schema.c raise reshdr
+       }
+}
+
+
+proc print {c} {
+       set types {
+               {{Postscript Files}     {.ps}}
+               {{All Files}    *}
+       }
+       if {[catch {tk_getSaveFile -defaultextension .ps -filetypes $types \
+                               -title "Print to Postscript"} fn] || [string match {} $fn]} return
+       if {[catch {::open $fn "w" } fid]} {
+               return -code error "Save Error: Unable to open '$fn' for writing\n$fid"
+       }
+       puts $fid [$c postscript -rotate 1]
+       close $fid
+}
+
+
+proc {canvasClick} {x y w} {
+global PgAcVar
+set PgAcVar(schema,panstarted) 0
+if {$w==".pgaw:Schema.c"} {
+       set canpan 1
+       if {[llength [.pgaw:Schema.c find overlapping $x $y $x $y]]!=0} {set canpan 0}
+       set PgAcVar(schema,panobject) tables
+       if {$canpan} {
+               if {[.pgaw:Schema.c find withtag hili]!=""} {
+                       .pgaw:Schema.c itemconfigure [.pgaw:Schema.c find withtag hili] -fill black
+                       .pgaw:Schema.c dtag [.pgaw:Schema.c find withtag hili] hili
+               }
+
+               .pgaw:Schema configure -cursor hand1
+               set PgAcVar(schema,panstartx) $x
+               set PgAcVar(schema,panstarty) $y
+               set PgAcVar(schema,panstarted) 1
+       }
+}
+}
+
+}
+
+proc vTclWindow.pgaw:Schema {base} {
+global PgAcVar
+       if {$base == ""} {
+               set base .pgaw:Schema
+       }
+       if {[winfo exists $base]} {
+               wm deiconify $base; return
+       }
+       toplevel $base -class Toplevel
+       wm focusmodel $base passive
+       wm geometry $base 759x530+10+13
+       wm maxsize $base 1009 738
+       wm minsize $base 1 1
+       wm overrideredirect $base 0
+       wm resizable $base 1 1
+       wm title $base [intlmsg "Visual schema designer"]
+       bind $base <B1-Motion> {
+               Schema::canvasPanning %x %y
+       }
+       bind $base <Button-1> {
+               Schema::canvasClick %x %y %W
+       }
+       bind $base <ButtonRelease-1> {
+               Schema::dragStop %x %y
+       }
+       bind $base <Key-Delete> {
+               Schema::deleteObject
+       }
+       canvas $base.c  -background #fefefe -borderwidth 2 -height 207 -relief ridge  -takefocus 0 -width 295 
+       frame $base.f \
+        -height 75 -relief groove -width 125 
+       label $base.f.l -text [intlmsg {Add table}]
+       entry $base.f.e \
+        -background #fefefe -borderwidth 1 
+       bind $base.f.e <Key-Return> {
+               Schema::addNewTable
+    }
+       button $base.f.bdd \
+        -image dnarw \
+        -command {if {[winfo exists .pgaw:Schema.ddf]} {
+       destroy .pgaw:Schema.ddf
+} else {
+       create_drop_down .pgaw:Schema 70 27 200
+       focus .pgaw:Schema.ddf.sb
+       foreach tbl [Database::getTablesList] {.pgaw:Schema.ddf.lb insert end $tbl}
+       bind .pgaw:Schema.ddf.lb <ButtonRelease-1> {
+               set i [.pgaw:Schema.ddf.lb curselection]
+               if {$i!=""} {
+                       set PgAcVar(schema,newtablename) [.pgaw:Schema.ddf.lb get $i]
+                       Schema::addNewTable
+               }
+               destroy .pgaw:Schema.ddf
+               break
+       }
+}} \
+        -padx 1 -pady 1 
+       button $base.f.btnclose \
+               -command {Schema::init
+Window destroy .pgaw:Schema} -padx 2 -pady 3 -text [intlmsg Close]
+       button $base.f.printbtn \
+               -command {Schema::print .pgaw:Schema.c} -padx 1 -pady 3 -text [intlmsg Print]
+       button $base.f.btnsave \
+               -command {if {$PgAcVar(schema,name)==""} then {
+       showError [intlmsg "You have to supply a name for this schema!"]
+       focus .pgaw:Schema.f.esn
+} else {
+       setCursor CLOCK
+       set tables [Schema::getSchemaTabless]
+       if {$PgAcVar(schema,oid)==0} then {
+               set pgres [wpg_exec $CurrentDB "insert into pga_schema values ('$PgAcVar(schema,name)','$tables','$PgAcVar(schema,links)')"]
+       } else {
+               set pgres [wpg_exec $CurrentDB "update pga_schema set schemaname='$PgAcVar(schema,name)',schematables='$tables',schemalinks='$PgAcVar(schema,links)' where oid=$PgAcVar(schema,oid)"]
+       }
+       setCursor DEFAULT
+       if {$PgAcVar(pgsql,status)!="PGRES_COMMAND_OK"} then {
+               showError "[intlmsg {Error executing query}]\n$PgAcVar(pgsql,errmsg)"
+       } else {
+               Mainlib::tab_click Schema
+               if {$PgAcVar(schema,oid)==0} {set PgAcVar(schema,oid) [pg_result $pgres -oid]}
+       }
+       catch {pg_result $pgres -clear}
+}} \
+               -padx 2 -pady 3 -text [intlmsg {Save schema}]
+       label $base.f.ls1 -text {  } 
+       entry $base.f.esn \
+               -background #fefefe -borderwidth 1 -textvariable PgAcVar(schema,name) 
+       label $base.f.lsn -text [intlmsg {Schema name}]
+       place $base.c  -x 5 -y 30 -width 748 -height 500 -anchor nw -bordermode ignore 
+       place $base.f \
+               -x 5 -y 5 -width 748 -height 25 -anchor nw -bordermode ignore 
+       pack $base.f.l \
+               -in .pgaw:Schema.f -anchor center -expand 0 -fill none -side left 
+       pack $base.f.e \
+               -in .pgaw:Schema.f -anchor center -expand 0 -fill none -side left 
+       pack $base.f.bdd \
+               -in .pgaw:Schema.f -anchor center -expand 0 -fill none -side left 
+       pack $base.f.btnclose \
+               -in .pgaw:Schema.f -anchor center -expand 0 -fill none -side right 
+       pack $base.f.printbtn \
+               -in .pgaw:Schema.f -anchor center -expand 0 -fill none -side right 
+       pack $base.f.btnsave \
+               -in .pgaw:Schema.f -anchor center -expand 0 -fill none -side right 
+       pack $base.f.ls1 \
+               -in .pgaw:Schema.f -anchor center -expand 0 -fill none -side right 
+       pack $base.f.esn \
+               -in .pgaw:Schema.f -anchor center -expand 0 -fill none -side right 
+       pack $base.f.lsn \
+               -in .pgaw:Schema.f -anchor center -expand 0 -fill none -side right 
+
+}
+
+
diff --git a/src/bin/pgaccess/lib/scripts.tcl b/src/bin/pgaccess/lib/scripts.tcl
new file mode 100644 (file)
index 0000000..0302e1f
--- /dev/null
@@ -0,0 +1,88 @@
+namespace eval Scripts {
+
+proc {new} {} {
+       design {}
+}
+
+
+proc {open} {scriptname} {
+global CurrentDB
+       set ss {}
+       wpg_select $CurrentDB "select * from pga_scripts where scriptname='$scriptname'" rec {
+               set ss $rec(scriptsource)
+       }
+       if {[string length $ss] > 0} {
+               eval $ss
+       }
+}
+
+
+proc {design} {scriptname} {
+global PgAcVar CurrentDB
+       Window show .pgaw:Scripts
+       set PgAcVar(script,name) $scriptname
+       .pgaw:Scripts.src delete 1.0 end
+       if {[string length $scriptname]==0} return;
+       wpg_select $CurrentDB "select * from pga_scripts where scriptname='$scriptname'" rec {
+               .pgaw:Scripts.src insert end $rec(scriptsource)    
+       }
+}
+
+
+proc {execute} {scriptname} {
+       # a wrap for execute command
+       open $scriptname
+}
+
+
+proc {save} {} {
+global PgAcVar
+       if {$PgAcVar(script,name)==""} {
+               tk_messageBox -title [intlmsg Warning] -parent .pgaw:Scripts -message [intlmsg "The script must have a name!"]
+       } else {
+          sql_exec noquiet "delete from pga_scripts where scriptname='$PgAcVar(script,name)'"
+          regsub -all {\\} [.pgaw:Scripts.src get 1.0 end] {\\\\} PgAcVar(script,body)
+          regsub -all ' $PgAcVar(script,body)  \\' PgAcVar(script,body)
+          sql_exec noquiet "insert into pga_scripts values ('$PgAcVar(script,name)','$PgAcVar(script,body)')"
+          Mainlib::tab_click Scripts
+       }
+}
+
+}
+
+
+########################## END OF NAMESPACE SCRIPTS ##################
+
+proc vTclWindow.pgaw:Scripts {base} {
+global PgAcVar
+       if {$base == ""} {
+               set base .pgaw:Scripts
+       }
+       if {[winfo exists $base]} {
+               wm deiconify $base; return
+       }
+       toplevel $base -class Toplevel
+       wm focusmodel $base passive
+       wm geometry $base 594x416+192+152
+       wm maxsize $base 1009 738
+       wm minsize $base 300 300
+       wm overrideredirect $base 0
+       wm resizable $base 1 1
+       wm title $base [intlmsg "Design script"]
+       frame $base.f1  -height 55 -relief groove -width 125 
+       label $base.f1.l1  -borderwidth 0 -text [intlmsg {Script name}]
+       entry $base.f1.e1  -background #fefefe -borderwidth 1 -highlightthickness 0 -textvariable PgAcVar(script,name) -width 32 
+       text $base.src -background #fefefe -foreground #000000 -font $PgAcVar(pref,font_normal) -height 2  -highlightthickness 1 -selectborderwidth 0 -width 2 
+       frame $base.f2  -height 75 -relief groove -width 125 
+       button $base.f2.b1  -borderwidth 1 -command {Window destroy .pgaw:Scripts} -text [intlmsg Cancel]
+       button $base.f2.b2  -borderwidth 1  -command Scripts::save \
+               -text [intlmsg Save] -width 6 
+       pack $base.f1  -in .pgaw:Scripts -anchor center -expand 0 -fill x -pady 2 -side top 
+       pack $base.f1.l1  -in .pgaw:Scripts.f1 -anchor center -expand 0 -fill none -ipadx 2 -side left 
+       pack $base.f1.e1  -in .pgaw:Scripts.f1 -anchor center -expand 0 -fill none -side left 
+       pack $base.src  -in .pgaw:Scripts -anchor center -expand 1 -fill both -padx 2 -side top 
+       pack $base.f2  -in .pgaw:Scripts -anchor center -expand 0 -fill none -side top 
+       pack $base.f2.b1  -in .pgaw:Scripts.f2 -anchor center -expand 0 -fill none -side right 
+       pack $base.f2.b2  -in .pgaw:Scripts.f2 -anchor center -expand 0 -fill none -side right
+}
+
diff --git a/src/bin/pgaccess/lib/sequences.tcl b/src/bin/pgaccess/lib/sequences.tcl
new file mode 100644 (file)
index 0000000..834eaab
--- /dev/null
@@ -0,0 +1,159 @@
+namespace eval Sequences {
+
+proc {new} {} {
+global PgAcVar
+       Window show .pgaw:Sequence
+       set PgAcVar(seq,name) {}
+       set PgAcVar(seq,incr) 1
+       set PgAcVar(seq,start) 1
+       set PgAcVar(seq,minval) 1
+       set PgAcVar(seq,maxval) 2147483647
+       focus .pgaw:Sequence.f1.e1
+}
+
+proc {open} {seqname} {
+global PgAcVar CurrentDB
+Window show .pgaw:Sequence
+set flag 1
+wpg_select $CurrentDB "select * from \"$seqname\"" rec {
+       set flag 0
+       set PgAcVar(seq,name) $seqname
+       set PgAcVar(seq,incr) $rec(increment_by)
+       set PgAcVar(seq,start) $rec(last_value)
+       .pgaw:Sequence.f1.l3 configure -text [intlmsg "Last value"]
+       set PgAcVar(seq,minval) $rec(min_value)
+       set PgAcVar(seq,maxval) $rec(max_value)
+       .pgaw:Sequence.fb.btnsave configure -state disabled
+}
+if {$flag} {
+       showError [format [intlmsg "Sequence '%s' not found!"] $seqname]
+} else {
+       for {set i 1} {$i<6} {incr i} {
+               .pgaw:Sequence.f1.e$i configure -state disabled
+       }
+       focus .pgaw:Sequence.fb.btncancel
+}
+}
+
+proc {save} {} {
+global PgAcVar
+       if {$PgAcVar(seq,name)==""} {
+               showError [intlmsg "You should supply a name for this sequence"]
+       } else {
+               set s1 {};set s2 {};set s3 {};set s4 {};
+               if {$PgAcVar(seq,incr)!=""} {set s1 "increment $PgAcVar(seq,incr)"};
+               if {$PgAcVar(seq,start)!=""} {set s2 "start $PgAcVar(seq,start)"};
+               if {$PgAcVar(seq,minval)!=""} {set s3 "minvalue $PgAcVar(seq,minval)"};
+               if {$PgAcVar(seq,maxval)!=""} {set s4 "maxvalue $PgAcVar(seq,maxval)"};
+               set sqlcmd "create sequence \"$PgAcVar(seq,name)\" $s1 $s2 $s3 $s4"
+               if {[sql_exec noquiet $sqlcmd]} {
+                       Mainlib::cmd_Sequences
+                       tk_messageBox -title [intlmsg Information] -parent .pgaw:Sequence -message [intlmsg "Sequence created!"]
+               }
+       }
+}
+
+}
+
+proc vTclWindow.pgaw:Sequence {base} {
+       if {$base == ""} {
+               set base .pgaw:Sequence
+       }
+       if {[winfo exists $base]} {
+               wm deiconify $base; return
+       }
+       toplevel $base -class Toplevel
+       wm focusmodel $base passive
+       wm geometry $base 283x172+119+210
+       wm maxsize $base 1009 738
+       wm minsize $base 1 1
+       wm overrideredirect $base 0
+       wm resizable $base 0 0
+       wm deiconify $base
+       wm title $base [intlmsg "Sequence"]
+       bind $base <Key-F1> "Help::load sequences"
+       frame $base.f1 \
+               -borderwidth 2 -height 75 -width 125 
+       label $base.f1.l1 \
+               -borderwidth 0 -relief raised -text [intlmsg {Sequence name}]
+       entry $base.f1.e1 \
+               -background #fefefe -borderwidth 1 -textvariable PgAcVar(seq,name) -width 200 
+       bind $base.f1.e1 <Key-KP_Enter> {
+               focus .pgaw:Sequence.f1.e2
+       }
+       bind $base.f1.e1 <Key-Return> {
+               focus .pgaw:Sequence.f1.e2
+       }
+       label $base.f1.l2 \
+               -borderwidth 0 -relief raised -text [intlmsg Increment]
+       entry $base.f1.e2 \
+               -background #fefefe -borderwidth 1 -textvariable PgAcVar(seq,incr) -width 200 
+       bind $base.f1.e2 <Key-Return> {
+               focus .pgaw:Sequence.f1.e3
+       }
+       label $base.f1.l3 \
+               -borderwidth 0 -relief raised -text [intlmsg {Start value}]
+       entry $base.f1.e3 \
+               -background #fefefe -borderwidth 1 -textvariable PgAcVar(seq,start) -width 200 
+       bind $base.f1.e3 <Key-Return> {
+               focus .pgaw:Sequence.f1.e4
+       }
+       label $base.f1.l4 \
+               -borderwidth 0 -relief raised -text [intlmsg Minvalue]
+       entry $base.f1.e4 \
+               -background #fefefe -borderwidth 1 -textvariable PgAcVar(seq,minval) \
+               -width 200 
+       bind $base.f1.e4 <Key-Return> {
+               focus .pgaw:Sequence.f1.e5
+       }
+       label $base.f1.ls2 \
+               -borderwidth 0 -relief raised -text { } 
+       label $base.f1.l5 \
+               -borderwidth 0 -relief raised -text [intlmsg Maxvalue]
+       entry $base.f1.e5 \
+               -background #fefefe -borderwidth 1 -textvariable PgAcVar(seq,maxval) \
+               -width 200 
+       bind $base.f1.e5 <Key-Return> {
+               focus .pgaw:Sequence.fb.btnsave
+       }
+       frame $base.fb \
+               -height 75 -relief groove -width 125 
+       button $base.fb.btnsave \
+               -borderwidth 1 -command Sequences::save \
+               -padx 9 -pady 3 -text [intlmsg {Define sequence}]
+       button $base.fb.btncancel \
+               -borderwidth 1 -command {Window destroy .pgaw:Sequence} \
+               -padx 9 -pady 3 -text [intlmsg Close]
+       place $base.f1 \
+               -x 9 -y 5 -width 265 -height 126 -anchor nw -bordermode ignore 
+       grid columnconf $base.f1 2 -weight 1
+       grid $base.f1.l1 \
+               -in .pgaw:Sequence.f1 -column 0 -row 0 -columnspan 1 -rowspan 1 -sticky w 
+       grid $base.f1.e1 \
+               -in .pgaw:Sequence.f1 -column 2 -row 0 -columnspan 1 -rowspan 1 -pady 2 
+       grid $base.f1.l2 \
+               -in .pgaw:Sequence.f1 -column 0 -row 2 -columnspan 1 -rowspan 1 -sticky w 
+       grid $base.f1.e2 \
+               -in .pgaw:Sequence.f1 -column 2 -row 2 -columnspan 1 -rowspan 1 -pady 2 
+       grid $base.f1.l3 \
+               -in .pgaw:Sequence.f1 -column 0 -row 4 -columnspan 1 -rowspan 1 -sticky w 
+       grid $base.f1.e3 \
+               -in .pgaw:Sequence.f1 -column 2 -row 4 -columnspan 1 -rowspan 1 -pady 2 
+       grid $base.f1.l4 \
+               -in .pgaw:Sequence.f1 -column 0 -row 6 -columnspan 1 -rowspan 1 -sticky w 
+       grid $base.f1.e4 \
+               -in .pgaw:Sequence.f1 -column 2 -row 6 -columnspan 1 -rowspan 1 -pady 2 
+       grid $base.f1.ls2 \
+               -in .pgaw:Sequence.f1 -column 1 -row 0 -columnspan 1 -rowspan 1 
+       grid $base.f1.l5 \
+               -in .pgaw:Sequence.f1 -column 0 -row 7 -columnspan 1 -rowspan 1 -sticky w 
+       grid $base.f1.e5 \
+               -in .pgaw:Sequence.f1 -column 2 -row 7 -columnspan 1 -rowspan 1 -pady 2 
+       place $base.fb \
+               -x 0 -y 135 -width 283 -height 40 -anchor nw -bordermode ignore 
+       grid $base.fb.btnsave \
+               -in .pgaw:Sequence.fb -column 0 -row 0 -columnspan 1 -rowspan 1 -padx 5 
+       grid $base.fb.btncancel \
+               -in .pgaw:Sequence.fb -column 1 -row 0 -columnspan 1 -rowspan 1 -padx 5 
+}
+
diff --git a/src/bin/pgaccess/lib/tables.tcl b/src/bin/pgaccess/lib/tables.tcl
new file mode 100644 (file)
index 0000000..8572312
--- /dev/null
@@ -0,0 +1,2158 @@
+namespace eval Tables {
+
+
+proc {new} {} {
+       PgAcVar:clean nt,*
+       Window show .pgaw:NewTable
+       focus .pgaw:NewTable.etabn
+}
+
+
+proc {open} {tablename {filter ""} {order ""}} {
+global PgAcVar
+       set wn [getNewWindowName]
+       createWindow
+       set PgAcVar(mw,$wn,tablename) $tablename
+       loadLayout $wn $tablename
+       set PgAcVar(mw,$wn,sortfield) $order
+       set PgAcVar(mw,$wn,filter) $filter
+       set PgAcVar(mw,$wn,query) "select oid,\"$tablename\".* from \"$tablename\""
+       set PgAcVar(mw,$wn,updatable) 1
+       set PgAcVar(mw,$wn,isaquery) 0
+       initVariables $wn
+       refreshRecords $wn
+       catch {wm title $wn "$tablename"}
+}
+
+
+proc {design} {tablename} {
+global PgAcVar CurrentDB
+       if {$CurrentDB==""} return;
+       set PgAcVar(tblinfo,tablename) $tablename
+       refreshTableInformation
+}
+
+
+proc {refreshTableInformation} {} {
+global PgAcVar CurrentDB
+       Window show .pgaw:TableInfo
+       wm title .pgaw:TableInfo "[intlmsg {Table information}] : $PgAcVar(tblinfo,tablename)"
+       .pgaw:TableInfo.f1.lb delete 0 end
+       .pgaw:TableInfo.f2.fl.ilb delete 0 end
+       .pgaw:TableInfo.f2.fr.lb delete 0 end
+       .pgaw:TableInfo.f3.plb delete 0 end
+       set PgAcVar(tblinfo,isunique) {}
+       set PgAcVar(tblinfo,isclustered) {}
+       set PgAcVar(tblinfo,indexfields) {}
+       wpg_select $CurrentDB "select attnum,attname,typname,attlen,attnotnull,atttypmod,usename,usesysid,pg_class.oid,relpages,reltuples,relhaspkey,relhasrules,relacl from pg_class,pg_user,pg_attribute,pg_type where (pg_class.relname='$PgAcVar(tblinfo,tablename)') and (pg_class.oid=pg_attribute.attrelid) and (pg_class.relowner=pg_user.usesysid) and (pg_attribute.atttypid=pg_type.oid) order by attnum" rec {
+               set fsize $rec(attlen)
+               set fsize1 $rec(atttypmod)
+               set ftype $rec(typname)
+               if { $fsize=="-1" && $fsize1!="-1" } {
+                       set fsize $rec(atttypmod)
+                       incr fsize -4
+               }
+               if { $fsize1=="-1" && $fsize=="-1" } {
+                       set fsize ""
+               }
+               if {$rec(attnotnull) == "t"} {
+                       set notnull "NOT NULL"
+               } else {
+                       set notnull {}
+               }
+               if {$rec(attnum)>0} {.pgaw:TableInfo.f1.lb insert end [format "%-33.33s %-14.14s %6.6s    %-8.8s" $rec(attname) $ftype $fsize $notnull]}
+               set PgAcVar(tblinfo,owner) $rec(usename)
+               set PgAcVar(tblinfo,tableoid) $rec(oid)
+               set PgAcVar(tblinfo,ownerid) $rec(usesysid)
+               set PgAcVar(tblinfo,f$rec(attnum)) $rec(attname)
+               set PgAcVar(tblinfo,numtuples) $rec(reltuples)
+               set PgAcVar(tblinfo,numpages) $rec(relpages)
+               set PgAcVar(tblinfo,permissions) $rec(relacl)
+               if {$rec(relhaspkey)=="t"} {
+                       set PgAcVar(tblinfo,hasprimarykey) [intlmsg Yes]
+               } else {
+                       set PgAcVar(tblinfo,hasprimarykey) [intlmsg No]
+               }
+               if {$rec(relhasrules)=="t"} {
+                       set PgAcVar(tblinfo,hasrules) [intlmsg Yes]
+               } else {
+                       set PgAcVar(tblinfo,hasrules) [intlmsg No]
+               }
+       }
+       set PgAcVar(tblinfo,indexlist) {}
+       wpg_select $CurrentDB "select oid,indexrelid from pg_index where (pg_class.relname='$PgAcVar(tblinfo,tablename)') and (pg_class.oid=pg_index.indrelid)" rec {
+               lappend PgAcVar(tblinfo,indexlist) $rec(oid)
+               wpg_select $CurrentDB "select relname from pg_class where oid=$rec(indexrelid)" rec1 {
+                       .pgaw:TableInfo.f2.fl.ilb insert end $rec1(relname)
+               }
+       }
+       #
+       # showing permissions
+       set temp $PgAcVar(tblinfo,permissions)
+       regsub "^\{" $temp {} temp
+       regsub "\}$" $temp {} temp
+       regsub -all "\"" $temp {} temp
+       foreach token [split $temp ,] {
+               set oli [split $token =]
+               set uname [lindex $oli 0]
+               set rights [lindex $oli 1]
+               if {$uname == ""} {set uname PUBLIC}
+               set r_select " "
+               set r_update " "
+               set r_insert " "
+               set r_rule   " "
+               if {[string first r $rights] != -1} {set r_select x}
+               if {[string first w $rights] != -1} {set r_update x}
+               if {[string first a $rights] != -1} {set r_insert x}
+               if {[string first R $rights] != -1} {set r_rule   x}
+               #
+               # changing the format of the following line can affect the loadPermissions procedure
+               # see below
+               .pgaw:TableInfo.f3.plb insert end [format "%-23.23s %11s %11s %11s %11s" $uname $r_select $r_update $r_insert $r_rule]
+               
+       }
+}
+
+proc {loadPermissions} {} {
+global PgAcVar
+       set sel [.pgaw:TableInfo.f3.plb curselection]
+       if {$sel == ""} {
+               bell
+               return
+       }
+       set line [.pgaw:TableInfo.f3.plb get $sel]
+       set uname [string trim [string range $line 0 22]]
+       Window show .pgaw:Permissions
+       wm transient .pgaw:Permissions .pgaw:TableInfo
+       set PgAcVar(permission,username) $uname
+       set PgAcVar(permission,select) [expr {"x"==[string range $line 34 34]}]
+       set PgAcVar(permission,update) [expr {"x"==[string range $line 46 46]}]
+       set PgAcVar(permission,insert) [expr {"x"==[string range $line 58 58]}]
+       set PgAcVar(permission,rule)   [expr {"x"==[string range $line 70 70]}]
+       focus .pgaw:Permissions.f1.ename
+}
+
+
+proc {newPermissions} {} {
+global PgAcVar
+       PgAcVar:clean permission,*
+       Window show .pgaw:Permissions
+       wm transient .pgaw:Permissions .pgaw:TableInfo
+       focus .pgaw:Permissions.f1.ename
+}
+
+
+proc {savePermissions} {} {
+global PgAcVar
+       if {$PgAcVar(permission,username) == ""} {
+               showError [intlmsg "User without name?"]
+               return
+       }
+       sql_exec noquiet "revoke all on \"$PgAcVar(tblinfo,tablename)\" from $PgAcVar(permission,username)"
+       if {$PgAcVar(permission,select)} {
+               sql_exec noquiet "GRANT SELECT on \"$PgAcVar(tblinfo,tablename)\" to $PgAcVar(permission,username)"
+       }
+       if {$PgAcVar(permission,insert)} {
+               sql_exec noquiet "GRANT INSERT on \"$PgAcVar(tblinfo,tablename)\" to $PgAcVar(permission,username)"
+       }
+       if {$PgAcVar(permission,update)} {
+               sql_exec noquiet "GRANT UPDATE on \"$PgAcVar(tblinfo,tablename)\" to $PgAcVar(permission,username)"
+       }
+       if {$PgAcVar(permission,rule)} {
+               sql_exec noquiet "GRANT RULE on \"$PgAcVar(tblinfo,tablename)\" to $PgAcVar(permission,username)"
+       }
+       refreshTableInformation
+}
+
+
+proc {clusterIndex} {} {
+global PgAcVar
+       set sel [.pgaw:TableInfo.f2.fl.ilb curselection]
+       if {$sel == ""} {
+               showError [intlmsg "You have to select an index!"]
+               return
+       }
+       bell
+       if {[tk_messageBox -title [intlmsg Warning] -parent .pgaw:TableInfo -message [format [intlmsg "You choose to cluster index\n\n %s \n\nAll other indices will be lost!\nProceed?"] [.pgaw:TableInfo.f2.fl.ilb get $sel]] -type yesno -default no]=="no"} {return}
+       if {[sql_exec noquiet "cluster \"[.pgaw:TableInfo.f2.fl.ilb get $sel]\" on \"$PgAcVar(tblinfo,tablename)\""]} {
+               refreshTableInformation
+       }               
+}
+
+
+proc {get_tag_info} {wn itemid prefix} {
+       set taglist [$wn.c itemcget $itemid -tags]
+       set i [lsearch -glob $taglist $prefix*]
+       set thetag [lindex $taglist $i]
+       return [string range $thetag 1 end]
+}
+
+
+proc {dragMove} {w x y} {
+global PgAcVar
+       set dlo ""
+       catch { set dlo $PgAcVar(draglocation,obj) }
+       if {$dlo != ""} {
+               set dx [expr $x - $PgAcVar(draglocation,x)]
+               set dy [expr $y - $PgAcVar(draglocation,y)]
+               $w move $dlo $dx $dy
+               set PgAcVar(draglocation,x) $x
+               set PgAcVar(draglocation,y) $y
+       }
+}
+
+
+proc {dragStart} {wn w x y} {
+global PgAcVar
+       PgAcVar:clean draglocation,*
+       set object [$w find closest $x $y]
+       if {[lsearch [$wn.c gettags $object] movable]==-1} return;
+       $wn.c bind movable <Leave> {}
+       set PgAcVar(draglocation,obj) $object
+       set PgAcVar(draglocation,x) $x
+       set PgAcVar(draglocation,y) $y
+       set PgAcVar(draglocation,start) $x
+}
+
+
+proc {dragStop} {wn w x y} {
+global PgAcVar CurrentDB
+       set dlo ""
+       catch { set dlo $PgAcVar(draglocation,obj) }
+       if {$dlo != ""} {
+               $wn.c bind movable <Leave> "$wn configure -cursor left_ptr"
+               $wn configure -cursor left_ptr
+               set ctr [get_tag_info $wn $PgAcVar(draglocation,obj) v]
+               set diff [expr $x-$PgAcVar(draglocation,start)]
+               if {$diff==0} return;
+               set newcw {}
+               for {set i 0} {$i<$PgAcVar(mw,$wn,colcount)} {incr i} {
+                       if {$i==$ctr} {
+               lappend newcw [expr [lindex $PgAcVar(mw,$wn,colwidth) $i]+$diff]
+                       } else {
+               lappend newcw [lindex $PgAcVar(mw,$wn,colwidth) $i]
+                       }
+               }
+               set PgAcVar(mw,$wn,colwidth) $newcw
+               $wn.c itemconfigure c$ctr -width [expr [lindex $PgAcVar(mw,$wn,colwidth) $ctr]-5]
+               drawHeaders $wn
+               drawHorizontalLines $wn
+               if {$PgAcVar(mw,$wn,crtrow)!=""} {showRecord $wn $PgAcVar(mw,$wn,crtrow)}
+               for {set i [expr $ctr+1]} {$i<$PgAcVar(mw,$wn,colcount)} {incr i} {
+                       $wn.c move c$i $diff 0
+               }
+               setCursor CLOCK
+               sql_exec quiet "update pga_layout set colwidth='$PgAcVar(mw,$wn,colwidth)' where tablename='$PgAcVar(mw,$wn,layout_name)'"
+               setCursor DEFAULT
+       }
+}
+
+
+proc {canvasClick} {wn x y} {
+global PgAcVar
+       if {![finishEdit $wn]} return
+       # Determining row
+       for {set row 0} {$row<$PgAcVar(mw,$wn,nrecs)} {incr row} {
+               if {[lindex $PgAcVar(mw,$wn,rowy) $row]>$y} break
+       }
+       incr row -1
+       if {$y>[lindex $PgAcVar(mw,$wn,rowy) $PgAcVar(mw,$wn,last_rownum)]} {set row $PgAcVar(mw,$wn,last_rownum)}
+       if {$row<0} return
+       set PgAcVar(mw,$wn,row_edited) $row
+       set PgAcVar(mw,$wn,crtrow) $row
+       showRecord $wn $row
+       if {$PgAcVar(mw,$wn,errorsavingnew)} return
+       # Determining column
+       set posx [expr -$PgAcVar(mw,$wn,leftoffset)]
+       set col 0
+       foreach cw $PgAcVar(mw,$wn,colwidth) {
+               incr posx [expr $cw+2]
+               if {$x<$posx} break
+               incr col
+       }
+       set itlist [$wn.c find withtag r$row]
+       foreach item $itlist {
+               if {[get_tag_info $wn $item c]==$col} {
+                       startEdit $wn $item $x $y
+                       break
+               }
+       }
+}
+
+
+proc {deleteRecord} {wn} {
+global PgAcVar CurrentDB
+       if {!$PgAcVar(mw,$wn,updatable)} return;
+       if {![finishEdit $wn]} return;
+       set taglist [$wn.c gettags hili]
+       if {[llength $taglist]==0} return;
+       set rowtag [lindex $taglist [lsearch -regexp $taglist "^r"]]
+       set row [string range $rowtag 1 end]
+       set oid [lindex $PgAcVar(mw,$wn,keylist) $row]
+       if {[tk_messageBox -title [intlmsg "FINAL WARNING"] -icon question -parent $wn -message [intlmsg "Delete current record ?"] -type yesno -default no]=="no"} return
+       if {[sql_exec noquiet "delete from \"$PgAcVar(mw,$wn,tablename)\" where oid=$oid"]} {
+               $wn.c delete hili
+       }
+}
+
+
+proc {drawHeaders} {wn} {
+global PgAcVar
+       $wn.c delete header
+       set posx [expr 5-$PgAcVar(mw,$wn,leftoffset)]
+       for {set i 0} {$i<$PgAcVar(mw,$wn,colcount)} {incr i} {
+               set xf [expr $posx+[lindex $PgAcVar(mw,$wn,colwidth) $i]]
+               $wn.c create rectangle $posx 1 $xf 22 -fill #CCCCCC -outline "" -width 0 -tags header
+               $wn.c create text [expr $posx+[lindex $PgAcVar(mw,$wn,colwidth) $i]*1.0/2] 14 -text [lindex $PgAcVar(mw,$wn,colnames) $i] -tags header -fill navy -font $PgAcVar(pref,font_normal)
+               $wn.c create line $posx 22 [expr $xf-1] 22 -fill #AAAAAA -tags header
+               $wn.c create line [expr $xf-1] 5 [expr $xf-1] 22 -fill #AAAAAA -tags header
+               $wn.c create line [expr $xf+1] 5 [expr $xf+1] 22 -fill white -tags header
+               $wn.c create line $xf -15000 $xf 15000 -fill #CCCCCC -tags [subst {header movable v$i}]
+               set posx [expr $xf+2]
+       }
+       set PgAcVar(mw,$wn,r_edge) $posx
+       $wn.c bind movable <Button-1> "Tables::dragStart $wn %W %x %y"
+       $wn.c bind movable <B1-Motion> {Tables::dragMove %W %x %y}
+       $wn.c bind movable <ButtonRelease-1> "Tables::dragStop $wn %W %x %y"
+       $wn.c bind movable <Enter> "$wn configure -cursor left_side"
+       $wn.c bind movable <Leave> "$wn configure -cursor left_ptr"
+}
+
+
+proc {drawHorizontalLines} {wn} {
+global PgAcVar
+       $wn.c delete hgrid
+       set posx 10
+       for {set j 0} {$j<$PgAcVar(mw,$wn,colcount)} {incr j} {
+               set ledge($j) $posx
+               incr posx [expr [lindex $PgAcVar(mw,$wn,colwidth) $j]+2]
+               set textwidth($j) [expr [lindex $PgAcVar(mw,$wn,colwidth) $j]-5]
+       }
+       incr posx -6
+       for {set i 0} {$i<$PgAcVar(mw,$wn,nrecs)} {incr i} {
+               $wn.c create line [expr -$PgAcVar(mw,$wn,leftoffset)] [lindex $PgAcVar(mw,$wn,rowy) [expr $i+1]] [expr $posx-$PgAcVar(mw,$wn,leftoffset)] [lindex $PgAcVar(mw,$wn,rowy) [expr $i+1]] -fill gray -tags [subst {hgrid g$i}]
+       }
+       if {$PgAcVar(mw,$wn,updatable)} {
+               set i $PgAcVar(mw,$wn,nrecs)
+               set posy [expr 14+[lindex $PgAcVar(mw,$wn,rowy) $PgAcVar(mw,$wn,nrecs)]]
+               $wn.c create line [expr -$PgAcVar(mw,$wn,leftoffset)] $posy [expr $posx-$PgAcVar(mw,$wn,leftoffset)] $posy -fill gray -tags [subst {hgrid g$i}]
+       }
+}
+
+
+proc {drawNewRecord} {wn} {
+global PgAcVar
+       set posx [expr 10-$PgAcVar(mw,$wn,leftoffset)]
+       set posy [lindex $PgAcVar(mw,$wn,rowy) $PgAcVar(mw,$wn,last_rownum)]
+       if {$PgAcVar(pref,tvfont)=="helv"} {
+               set tvfont $PgAcVar(pref,font_normal)
+       } else {
+               set tvfont $PgAcVar(pref,font_fix)
+       }
+       if {$PgAcVar(mw,$wn,updatable)} {
+         for {set j 0} {$j<$PgAcVar(mw,$wn,colcount)} {incr j} {
+               $wn.c create text $posx $posy -text * -tags [subst {r$PgAcVar(mw,$wn,nrecs) c$j q new unt}]  -anchor nw -font $tvfont -width [expr [lindex $PgAcVar(mw,$wn,colwidth) $j]-5]
+               incr posx [expr [lindex $PgAcVar(mw,$wn,colwidth) $j]+2]
+         }
+         incr posy 14
+         $wn.c create line [expr -$PgAcVar(mw,$wn,leftoffset)] $posy [expr $PgAcVar(mw,$wn,r_edge)-$PgAcVar(mw,$wn,leftoffset)] $posy -fill gray -tags [subst {hgrid g$PgAcVar(mw,$wn,nrecs)}]
+       }
+}
+
+
+proc {editMove} { wn {distance 1} {position end} } {
+       global PgAcVar 
+
+       # This routine moves the cursor some relative distance
+       # from one cell being editted to another cell in the table.
+       # Typical distances are 1, +1, $PgAcVar(mw,$wn,colcount), and 
+       # -$PgAcVar(mw,$wn,colcount).  Position is where
+       # the cursor will be placed within the cell.  The valid
+       # positions are 0 and end.
+
+       # get the current row and column
+       set current_cell_id $PgAcVar(mw,$wn,id_edited)
+       set tags [$wn.c gettags $current_cell_id] 
+       regexp {r([0-9]+)} $tags match crow
+       regexp {c([0-9]+)} $tags match ccol
+
+
+       # calculate next row and column
+       set colcount $PgAcVar(mw,$wn,colcount)
+       set ccell [expr ($crow * $colcount) + $ccol]
+       set ncell [expr $ccell + $distance]
+       set nrow [expr $ncell / $colcount]
+       set ncol [expr $ncell % $colcount]
+
+
+       # find the row of the next cell
+       if {$distance < 0} {
+               set row_increment -1
+       } else {
+               set row_increment 1
+       }
+       set id_tuple [$wn.c find withtag r$nrow] 
+       # skip over deleted rows...
+       while {[llength $id_tuple] == 0} {
+               # case above first row of table
+               if {$nrow < 0} {
+                       return
+               # case at or beyond last row of table
+               } elseif {$nrow >= $PgAcVar(mw,$wn,nrecs)} {
+                       if {![insertNewRecord $wn]} {
+                  set PgAcVar(mw,$wn,errorsavingnew) 1
+                       return
+                 }
+                 set id_tuple [$wn.c find withtag r$nrow] 
+                 break
+               }
+       incr nrow $row_increment
+               set id_tuple [$wn.c find withtag r$nrow] 
+       }
+
+       # find the widget id of the next cell
+       set next_cell_id [lindex [lsort -integer $id_tuple] $ncol]
+       if {[string compare $next_cell_id {}] == 0} {
+               set next_cell_id [$wn.c find withtag $current_cell_id]
+       }
+
+       # make sure that the new cell is in the visible window
+       set toprec $PgAcVar(mw,$wn,toprec)
+       set numscreenrecs [getVisibleRecordsCount $wn]
+       if {$nrow < $toprec} {
+          # case nrow above visable window
+          scrollWindow $wn moveto \
+               [expr $nrow *[recordSizeInScrollbarUnits $wn]]
+       } elseif {$nrow > ($toprec + $numscreenrecs - 1)} {
+          # case nrow below visable window
+               scrollWindow $wn moveto \
+               [expr ($nrow - $numscreenrecs + 2) * [recordSizeInScrollbarUnits $wn]]
+       }
+       # I need to find a better way to pan -kk
+       foreach {x1 y1 x2 y2}  [$wn.c bbox $next_cell_id] {break}
+       while {$x1 <= $PgAcVar(mw,$wn,leftoffset)} {
+               panRight $wn
+               foreach {x1 y1 x2 y2}  [$wn.c bbox $next_cell_id] {break}
+       }
+       set rightedge [expr $x1 + [lindex $PgAcVar(mw,$wn,colwidth) $ncol]]
+       while {$rightedge > ($PgAcVar(mw,$wn,leftoffset) + [winfo width $wn.c])} {
+               panLeft $wn
+       }
+
+       # move to the next cell
+       foreach {x1 y1 x2 y2}  [$wn.c bbox $next_cell_id] {break}
+       switch -exact -- $position {
+               0 {
+                       canvasClick $wn [incr x1  ] [incr y1 ]
+       }
+       end -
+               default {
+                       canvasClick $wn [incr x2  -1] [incr y2 -1]
+       }
+       }
+}
+
+
+proc {editText} {wn c k} {
+global PgAcVar
+set bbin [$wn.c bbox r$PgAcVar(mw,$wn,row_edited)]
+switch $k {
+       BackSpace { set dp [expr [$wn.c index $PgAcVar(mw,$wn,id_edited) insert]-1];if {$dp>=0} {$wn.c dchars $PgAcVar(mw,$wn,id_edited) $dp $dp; set PgAcVar(mw,$wn,dirtyrec) 1}}
+       Home {$wn.c icursor $PgAcVar(mw,$wn,id_edited) 0}
+       End {$wn.c icursor $PgAcVar(mw,$wn,id_edited) end}
+               Left {
+                       set position [expr [$wn.c index $PgAcVar(mw,$wn,id_edited) insert]-1]
+                       if {$position < 0} {
+               editMove $wn -1 end
+               return
+                       }
+                       $wn.c icursor $PgAcVar(mw,$wn,id_edited) $position
+               }
+       Delete {}
+               Right {
+                       set position [expr [$wn.c index $PgAcVar(mw,$wn,id_edited) insert]+1]
+                       if {$position > [$wn.c index $PgAcVar(mw,$wn,id_edited) end] } {
+               editMove $wn 1 0
+               return
+                       }
+                       $wn.c icursor $PgAcVar(mw,$wn,id_edited) $position
+               }
+               Return -
+               Tab {editMove $wn; return}
+               ISO_Left_Tab {editMove $wn -1; return}
+               Up  {editMove $wn -$PgAcVar(mw,$wn,colcount); return }
+               Down  {editMove $wn $PgAcVar(mw,$wn,colcount); return }
+       Escape {set PgAcVar(mw,$wn,dirtyrec) 0; $wn.c itemconfigure $PgAcVar(mw,$wn,id_edited) -text $PgAcVar(mw,$wn,text_initial_value); $wn.c focus {}}
+       default {if {[string compare $c " "]>-1} {$wn.c insert $PgAcVar(mw,$wn,id_edited) insert $c;set PgAcVar(mw,$wn,dirtyrec) 1}}
+}
+set bbout [$wn.c bbox r$PgAcVar(mw,$wn,row_edited)]
+set dy [expr [lindex $bbout 3]-[lindex $bbin 3]]
+if {$dy==0} return
+set re $PgAcVar(mw,$wn,row_edited)
+$wn.c move g$re 0 $dy
+for {set i [expr 1+$re]} {$i<=$PgAcVar(mw,$wn,nrecs)} {incr i} {
+       $wn.c move r$i 0 $dy
+       $wn.c move g$i 0 $dy
+       set rh [lindex $PgAcVar(mw,$wn,rowy) $i]
+       incr rh $dy
+       set PgAcVar(mw,$wn,rowy) [lreplace $PgAcVar(mw,$wn,rowy) $i $i $rh]
+}
+showRecord $wn $PgAcVar(mw,$wn,row_edited)
+# Delete is trapped by window interpreted as record delete
+#    Delete {$wn.c dchars $PgAcVar(mw,$wn,id_edited) insert insert; set PgAcVar(mw,$wn,dirtyrec) 1}
+}
+
+
+proc {finishEdit} {wn} {
+global PgAcVar CurrentDB
+# User has edited the text ?
+if {!$PgAcVar(mw,$wn,dirtyrec)} {
+       # No, unfocus text
+       $wn.c focus {}
+       # For restoring * to the new record position
+       if {$PgAcVar(mw,$wn,id_edited)!=""} {
+               if {[lsearch [$wn.c gettags $PgAcVar(mw,$wn,id_edited)] new]!=-1} {
+                       $wn.c itemconfigure $PgAcVar(mw,$wn,id_edited) -text $PgAcVar(mw,$wn,text_initial_value)
+               }
+       }
+       set PgAcVar(mw,$wn,id_edited) {};set PgAcVar(mw,$wn,text_initial_value) {}
+       return 1
+}
+# Trimming the spaces
+set fldval [string trim [$wn.c itemcget $PgAcVar(mw,$wn,id_edited) -text]]
+$wn.c itemconfigure $PgAcVar(mw,$wn,id_edited) -text $fldval
+if {[string compare $PgAcVar(mw,$wn,text_initial_value) $fldval]==0} {
+       set PgAcVar(mw,$wn,dirtyrec) 0
+       $wn.c focus {}
+       set PgAcVar(mw,$wn,id_edited) {};set PgAcVar(mw,$wn,text_initial_value) {}
+       return 1
+}
+setCursor CLOCK
+set oid [lindex $PgAcVar(mw,$wn,keylist) $PgAcVar(mw,$wn,row_edited)]
+set fld [lindex $PgAcVar(mw,$wn,colnames) [get_tag_info $wn $PgAcVar(mw,$wn,id_edited) c]]
+set fillcolor black
+if {$PgAcVar(mw,$wn,row_edited)==$PgAcVar(mw,$wn,last_rownum)} {
+       set fillcolor red
+       set sfp [lsearch $PgAcVar(mw,$wn,newrec_fields) "\"$fld\""]
+       if {$sfp>-1} {
+               set PgAcVar(mw,$wn,newrec_fields) [lreplace $PgAcVar(mw,$wn,newrec_fields) $sfp $sfp]
+               set PgAcVar(mw,$wn,newrec_values) [lreplace $PgAcVar(mw,$wn,newrec_values) $sfp $sfp]
+       }                       
+       lappend PgAcVar(mw,$wn,newrec_fields) "\"$fld\""
+       lappend PgAcVar(mw,$wn,newrec_values) '$fldval'
+       # Remove the untouched tag from the object
+       $wn.c dtag $PgAcVar(mw,$wn,id_edited) unt
+               $wn.c itemconfigure $PgAcVar(mw,$wn,id_edited) -fill red
+       set retval 1
+} else {
+       set PgAcVar(mw,$wn,msg) "Updating record ..."
+       after 1000 "set PgAcVar(mw,$wn,msg) {}"
+       regsub -all ' $fldval  \\' sqlfldval
+
+#FIXME rjr 4/29/1999 special case null so it can be entered into tables
+#really need to write a tcl sqlquote proc which quotes the string only
+#if necessary, so it can be used all over pgaccess, instead of explicit 's
+
+       if {$sqlfldval == "null"} {
+               set retval [sql_exec noquiet "update \"$PgAcVar(mw,$wn,tablename)\" \
+               set \"$fld\"= null where oid=$oid"]
+       } else {
+               set retval [sql_exec noquiet "update \"$PgAcVar(mw,$wn,tablename)\" \
+               set \"$fld\"='$sqlfldval' where oid=$oid"]
+       }
+}
+setCursor DEFAULT
+if {!$retval} {
+       set PgAcVar(mw,$wn,msg) ""
+       focus $wn.c
+       return 0
+}
+set PgAcVar(mw,$wn,dirtyrec) 0
+$wn.c focus {}
+set PgAcVar(mw,$wn,id_edited) {};set PgAcVar(mw,$wn,text_initial_value) {}
+return 1
+}
+
+proc {loadLayout} {wn layoutname} {
+global PgAcVar CurrentDB
+       setCursor CLOCK
+       set PgAcVar(mw,$wn,layout_name) $layoutname
+       catch {unset PgAcVar(mw,$wn,colcount) PgAcVar(mw,$wn,colnames) PgAcVar(mw,$wn,colwidth)}
+       set PgAcVar(mw,$wn,layout_found) 0
+       set pgres [wpg_exec $CurrentDB "select *,oid from pga_layout where tablename='$layoutname' order by oid desc"]
+       set pgs [pg_result $pgres -status]
+       if {$pgs!="PGRES_TUPLES_OK"} {
+               # Probably table pga_layout isn't yet defined
+               sql_exec noquiet "create table pga_layout (tablename varchar(64),nrcols int2,colnames text,colwidth text)"
+               sql_exec quiet "grant ALL on pga_layout to PUBLIC"
+       } else {
+               set nrlay [pg_result $pgres -numTuples]
+               if {$nrlay>=1} {
+                       set layoutinfo [pg_result $pgres -getTuple 0]
+                       set PgAcVar(mw,$wn,colcount) [lindex $layoutinfo 1]
+                       set PgAcVar(mw,$wn,colnames)  [lindex $layoutinfo 2]
+                       set PgAcVar(mw,$wn,colwidth) [lindex $layoutinfo 3]
+                       set goodoid [lindex $layoutinfo 4]
+                       set PgAcVar(mw,$wn,layout_found) 1
+               }
+               if {$nrlay>1} {
+                       showError "Multiple ($nrlay) layout info found\n\nPlease report the bug!"
+                       sql_exec quiet "delete from pga_layout where (tablename='$PgAcVar(mw,$wn,tablename)') and (oid<>$goodoid)"
+               }
+       }
+       pg_result $pgres -clear
+}
+
+
+proc {panLeft} {wn } {
+global PgAcVar
+       if {![finishEdit $wn]} return;
+       if {$PgAcVar(mw,$wn,leftcol)==[expr $PgAcVar(mw,$wn,colcount)-1]} return;
+       set diff [expr 2+[lindex $PgAcVar(mw,$wn,colwidth) $PgAcVar(mw,$wn,leftcol)]]
+       incr PgAcVar(mw,$wn,leftcol)
+       incr PgAcVar(mw,$wn,leftoffset) $diff
+       $wn.c move header -$diff 0
+       $wn.c move q -$diff 0
+       $wn.c move hgrid -$diff 0
+}
+
+
+proc {panRight} {wn} {
+global PgAcVar
+       if {![finishEdit $wn]} return;
+       if {$PgAcVar(mw,$wn,leftcol)==0} return;
+       incr PgAcVar(mw,$wn,leftcol) -1
+       set diff [expr 2+[lindex $PgAcVar(mw,$wn,colwidth) $PgAcVar(mw,$wn,leftcol)]]
+       incr PgAcVar(mw,$wn,leftoffset) -$diff
+       $wn.c move header $diff 0
+       $wn.c move q $diff 0
+       $wn.c move hgrid $diff 0
+}
+
+
+proc {insertNewRecord} {wn} {
+global PgAcVar CurrentDB
+       if {![finishEdit $wn]} {return 0}
+       if {$PgAcVar(mw,$wn,newrec_fields)==""} {return 1}
+       set PgAcVar(mw,$wn,msg) "Saving new record ..."
+       after 1000 "set PgAcVar(mw,$wn,msg) {}"
+       set pgres [wpg_exec $CurrentDB "insert into \"$PgAcVar(mw,$wn,tablename)\" ([join $PgAcVar(mw,$wn,newrec_fields) ,]) values ([join $PgAcVar(mw,$wn,newrec_values) ,])" ]
+       if {[pg_result $pgres -status]!="PGRES_COMMAND_OK"} {
+               set errmsg [pg_result $pgres -error]
+               showError "[intlmsg {Error inserting new record}]\n\n$errmsg"
+               return 0
+       }
+       set oid [pg_result $pgres -oid]
+       lappend PgAcVar(mw,$wn,keylist) $oid
+       pg_result $pgres -clear
+       # Get bounds of the last record
+       set lrbb [$wn.c bbox new]
+       lappend PgAcVar(mw,$wn,rowy) [lindex $lrbb 3]
+       $wn.c itemconfigure new -fill black
+       $wn.c dtag q new
+       # Replace * from untouched new row elements with "  "
+       foreach item [$wn.c find withtag unt] {
+               $wn.c itemconfigure $item -text "  "
+       }
+       $wn.c dtag q unt
+       incr PgAcVar(mw,$wn,last_rownum)
+       incr PgAcVar(mw,$wn,nrecs)
+       drawNewRecord $wn
+       set PgAcVar(mw,$wn,newrec_fields) {}
+       set PgAcVar(mw,$wn,newrec_values) {}
+       return 1
+}
+
+
+proc {scrollWindow} {wn par1 args} {
+global PgAcVar
+       if {![finishEdit $wn]} return;
+       if {$par1=="scroll"} {
+               set newtop $PgAcVar(mw,$wn,toprec)
+               if {[lindex $args 1]=="units"} {
+                       incr newtop [lindex $args 0]
+               } else {
+                       incr newtop [expr [lindex $args 0]*25]
+                       if {$newtop<0} {set newtop 0}
+                       if {$newtop>=[expr $PgAcVar(mw,$wn,nrecs)-1]} {set newtop [expr $PgAcVar(mw,$wn,nrecs)-1]}
+               }
+       } elseif {$par1=="moveto"} {
+               set newtop [expr int([lindex $args 0]*$PgAcVar(mw,$wn,nrecs))]
+       } else {
+               return
+       }
+       if {$newtop<0} return;
+       if {$newtop>=[expr $PgAcVar(mw,$wn,nrecs)-1]} return;
+       set dy [expr [lindex $PgAcVar(mw,$wn,rowy) $PgAcVar(mw,$wn,toprec)]-[lindex $PgAcVar(mw,$wn,rowy) $newtop]]
+       $wn.c move q 0 $dy
+       $wn.c move hgrid 0 $dy
+       set newrowy {}
+       foreach y $PgAcVar(mw,$wn,rowy) {lappend newrowy [expr $y+$dy]}
+       set PgAcVar(mw,$wn,rowy) $newrowy
+       set PgAcVar(mw,$wn,toprec) $newtop
+       setScrollbar $wn
+}
+
+
+proc {initVariables} {wn} {
+global PgAcVar
+       set PgAcVar(mw,$wn,newrec_fields) {}
+       set PgAcVar(mw,$wn,newrec_values) {}
+}
+
+proc {selectRecords} {wn sql} {
+global PgAcVar CurrentDB
+if {![finishEdit $wn]} return;
+initVariables $wn
+$wn.c delete q
+$wn.c delete header
+$wn.c delete hgrid
+$wn.c delete new
+set PgAcVar(mw,$wn,leftcol) 0
+set PgAcVar(mw,$wn,leftoffset) 0
+set PgAcVar(mw,$wn,crtrow) {}
+set PgAcVar(mw,$wn,msg) [intlmsg "Accessing data. Please wait ..."]
+catch {$wn.f1.b1 configure -state disabled}
+setCursor CLOCK
+set is_error 1
+if {[sql_exec noquiet "BEGIN"]} {
+       if {[sql_exec noquiet "declare mycursor cursor for $sql"]} {
+               set pgres [wpg_exec $CurrentDB "fetch $PgAcVar(pref,rows) in mycursor"]
+               if {$PgAcVar(pgsql,status)=="PGRES_TUPLES_OK"} {
+                       set is_error 0
+               }
+       }
+}
+if {$is_error} {
+       sql_exec quiet "END"
+       set PgAcVar(mw,$wn,msg) {}
+       catch {$wn.f1.b1 configure -state normal}
+       setCursor DEFAULT
+       set PgAcVar(mw,$wn,msg) "Error executing : $sql"
+       return
+}
+if {$PgAcVar(mw,$wn,updatable)} then {set shift 1} else {set shift 0}
+#
+# checking at least the numer of fields
+set attrlist [pg_result $pgres -lAttributes]
+if {$PgAcVar(mw,$wn,layout_found)} then {
+       if {  ($PgAcVar(mw,$wn,colcount) != [expr [llength $attrlist]-$shift]) ||
+                 ($PgAcVar(mw,$wn,colcount) != [llength $PgAcVar(mw,$wn,colnames)]) ||
+                 ($PgAcVar(mw,$wn,colcount) != [llength $PgAcVar(mw,$wn,colwidth)]) } then {
+               # No. of columns don't match, something is wrong
+               # tk_messageBox -title [intlmsg Information] -message "Layout info changed !\nRescanning..."
+               set PgAcVar(mw,$wn,layout_found) 0
+               sql_exec quiet "delete from pga_layout where tablename='$PgAcVar(mw,$wn,layout_name)'"
+       }
+}
+# Always take the col. names from the result
+set PgAcVar(mw,$wn,colcount) [llength $attrlist]
+if {$PgAcVar(mw,$wn,updatable)} then {incr PgAcVar(mw,$wn,colcount) -1}
+set PgAcVar(mw,$wn,colnames) {}
+# In defPgAcVar(mw,$wn,colwidth) prepare PgAcVar(mw,$wn,colwidth) (in case that not layout_found)
+set defPgAcVar(mw,$wn,colwidth) {}
+for {set i 0} {$i<$PgAcVar(mw,$wn,colcount)} {incr i} {
+       lappend PgAcVar(mw,$wn,colnames) [lindex [lindex $attrlist [expr {$i+$shift}]] 0]
+       lappend defPgAcVar(mw,$wn,colwidth) 150
+}
+if {!$PgAcVar(mw,$wn,layout_found)} {
+       set PgAcVar(mw,$wn,colwidth) $defPgAcVar(mw,$wn,colwidth)
+       sql_exec quiet "insert into pga_layout values ('$PgAcVar(mw,$wn,layout_name)',$PgAcVar(mw,$wn,colcount),'$PgAcVar(mw,$wn,colnames)','$PgAcVar(mw,$wn,colwidth)')"
+       set PgAcVar(mw,$wn,layout_found) 1
+}
+set PgAcVar(mw,$wn,nrecs) [pg_result $pgres -numTuples]
+if {$PgAcVar(mw,$wn,nrecs)>$PgAcVar(pref,rows)} {
+       set PgAcVar(mw,$wn,msg) "Only first $PgAcVar(pref,rows) records from $PgAcVar(mw,$wn,nrecs) have been loaded"
+       set PgAcVar(mw,$wn,nrecs) $PgAcVar(pref,rows)
+}
+set tagoid {}
+if {$PgAcVar(pref,tvfont)=="helv"} {
+       set tvfont $PgAcVar(pref,font_normal)
+} else {
+       set tvfont $PgAcVar(pref,font_fix)
+}
+# Computing column's left edge
+set posx 10
+for {set j 0} {$j<$PgAcVar(mw,$wn,colcount)} {incr j} {
+       set ledge($j) $posx
+       incr posx [expr {[lindex $PgAcVar(mw,$wn,colwidth) $j]+2}]
+       set textwidth($j) [expr {[lindex $PgAcVar(mw,$wn,colwidth) $j]-5}]
+}
+incr posx -6
+set posy 24
+drawHeaders $wn
+set PgAcVar(mw,$wn,updatekey) oid
+set PgAcVar(mw,$wn,keylist) {}
+set PgAcVar(mw,$wn,rowy) {24}
+set PgAcVar(mw,$wn,msg) "Loading maximum $PgAcVar(pref,rows) records ..."
+set wupdatable $PgAcVar(mw,$wn,updatable)
+for {set i 0} {$i<$PgAcVar(mw,$wn,nrecs)} {incr i} {
+       set curtup [pg_result $pgres -getTuple $i]
+       if {$wupdatable} then {lappend PgAcVar(mw,$wn,keylist) [lindex $curtup 0]}
+       for {set j 0} {$j<$PgAcVar(mw,$wn,colcount)} {incr j} {
+               $wn.c create text $ledge($j) $posy -text [lindex $curtup [expr {$j+$shift}]] -tags [subst {r$i c$j q}] -anchor nw -font $tvfont -width $textwidth($j) -fill black
+       }
+       set bb [$wn.c bbox r$i]
+       incr posy [expr {[lindex $bb 3]-[lindex $bb 1]}]
+       lappend PgAcVar(mw,$wn,rowy) $posy
+       $wn.c create line 0 [lindex $bb 3] $posx [lindex $bb 3] -fill gray -tags [subst {hgrid g$i}]
+       if {$i==25} {update; update idletasks}
+}
+after 3000 "set PgAcVar(mw,$wn,msg) {}"
+set PgAcVar(mw,$wn,last_rownum) $i
+# Defining position for input data
+drawNewRecord $wn
+pg_result $pgres -clear
+sql_exec quiet "END"
+set PgAcVar(mw,$wn,toprec) 0
+setScrollbar $wn
+if {$PgAcVar(mw,$wn,updatable)} then {
+       $wn.c bind q <Key> "Tables::editText $wn %A %K"
+} else {
+       $wn.c bind q <Key> {}
+}
+set PgAcVar(mw,$wn,dirtyrec) 0
+$wn.c raise header
+catch {$wn.f1.b1 configure -state normal}
+setCursor DEFAULT
+}
+
+
+proc recordSizeInScrollbarUnits {wn} {
+       # record size in scrollbar units
+       global PgAcVar
+       return [expr 1.0/$PgAcVar(mw,$wn,nrecs)]
+}
+
+
+proc getVisibleRecordsCount {wn} {
+       # number of records that fit in the window at its current size
+       expr [winfo height $wn.c]/14
+}
+
+
+proc {setScrollbar} {wn} {
+global PgAcVar
+       if {$PgAcVar(mw,$wn,nrecs)==0} return;
+       # Fixes problem of window resizing messing up the scrollbar size.
+       set record_size [recordSizeInScrollbarUnits $wn];
+       $wn.sb set [expr $PgAcVar(mw,$wn,toprec)*$record_size] \
+       [expr ($PgAcVar(mw,$wn,toprec)+[getVisibleRecordsCount $wn])*$record_size]
+}
+
+
+proc {refreshRecords} {wn} {
+global PgAcVar
+       set nq $PgAcVar(mw,$wn,query)
+       if {($PgAcVar(mw,$wn,isaquery)) && ("$PgAcVar(mw,$wn,filter)$PgAcVar(mw,$wn,sortfield)"!="")} {
+               showError [intlmsg "Sorting and filtering not (yet) available from queries!\n\nPlease enter them in the query definition!"]
+               set PgAcVar(mw,$wn,sortfield) {}
+               set PgAcVar(mw,$wn,filter) {}
+       } else {
+               if {$PgAcVar(mw,$wn,filter)!=""} {
+                       set nq "$PgAcVar(mw,$wn,query) where ($PgAcVar(mw,$wn,filter))"
+               } else {
+                       set nq $PgAcVar(mw,$wn,query)
+               }
+               if {$PgAcVar(mw,$wn,sortfield)!=""} {
+                       set nq "$nq order by $PgAcVar(mw,$wn,sortfield)"
+               }
+       }
+       if {[insertNewRecord $wn]} {selectRecords $wn $nq}
+}
+
+
+proc {showRecord} {wn row} {
+global PgAcVar
+       set PgAcVar(mw,$wn,errorsavingnew) 0
+       if {$PgAcVar(mw,$wn,newrec_fields)!=""} {
+               if {$row!=$PgAcVar(mw,$wn,last_rownum)} {
+                       if {![insertNewRecord $wn]} {
+               set PgAcVar(mw,$wn,errorsavingnew) 1
+               return
+                       }
+               }
+       }
+       set y1 [lindex $PgAcVar(mw,$wn,rowy) $row]
+       set y2 [lindex $PgAcVar(mw,$wn,rowy) [expr $row+1]]
+       if {$y2==""} {set y2 [expr $y1+14]}
+       $wn.c dtag hili hili
+       $wn.c addtag hili withtag r$row
+       # Making a rectangle arround the record
+       set x 3
+       foreach wi $PgAcVar(mw,$wn,colwidth) {incr x [expr $wi+2]}
+       $wn.c delete crtrec
+       $wn.c create rectangle [expr -1-$PgAcVar(mw,$wn,leftoffset)] $y1 [expr $x-$PgAcVar(mw,$wn,leftoffset)] $y2 -fill #EEEEEE -outline {} -tags {q crtrec}
+       $wn.c lower crtrec
+}
+
+
+proc {startEdit} {wn id x y} {
+global PgAcVar
+       if {!$PgAcVar(mw,$wn,updatable)} return
+       set PgAcVar(mw,$wn,id_edited) $id
+       set PgAcVar(mw,$wn,dirtyrec) 0
+       set PgAcVar(mw,$wn,text_initial_value) [$wn.c itemcget $id -text]
+       focus $wn.c
+       $wn.c focus $id
+       $wn.c icursor $id @$x,$y
+       if {$PgAcVar(mw,$wn,row_edited)==$PgAcVar(mw,$wn,nrecs)} {
+               if {[$wn.c itemcget $id -text]=="*"} {
+                       $wn.c itemconfigure $id -text ""
+                       $wn.c icursor $id 0
+               }
+       }
+}
+
+
+proc {canvasPaste} {wn x y} {
+global PgAcVar
+       $wn.c insert $PgAcVar(mw,$wn,id_edited) insert [selection get]
+       set PgAcVar(mw,$wn,dirtyrec) 1
+}
+
+proc {getNewWindowName} {} {
+global PgAcVar
+       incr PgAcVar(mwcount)
+       return .pgaw:$PgAcVar(mwcount)
+}
+
+
+
+proc {createWindow} {{base ""}} {
+global PgAcVar
+       if {$base == ""} {
+               set base .pgaw:$PgAcVar(mwcount)
+               set included 0
+       } else {
+               set included 1
+       }
+       set wn $base
+       set PgAcVar(mw,$wn,dirtyrec) 0
+       set PgAcVar(mw,$wn,id_edited) {}
+       set PgAcVar(mw,$wn,filter) {}
+       set PgAcVar(mw,$wn,sortfield) {}
+       if {! $included} {
+               if {[winfo exists $base]} {
+                       wm deiconify $base; return
+               }
+               toplevel $base -class Toplevel
+               wm focusmodel $base passive
+               wm geometry $base 650x400
+               wm maxsize $base 1009 738
+               wm minsize $base 650 400
+               wm overrideredirect $base 0
+               wm resizable $base 1 1
+               wm deiconify $base
+               wm title $base [intlmsg "Table"]
+       }
+       bind $base <Key-Delete> "Tables::deleteRecord $wn"
+       bind $base <Key-F1> "Help::load tables"
+       if {! $included} {
+               frame $base.f1  -borderwidth 2 -height 75 -relief groove -width 125 
+               label $base.f1.l1  -borderwidth 0 -text [intlmsg {Sort field}]
+               entry $base.f1.e1  -background #fefefe -borderwidth 1 -width 14  -highlightthickness 1 -textvariable PgAcVar(mw,$wn,sortfield)
+               bind $base.f1.e1 <Key-Return> "Tables::refreshRecords $wn"      
+               bind $base.f1.e1 <Key-KP_Enter> "Tables::refreshRecords $wn"    
+               label $base.f1.lb1  -borderwidth 0 -text {     } 
+               label $base.f1.l2  -borderwidth 0 -text [intlmsg {Filter conditions}]
+               entry $base.f1.e2  -background #fefefe -borderwidth 1  -highlightthickness 1 -textvariable PgAcVar(mw,$wn,filter)
+               bind $base.f1.e2 <Key-Return> "Tables::refreshRecords $wn"      
+               bind $base.f1.e2 <Key-KP_Enter> "Tables::refreshRecords $wn"    
+               button $base.f1.b1  -borderwidth 1 -text [intlmsg Close] -command "
+               if {\[Tables::insertNewRecord $wn\]} {
+                       $wn.c delete rows
+                       $wn.c delete header
+                       Window destroy $wn
+                       PgAcVar:clean mw,$wn,*
+               }"
+               button $base.f1.b2  -borderwidth 1 -text [intlmsg Reload] -command "Tables::refreshRecords $wn"
+       }
+       frame $base.frame20  -borderwidth 2 -height 75 -relief groove -width 125 
+       button $base.frame20.01  -borderwidth 1 -text < -command "Tables::panRight $wn"
+       label $base.frame20.02  -anchor w -borderwidth 1 -height 1  -relief sunken -text {} -textvariable PgAcVar(mw,$wn,msg) 
+       button $base.frame20.03  -borderwidth 1 -text > -command "Tables::panLeft $wn"
+       canvas $base.c  -background #fefefe -borderwidth 2 -height 207 -highlightthickness 0  -relief ridge -selectborderwidth 0 -takefocus 1 -width 295 
+       scrollbar $base.sb  -borderwidth 1 -orient vert -width 12  -command "Tables::scrollWindow $wn"
+       bind $base.c <Button-1> "Tables::canvasClick $wn %x %y"
+       bind $base.c <Button-2> "Tables::canvasPaste $wn %x %y"
+       bind $base.c <Button-3> "if {[Tables::finishEdit $wn]} \"Tables::insertNewRecord $wn\""
+
+       # Prevent Tab from moving focus out of canvas widget
+       bind $base.c <Tab> break
+
+       if {! $included} {
+               pack $base.f1  -in $wn -anchor center -expand 0 -fill x -side top 
+               pack $base.f1.l1  -in $wn.f1 -anchor center -expand 0 -fill none -side left 
+               pack $base.f1.e1  -in $wn.f1 -anchor center -expand 0 -fill none -side left 
+               pack $base.f1.lb1  -in $wn.f1 -anchor center -expand 0 -fill none -side left 
+               pack $base.f1.l2  -in $wn.f1 -anchor center -expand 0 -fill none -side left 
+               pack $base.f1.e2  -in $wn.f1 -anchor center -expand 0 -fill none -side left 
+               pack $base.f1.b1  -in $wn.f1 -anchor center -expand 0 -fill none -side right 
+               pack $base.f1.b2  -in $wn.f1 -anchor center -expand 0 -fill none -side right 
+       }
+       pack $base.frame20  -in $wn -anchor s -expand 0 -fill x -side bottom 
+       pack $base.frame20.01  -in $wn.frame20 -anchor center -expand 0 -fill none -side left 
+       pack $base.frame20.02  -in $wn.frame20 -anchor center -expand 1 -fill x -side left 
+       pack $base.frame20.03  -in $wn.frame20 -anchor center -expand 0 -fill none -side right 
+       pack $base.c -in $wn -anchor w -expand 1 -fill both -side left 
+       pack $base.sb -in $wn -anchor e -expand 0 -fill y -side right
+}
+
+
+proc {renameColumn} {} {
+global PgAcVar CurrentDB
+       if {[string length [string trim $PgAcVar(tblinfo,new_cn)]]==0} {
+               showError [intlmsg "Field name not entered!"]
+               return
+       }
+       set old_name [string trim [string range $PgAcVar(tblinfo,old_cn) 0 31]]
+       set PgAcVar(tblinfo,new_cn) [string trim $PgAcVar(tblinfo,new_cn)]
+       if {$old_name == $PgAcVar(tblinfo,new_cn)} {
+               showError [intlmsg "New name is the same as the old one!"]
+               return
+       }
+       foreach line [.pgaw:TableInfo.f1.lb get 0 end] {
+               if {[string trim [string range $line 0 31]]==$PgAcVar(tblinfo,new_cn)} {
+                       showError [format [intlmsg {Column name '%s' already exists in this table!}] $PgAcVar(tblinfo,new_cn)]
+                       return
+               }
+       }
+       if {[sql_exec noquiet "alter table \"$PgAcVar(tblinfo,tablename)\" rename column \"$old_name\" to \"$PgAcVar(tblinfo,new_cn)\""]} {
+               refreshTableInformation
+               Window destroy .pgaw:RenameField
+       }
+}
+
+
+
+proc {addNewIndex} {} {
+global PgAcVar
+       set iflds [.pgaw:TableInfo.f1.lb curselection]
+       if {$iflds==""} {
+               showError [intlmsg "You have to select index fields!"]
+               return
+       }
+       set ifldslist {}
+       foreach i $iflds {lappend ifldslist "\"[string trim [string range [.pgaw:TableInfo.f1.lb get $i] 0 32]]\""}
+       set PgAcVar(addindex,indexname) $PgAcVar(tblinfo,tablename)_[join $ifldslist _]
+       # Replace the quotes with underlines
+       regsub -all {"} $PgAcVar(addindex,indexname) {_} PgAcVar(addindex,indexname)
+       # Replace the double underlines
+       while {[regsub -all {__} $PgAcVar(addindex,indexname) {_} PgAcVar(addindex,indexname)]} {}
+       # Replace the final underline
+       regsub -all {_$} $PgAcVar(addindex,indexname) {} PgAcVar(addindex,indexname)
+       set PgAcVar(addindex,indexfields) [join $ifldslist ,]
+       Window show .pgaw:AddIndex
+       wm transient .pgaw:AddIndex .pgaw:TableInfo
+}
+
+proc {deleteIndex} {} {
+global PgAcVar
+       set sel [.pgaw:TableInfo.f2.fl.ilb curselection]
+       if {$sel == ""} {
+               showError [intlmsg "You have to select an index!"]
+               return
+       }
+       if {[tk_messageBox -title [intlmsg Warning] -parent .pgaw:TableInfo -message [format [intlmsg "You choose to delete index\n\n %s \n\nProceed?"] [.pgaw:TableInfo.f2.fl.ilb get $sel]] -type yesno -default no]=="no"} {return}
+       if {[sql_exec noquiet "drop index \"[.pgaw:TableInfo.f2.fl.ilb get $sel]\""]} {
+               refreshTableInformation
+       }
+}
+
+proc {createNewIndex} {} {
+global PgAcVar
+       if {$PgAcVar(addindex,indexname)==""} {
+               showError [intlmsg "Index name cannot be null!"]
+               return
+       }
+       setCursor CLOCK
+       if {[sql_exec noquiet "CREATE $PgAcVar(addindex,unique) INDEX \"$PgAcVar(addindex,indexname)\" on \"$PgAcVar(tblinfo,tablename)\" ($PgAcVar(addindex,indexfields))"]} {
+               setCursor DEFAULT
+               Window destroy .pgaw:AddIndex
+               refreshTableInformation
+       }
+       setCursor DEFAULT
+}
+
+
+proc {showIndexInformation} {} {
+global PgAcVar CurrentDB
+set cs [.pgaw:TableInfo.f2.fl.ilb curselection]
+if {$cs==""} return
+set idxname [.pgaw:TableInfo.f2.fl.ilb get $cs]
+wpg_select $CurrentDB "select pg_index.*,pg_class.oid from pg_index,pg_class where pg_class.relname='$idxname' and pg_class.oid=pg_index.indexrelid" rec {
+       if {$rec(indisunique)=="t"} {
+               set PgAcVar(tblinfo,isunique) [intlmsg Yes]
+       } else {
+               set PgAcVar(tblinfo,isunique) [intlmsg No]
+       }
+       if {$rec(indisclustered)=="t"} {
+               set PgAcVar(tblinfo,isclustered) [intlmsg Yes]
+       } else {
+               set PgAcVar(tblinfo,isclustered) [intlmsg No]
+       }
+       set PgAcVar(tblinfo,indexfields) {}
+       .pgaw:TableInfo.f2.fr.lb delete 0 end
+       foreach field $rec(indkey) {
+               if {$field!=0} {
+#            wpg_select $CurrentDB "select attname from pg_attribute where attrelid=$PgAcVar(tblinfo,tableoid) and attnum=$field" rec1 {
+#                set PgAcVar(tblinfo,indexfields) "$PgAcVar(tblinfo,indexfields) $rec1(attname)"
+#            }
+               set PgAcVar(tblinfo,indexfields) "$PgAcVar(tblinfo,indexfields) $PgAcVar(tblinfo,f$field)"
+               .pgaw:TableInfo.f2.fr.lb insert end $PgAcVar(tblinfo,f$field)
+               }
+
+       }
+}
+set PgAcVar(tblinfo,indexfields) [string trim $PgAcVar(tblinfo,indexfields)]
+}
+
+
+proc {addNewColumn} {} {
+global PgAcVar
+       if {$PgAcVar(addfield,name)==""} {
+               showError [intlmsg "Empty field name ?"]
+               focus .pgaw:AddField.e1
+               return
+       }               
+       if {$PgAcVar(addfield,type)==""} {
+               showError [intlmsg "No field type ?"]
+               focus .pgaw:AddField.e2
+               return
+       }
+       if {![sql_exec quiet "alter table \"$PgAcVar(tblinfo,tablename)\" add column \"$PgAcVar(addfield,name)\" $PgAcVar(addfield,type)"]} {
+               showError "[intlmsg {Cannot add column}]\n\n$PgAcVar(pgsql,errmsg)"
+               return
+       }
+       Window destroy .pgaw:AddField
+       sql_exec quiet "update pga_layout set colnames=colnames || ' {$PgAcVar(addfield,name)}', colwidth=colwidth || ' 150',nrcols=nrcols+1 where tablename='$PgAcVar(tblinfo,tablename)'"
+       refreshTableInformation
+}
+
+
+proc {newtable:add_new_field} {} {
+global PgAcVar
+if {$PgAcVar(nt,fieldname)==""} {
+       showError [intlmsg "Enter a field name"]
+       focus .pgaw:NewTable.e2
+       return
+}
+if {$PgAcVar(nt,fldtype)==""} {
+       showError [intlmsg "The field type is not specified!"]
+       return
+}
+if {($PgAcVar(nt,fldtype)=="varchar")&&($PgAcVar(nt,fldsize)=="")} {
+       focus .pgaw:NewTable.e3
+       showError [intlmsg "You must specify field size!"]
+       return
+}
+if {$PgAcVar(nt,fldsize)==""} then {set sup ""} else {set sup "($PgAcVar(nt,fldsize))"}
+if {[regexp $PgAcVar(nt,fldtype) "varchartextdatetime"]} {set supc "'"} else {set supc ""}
+# Don't put the ' arround default value if it contains the now() function
+if {([regexp $PgAcVar(nt,fldtype) "datetime"]) && ([regexp now $PgAcVar(nt,defaultval)])} {set supc ""}
+# Clear the notnull attribute if field type is serial
+if {$PgAcVar(nt,fldtype)=="serial"} {set PgAcVar(nt,notnull) " "}
+if {$PgAcVar(nt,defaultval)==""} then {set sup2 ""} else {set sup2 " DEFAULT $supc$PgAcVar(nt,defaultval)$supc"}
+# Checking for field name collision
+set inspos end
+for {set i 0} {$i<[.pgaw:NewTable.lb size]} {incr i} {
+       set linie [.pgaw:NewTable.lb get $i]
+       if {$PgAcVar(nt,fieldname)==[string trim [string range $linie 2 33]]} {
+               if {[tk_messageBox -title [intlmsg Warning] -parent .pgaw:NewTable -message [format [intlmsg "There is another field with the same name: '%s'!\n\nReplace it ?"] $PgAcVar(nt,fieldname)] -type yesno -default yes]=="no"} return
+               .pgaw:NewTable.lb delete $i
+               set inspos $i
+               break
+       }        
+  }
+.pgaw:NewTable.lb insert $inspos [format "%1s %-32.32s %-14s%-16s" $PgAcVar(nt,primarykey) $PgAcVar(nt,fieldname) $PgAcVar(nt,fldtype)$sup $sup2$PgAcVar(nt,notnull)]
+focus .pgaw:NewTable.e2
+set PgAcVar(nt,fieldname) {}
+set PgAcVar(nt,fldsize) {}
+set PgAcVar(nt,defaultval) {}
+set PgAcVar(nt,primarykey) " "
+}
+
+proc {newtable:create} {} {
+global PgAcVar CurrentDB
+if {$PgAcVar(nt,tablename)==""} then {
+       showError [intlmsg "You must supply a name for your table!"]
+       focus .pgaw:NewTable.etabn
+       return
+}
+if {[.pgaw:NewTable.lb size]==0} then {
+       showError [intlmsg "Your table has no fields!"]
+       focus .pgaw:NewTable.e2
+       return
+}
+set fl {}
+set pkf {}
+foreach line [.pgaw:NewTable.lb get 0 end] {
+       set fldname "\"[string trim [string range $line 2 33]]\""
+       lappend fl "$fldname [string trim [string range $line 35 end]]"
+       if {[string range $line 0 0]=="*"} {
+               lappend pkf "$fldname"
+       }
+}
+set temp "create table \"$PgAcVar(nt,tablename)\" ([join $fl ,]"
+if {$PgAcVar(nt,constraint)!=""} then {set temp "$temp, constraint \"$PgAcVar(nt,constraint)\""}
+if {$PgAcVar(nt,check)!=""} then {set temp "$temp check ($PgAcVar(nt,check))"}
+if {[llength $pkf]>0} then {set temp "$temp, primary key([join $pkf ,])"}
+set temp "$temp)"
+if {$PgAcVar(nt,inherits)!=""} then {set temp "$temp inherits ($PgAcVar(nt,inherits))"}
+setCursor CLOCK
+if {[sql_exec noquiet $temp]} {
+       Window destroy .pgaw:NewTable
+       Mainlib::cmd_Tables
+}
+setCursor DEFAULT
+}
+
+proc {tabSelect} {i} {
+global PgAcVar
+       set base .pgaw:TableInfo
+       foreach tab {0 1 2 3} {
+               if {$i == $tab} {
+                       place $base.l$tab -y 13
+                       place $base.f$tab -x 15 -y 45
+                       $base.l$tab configure -font $PgAcVar(pref,font_bold)
+               } else {
+                       place $base.l$tab -y 15
+                       place $base.f$tab -x 15 -y 500
+                       $base.l$tab configure -font $PgAcVar(pref,font_normal)
+               }
+       }
+       array set coord [place info $base.l$i]
+       place $base.lline -x [expr {1+$coord(-x)}]
+}
+
+
+}
+
+####################   END OF NAMESPACE TABLES ####################
+
+proc vTclWindow.pgaw:NewTable {base} {
+global PgAcVar
+       if {$base == ""} {
+               set base .pgaw:NewTable
+       }
+       if {[winfo exists $base]} {
+               wm deiconify $base; return
+       }
+       toplevel $base -class Toplevel
+       wm focusmodel $base passive
+       wm geometry $base 634x392+78+181
+       wm maxsize $base 1009 738
+       wm minsize $base 1 1
+       wm overrideredirect $base 0
+       wm resizable $base 0 0
+       wm deiconify $base
+       wm title $base [intlmsg "Create new table"]
+       bind $base <Key-F1> "Help::load new_table"
+       entry $base.etabn \
+               -background #fefefe -borderwidth 1 -selectborderwidth 0 \
+               -textvariable PgAcVar(nt,tablename) 
+       bind $base.etabn <Key-Return> {
+               focus .pgaw:NewTable.einh
+       }
+       label $base.li \
+               -anchor w -borderwidth 0 -text [intlmsg Inherits]
+       entry $base.einh \
+               -background #fefefe -borderwidth 1 -selectborderwidth 0 \
+               -textvariable PgAcVar(nt,inherits) 
+       bind $base.einh <Key-Return> {
+               focus .pgaw:NewTable.e2
+       }
+       button $base.binh \
+               -borderwidth 1 \
+               -command {if {[winfo exists .pgaw:NewTable.ddf]} {
+       destroy .pgaw:NewTable.ddf
+} else {
+       create_drop_down .pgaw:NewTable 386 23 220
+       focus .pgaw:NewTable.ddf.sb
+       foreach tbl [Database::getTablesList] {.pgaw:NewTable.ddf.lb insert end $tbl}
+       bind .pgaw:NewTable.ddf.lb <ButtonRelease-1> {
+               set i [.pgaw:NewTable.ddf.lb curselection]
+               if {$i!=""} {
+                       if {$PgAcVar(nt,inherits)==""} {
+               set PgAcVar(nt,inherits) "\"[.pgaw:NewTable.ddf.lb get $i]\""
+                       } else {
+               set PgAcVar(nt,inherits) "$PgAcVar(nt,inherits),\"[.pgaw:NewTable.ddf.lb get $i]\""
+                       }
+               }
+               if {$i!=""} {focus .pgaw:NewTable.e2}
+               destroy .pgaw:NewTable.ddf
+               break
+       }
+}} \
+               -highlightthickness 0 -takefocus 0 -image dnarw
+       entry $base.e2 \
+               -background #fefefe -borderwidth 1 -selectborderwidth 0 \
+               -textvariable PgAcVar(nt,fieldname) 
+       bind $base.e2 <Key-Return> {
+               focus .pgaw:NewTable.e1
+       }
+       entry $base.e1 \
+               -background #fefefe -borderwidth 1 -selectborderwidth 0 \
+               -textvariable PgAcVar(nt,fldtype) 
+       bind $base.e1 <Key-Return> {
+               focus .pgaw:NewTable.e5
+       }
+       entry $base.e3 \
+               -background #fefefe -borderwidth 1 -selectborderwidth 0 \
+               -textvariable PgAcVar(nt,fldsize) 
+       bind $base.e3 <Key-Return> {
+               focus .pgaw:NewTable.e5
+       }
+       entry $base.e5 \
+               -background #fefefe -borderwidth 1 -selectborderwidth 0 \
+               -textvariable PgAcVar(nt,defaultval) 
+       bind $base.e5 <Key-Return> {
+               focus .pgaw:NewTable.cb1
+       }
+       checkbutton $base.cb1 \
+               -borderwidth 1 \
+               -offvalue { } -onvalue { NOT NULL} -text [intlmsg {field cannot be null}] \
+               -variable PgAcVar(nt,notnull) 
+       label $base.lab1 \
+               -borderwidth 0 -text [intlmsg type]
+       label $base.lab2 \
+               -borderwidth 0 -anchor w -text [intlmsg {field name}]
+       label $base.lab3 \
+               -borderwidth 0 -text [intlmsg size]
+       label $base.lab4 \
+               -borderwidth 0 -anchor w -text [intlmsg {Default value}]
+       button $base.addfld \
+               -borderwidth 1 -command Tables::newtable:add_new_field \
+               -text [intlmsg {Add field}]
+       button $base.delfld \
+               -borderwidth 1 -command {catch {.pgaw:NewTable.lb delete [.pgaw:NewTable.lb curselection]}} \
+               -text [intlmsg {Delete field}]
+       button $base.emptb \
+               -borderwidth 1 -command {.pgaw:NewTable.lb delete 0 [.pgaw:NewTable.lb size]} \
+               -text [intlmsg {Delete all}]
+       button $base.maketbl \
+               -borderwidth 1 -command Tables::newtable:create \
+               -text [intlmsg Create]
+       listbox $base.lb \
+               -background #fefefe -foreground #000000 -borderwidth 1 \
+               -selectbackground #c3c3c3 -font $PgAcVar(pref,font_fix) \
+               -selectborderwidth 0 -yscrollcommand {.pgaw:NewTable.sb set} 
+       bind $base.lb <ButtonRelease-1> {
+               if {[.pgaw:NewTable.lb curselection]!=""} {
+       set fldname [string trim [lindex [split [.pgaw:NewTable.lb get [.pgaw:NewTable.lb curselection]]] 0]]
+}
+       }
+       button $base.exitbtn \
+               -borderwidth 1 -command {Window destroy .pgaw:NewTable} \
+               -text [intlmsg Cancel]
+       button $base.helpbtn \
+               -borderwidth 1 -command {Help::load new_table} \
+               -text [intlmsg Help]
+       label $base.l1 \
+               -anchor w -borderwidth 1 \
+               -relief raised -text "       [intlmsg {field name}]"
+       label $base.l2 \
+               -borderwidth 1 \
+               -relief raised -text [intlmsg type]
+       label $base.l3 \
+               -borderwidth 1 \
+               -relief raised -text [intlmsg options]
+       scrollbar $base.sb \
+               -borderwidth 1 -command {.pgaw:NewTable.lb yview} -orient vert 
+       label $base.l93 \
+               -anchor w -borderwidth 0 -text [intlmsg {Table name}]
+       button $base.mvup \
+               -borderwidth 1 \
+               -command {if {[.pgaw:NewTable.lb size]>1} {
+       set i [.pgaw:NewTable.lb curselection]
+       if {($i!="")&&($i>0)} {
+               .pgaw:NewTable.lb insert [expr $i-1] [.pgaw:NewTable.lb get $i]
+               .pgaw:NewTable.lb delete [expr $i+1]
+               .pgaw:NewTable.lb selection set [expr $i-1]
+       }
+}} \
+               -text [intlmsg {Move up}]
+       button $base.mvdn \
+               -borderwidth 1 \
+               -command {if {[.pgaw:NewTable.lb size]>1} {
+       set i [.pgaw:NewTable.lb curselection]
+       if {($i!="")&&($i<[expr [.pgaw:NewTable.lb size]-1])} {
+               .pgaw:NewTable.lb insert [expr $i+2] [.pgaw:NewTable.lb get $i]
+               .pgaw:NewTable.lb delete $i
+               .pgaw:NewTable.lb selection set [expr $i+1]
+       }
+}} \
+               -text [intlmsg {Move down}]
+       button $base.button17 \
+               -borderwidth 1 \
+               -command {
+if {[winfo exists .pgaw:NewTable.ddf]} {
+       destroy .pgaw:NewTable.ddf
+} else {
+       create_drop_down .pgaw:NewTable 291 80 97
+       focus .pgaw:NewTable.ddf.sb
+       .pgaw:NewTable.ddf.lb insert end char varchar text int2 int4 serial float4 float8 money abstime date datetime interval reltime time timespan timestamp boolean box circle line lseg path point polygon
+       bind .pgaw:NewTable.ddf.lb <ButtonRelease-1> {
+               set i [.pgaw:NewTable.ddf.lb curselection]
+               if {$i!=""} {set PgAcVar(nt,fldtype) [.pgaw:NewTable.ddf.lb get $i]}
+               destroy .pgaw:NewTable.ddf
+               if {$i!=""} {
+                       if {[lsearch {char varchar} $PgAcVar(nt,fldtype)]==-1} {
+               set PgAcVar(nt,fldsize) {}
+               .pgaw:NewTable.e3 configure -state disabled
+               focus .pgaw:NewTable.e5
+                       } else {
+               .pgaw:NewTable.e3 configure -state normal
+               focus .pgaw:NewTable.e3
+                       }
+               }
+               break
+       }
+}} \
+               -highlightthickness 0 -takefocus 0 -image dnarw 
+       label $base.lco \
+               -borderwidth 0 -anchor w -text [intlmsg Constraint]
+       entry $base.eco \
+               -background #fefefe -borderwidth 1 -textvariable PgAcVar(nt,constraint) 
+       label $base.lch \
+               -borderwidth 0 -text [intlmsg check]
+       entry $base.ech \
+               -background #fefefe -borderwidth 1 -textvariable PgAcVar(nt,check) 
+       label $base.ll \
+               -borderwidth 1 \
+               -relief raised 
+       checkbutton $base.pk \
+               -borderwidth 1 \
+               -offvalue { } -onvalue * -text [intlmsg {primary key}] -variable PgAcVar(nt,primarykey) 
+       label $base.lpk \
+               -borderwidth 1 \
+               -relief raised -text K 
+       place $base.etabn \
+               -x 105 -y 5 -width 136 -height 20 -anchor nw -bordermode ignore 
+       place $base.li \
+               -x 245 -y 7 -height 16 -anchor nw -bordermode ignore 
+       place $base.einh \
+               -x 300 -y 5 -width 308 -height 20 -anchor nw -bordermode ignore 
+       place $base.binh \
+               -x 590 -y 7 -width 16 -height 16 -anchor nw -bordermode ignore 
+       place $base.e2 \
+               -x 105 -y 60 -width 136 -height 20 -anchor nw -bordermode ignore 
+       place $base.e1 \
+               -x 291 -y 60 -width 98 -height 20 -anchor nw -bordermode ignore 
+       place $base.e3 \
+               -x 470 -y 60 -width 46 -height 20 -anchor nw -bordermode ignore 
+       place $base.e5 \
+               -x 105 -y 82 -width 136 -height 20 -anchor nw -bordermode ignore 
+       place $base.cb1 \
+               -x 245 -y 83 -height 20 -anchor nw -bordermode ignore 
+       place $base.lab1 \
+               -x 247 -y 62 -height 16 -anchor nw -bordermode ignore 
+       place $base.lab2 \
+               -x 4 -y 62 -height 16 -anchor nw -bordermode ignore 
+       place $base.lab3 \
+               -x 400 -y 62 -height 16 -anchor nw -bordermode ignore 
+       place $base.lab4 \
+               -x 5 -y 84 -height 16 -anchor nw -bordermode ignore 
+       place $base.addfld \
+               -x 530 -y 58 -width 100 -height 26 -anchor nw -bordermode ignore 
+       place $base.delfld \
+               -x 530 -y 190 -width 100 -height 26 -anchor nw -bordermode ignore 
+       place $base.emptb \
+               -x 530 -y 220 -width 100 -height 26 -anchor nw -bordermode ignore 
+       place $base.maketbl \
+               -x 530 -y 365 -width 100 -height 26 -anchor nw -bordermode ignore 
+       place $base.lb \
+               -x 4 -y 121 -width 506 -height 269 -anchor nw -bordermode ignore 
+       place $base.helpbtn \
+               -x 530 -y 305 -width 100 -height 26 -anchor nw -bordermode ignore 
+       place $base.exitbtn \
+               -x 530 -y 335 -width 100 -height 26 -anchor nw -bordermode ignore 
+       place $base.l1 \
+               -x 18 -y 105 -width 195 -height 18 -anchor nw -bordermode ignore 
+       place $base.l2 \
+               -x 213 -y 105 -width 88 -height 18 -anchor nw -bordermode ignore 
+       place $base.l3 \
+               -x 301 -y 105 -width 225 -height 18 -anchor nw -bordermode ignore 
+       place $base.sb \
+               -x 509 -y 121 -width 18 -height 269 -anchor nw -bordermode ignore 
+       place $base.l93 \
+               -x 4 -y 7 -height 16 -anchor nw -bordermode ignore 
+       place $base.mvup \
+               -x 530 -y 120 -width 100 -height 26 -anchor nw -bordermode ignore 
+       place $base.mvdn \
+               -x 530 -y 150 -width 100 -height 26 -anchor nw -bordermode ignore 
+       place $base.button17 \
+               -x 371 -y 62 -width 16 -height 16 -anchor nw -bordermode ignore 
+       place $base.lco \
+               -x 5 -y 28 -width 58 -height 16 -anchor nw -bordermode ignore 
+       place $base.eco \
+               -x 105 -y 27 -width 136 -height 20 -anchor nw -bordermode ignore 
+       place $base.lch \
+               -x 245 -y 30 -anchor nw -bordermode ignore 
+       place $base.ech \
+               -x 300 -y 27 -width 308 -height 22 -anchor nw -bordermode ignore 
+       place $base.ll \
+               -x 5 -y 53 -width 603 -height 2 -anchor nw -bordermode ignore 
+       place $base.pk \
+               -x 450 -y 83 -height 20 -anchor nw -bordermode ignore 
+       place $base.lpk \
+               -x 4 -y 105 -width 14 -height 18 -anchor nw -bordermode ignore 
+}
+
+
+proc vTclWindow.pgaw:TableInfo {base} {
+global PgAcVar
+       if {$base == ""} {
+               set base .pgaw:TableInfo
+       }
+       if {[winfo exists $base]} {
+               wm deiconify $base; return
+       }
+       toplevel $base -class Toplevel \
+               -background #c7c3c7 
+       wm focusmodel $base passive
+       wm geometry $base 522x398+152+135
+       wm maxsize $base 1009 738
+       wm minsize $base 1 1
+       wm overrideredirect $base 0
+       wm resizable $base 0 0
+       wm deiconify $base
+       wm title $base [intlmsg "Table information"]
+       bind $base <Key-F1> "Help::load view_table_structure"
+       label $base.l0 \
+               -borderwidth 1 -font $PgAcVar(pref,font_bold) \
+               -relief raised -text [intlmsg General]
+       bind $base.l0 <Button-1> {
+               Tables::tabSelect 0
+    }
+       label $base.l1 \
+               -borderwidth 1 \
+               -relief raised -text [intlmsg Columns]
+       bind $base.l1 <Button-1> {
+               Tables::tabSelect 1
+    }
+       label $base.l2 \
+               -borderwidth 1 \
+               -relief raised -text [intlmsg Indexes]
+       bind $base.l2 <Button-1> {
+               Tables::tabSelect 2
+    }
+       label $base.l3 \
+               -borderwidth 1 \
+               -relief raised -text [intlmsg Permissions]
+       bind $base.l3 <Button-1> {
+               Tables::tabSelect 3
+    }
+       label $base.l \
+               -relief raised 
+       button $base.btnclose \
+               -borderwidth 1 -command {Window destroy .pgaw:TableInfo} \
+               -highlightthickness 0 -padx 9 -pady 3 -text [intlmsg Close]
+       frame $base.f1 \
+               -borderwidth 2 -height 75 -relief groove -width 125 
+       frame $base.f1.ft \
+               -height 75 -relief groove -width 125 
+       label $base.f1.ft.t1 \
+               -relief groove -text [intlmsg {field name}]
+       label $base.f1.ft.t2 \
+               -relief groove -text [intlmsg type] -width 12 
+       label $base.f1.ft.t3 \
+               -relief groove -text [intlmsg size] -width 6 
+       label $base.f1.ft.lnn \
+               -relief groove -text [intlmsg {not null}] -width 18 
+       label $base.f1.ft.ls \
+               -borderwidth 0 \
+               -relief raised -text {    } 
+       frame $base.f1.fb \
+               -height 75 -relief groove -width 125 
+       button $base.f1.fb.addcolbtn \
+               -borderwidth 1 \
+               -command {Window show .pgaw:AddField
+                       set PgAcVar(addfield,name) {}
+                       set PgAcVar(addfield,type) {}
+                       wm transient .pgaw:AddField .pgaw:TableInfo
+                       focus .pgaw:AddField.e1} \
+                -padx 9 -pady 3 -text [intlmsg {Add new column}]
+       button $base.f1.fb.rencolbtn \
+               -borderwidth 1 \
+               -command {
+if {[set PgAcVar(tblinfo,col_id) [.pgaw:TableInfo.f1.lb curselection]]==""} then {
+       bell
+} else {
+       set PgAcVar(tblinfo,old_cn) [.pgaw:TableInfo.f1.lb get [.pgaw:TableInfo.f1.lb curselection]]
+       set PgAcVar(tblinfo,new_cn) {}
+       Window show .pgaw:RenameField
+       tkwait visibility .pgaw:RenameField
+       wm transient .pgaw:RenameField .pgaw:TableInfo
+       focus .pgaw:RenameField.e1
+}
+} \
+                -padx 9 -pady 3 -text [intlmsg {Rename column}]
+       button $base.f1.fb.addidxbtn \
+               -borderwidth 1 -command Tables::addNewIndex \
+                -padx 9 \
+               -pady 3 -text [intlmsg {Add new index}]
+       listbox $base.f1.lb \
+               -background #fefefe -borderwidth 1 -font $PgAcVar(pref,font_fix) \
+               -highlightthickness 0 -selectborderwidth 0 \
+               -selectmode extended \
+               -yscrollcommand {.pgaw:TableInfo.f1.vsb set} 
+       scrollbar $base.f1.vsb \
+               -borderwidth 1 -command {.pgaw:TableInfo.f1.lb yview} -orient vert -width 14 
+       frame $base.f2 \
+               -borderwidth 2 -height 75 -relief groove -width 125 
+       frame $base.f2.fl \
+               -height 75 -relief groove -width 182 
+       label $base.f2.fl.t \
+               -relief groove -text [intlmsg {Indexes defined}]
+       button $base.f2.fl.delidxbtn \
+               -borderwidth 1 -command Tables::deleteIndex \
+                -padx 9 \
+               -pady 3 -text [intlmsg {Delete index}]
+       listbox $base.f2.fl.ilb \
+               -background #fefefe -borderwidth 1 \
+               -highlightthickness 0 -selectborderwidth 0 -width 37 \
+               -yscrollcommand {.pgaw:TableInfo.f2.fl.vsb set} 
+       bind $base.f2.fl.ilb <ButtonRelease-1> {
+               Tables::showIndexInformation
+       }
+       scrollbar $base.f2.fl.vsb \
+               -borderwidth 1 -command {.pgaw:TableInfo.f2.fl.ilb yview} -orient vert -width 14 
+       frame $base.f2.fr \
+               -height 75 -relief groove -width 526 
+       label $base.f2.fr.t \
+               -relief groove -text [intlmsg {index properties}]
+       button $base.f2.fr.clusterbtn \
+               -borderwidth 1 -command Tables::clusterIndex \
+                -padx 9 -pady 3 -text [intlmsg {Cluster index}]
+       frame $base.f2.fr.fp \
+               -borderwidth 2 -height 75 -relief groove -width 125 
+       label $base.f2.fr.fp.lu \
+               -anchor w -borderwidth 0 \
+               -relief raised -text [intlmsg {Is unique ?}]
+       label $base.f2.fr.fp.vu \
+               -borderwidth 0 -textvariable PgAcVar(tblinfo,isunique) \
+               -foreground #000096 -relief raised -text {} 
+       label $base.f2.fr.fp.lc \
+               -borderwidth 0 \
+               -relief raised -text [intlmsg {Is clustered ?}]
+       label $base.f2.fr.fp.vc -textvariable PgAcVar(tblinfo,isclustered) \
+               -borderwidth 0 \
+               -foreground #000096 -relief raised -text {}
+       label $base.f2.fr.lic \
+               -relief groove -text [intlmsg {index columns}]
+       listbox $base.f2.fr.lb \
+               -background #fefefe -borderwidth 1 \
+               -highlightthickness 0 -selectborderwidth 0 \
+               -yscrollcommand {.pgaw:TableInfo.f2.fr.vsb set} 
+       scrollbar $base.f2.fr.vsb \
+               -borderwidth 1 -command {.pgaw:TableInfo.f2.fr.lb yview} -orient vert -width 14 
+       frame $base.f3 \
+               -borderwidth 2 -height 75 -relief groove -width 125 
+       frame $base.f3.ft \
+               -height 75 -relief groove -width 125 
+       label $base.f3.ft.luser \
+               -relief groove -text [intlmsg {User name}]
+       label $base.f3.ft.lselect \
+               -relief groove -text [intlmsg select] -width 10 
+       label $base.f3.ft.lupdate \
+               -relief groove -text [intlmsg update] -width 10 
+       label $base.f3.ft.linsert \
+               -relief groove -text [intlmsg insert] -width 10 
+       label $base.f3.ft.lrule \
+               -relief groove -text [intlmsg rule] -width 10 
+       label $base.f3.ft.ls \
+               -borderwidth 0 \
+               -relief raised -text {    } 
+       frame $base.f3.fb \
+               -height 75 -relief groove -width 125 
+       button $base.f3.fb.adduserbtn \
+               -borderwidth 1 -command Tables::newPermissions \
+                -padx 9 -pady 3 -text [intlmsg {Add user}]
+       button $base.f3.fb.chguserbtn -command Tables::loadPermissions \
+               -borderwidth 1 -padx 9 -pady 3 -text [intlmsg {Change permissions}]
+       listbox $base.f3.plb \
+               -background #fefefe -borderwidth 1 -font $PgAcVar(pref,font_fix) \
+               -highlightthickness 0 -selectborderwidth 0 \
+               -yscrollcommand {.pgaw:TableInfo.f3.vsb set} 
+       bind $base.f3.plb <Double-1> Tables::loadPermissions
+       scrollbar $base.f3.vsb \
+               -borderwidth 1 -command {.pgaw:TableInfo.f3.plb yview} -orient vert -width 14 
+       label $base.lline \
+               -borderwidth 0 \
+               -relief raised -text {   } 
+       frame $base.f0 \
+               -borderwidth 2 -height 75 -relief groove -width 125 
+       frame $base.f0.fi \
+               -borderwidth 2 -height 75 -relief groove -width 125 
+       label $base.f0.fi.l1 \
+               -borderwidth 0 \
+               -relief raised -text [intlmsg {Table name}]
+       label $base.f0.fi.l2 \
+               -anchor w -borderwidth 1 \
+               -relief sunken -text {} -textvariable PgAcVar(tblinfo,tablename) \
+               -width 200 
+       label $base.f0.fi.l3 \
+               -borderwidth 0 \
+               -relief raised -text [intlmsg {Table OID}]
+       label $base.f0.fi.l4 \
+               -anchor w -borderwidth 1 \
+               -relief sunken -text {} -textvariable PgAcVar(tblinfo,tableoid) \
+               -width 200 
+       label $base.f0.fi.l5 \
+               -borderwidth 0 \
+               -relief raised -text [intlmsg Owner]
+       label $base.f0.fi.l6 \
+               -anchor w -borderwidth 1 \
+               -relief sunken -text {} -textvariable PgAcVar(tblinfo,owner) \
+               -width 200 
+       label $base.f0.fi.l7 \
+               -borderwidth 0 \
+               -relief raised -text [intlmsg {Owner ID}]
+       label $base.f0.fi.l8 \
+               -anchor w -borderwidth 1 \
+               -relief sunken -text {} -textvariable PgAcVar(tblinfo,ownerid) \
+               -width 200 
+       label $base.f0.fi.l9 \
+               -borderwidth 0 \
+               -relief raised -text [intlmsg {Has primary key ?}]
+       label $base.f0.fi.l10 \
+               -anchor w -borderwidth 1 \
+               -relief sunken -text {} \
+               -textvariable PgAcVar(tblinfo,hasprimarykey) -width 200 
+       label $base.f0.fi.l11 \
+               -borderwidth 0 \
+               -relief raised -text [intlmsg {Has rules ?}]
+       label $base.f0.fi.l12 \
+               -anchor w -borderwidth 1 \
+               -relief sunken -text {} -textvariable PgAcVar(tblinfo,hasrules) \
+               -width 200 
+       label $base.f0.fi.last \
+               -borderwidth 0 \
+               -relief raised -text {         } 
+       frame $base.f0.fs \
+               -borderwidth 2 -height 75 -relief groove -width 125 
+       label $base.f0.fs.l1 \
+               -borderwidth 0 \
+               -relief raised -text [intlmsg {Number of tuples}]
+       label $base.f0.fs.l2 \
+               -anchor e -borderwidth 1 \
+               -relief sunken -text 0 -textvariable PgAcVar(tblinfo,numtuples) \
+               -width 200 
+       label $base.f0.fs.l3 \
+               -borderwidth 0 \
+               -relief raised -text [intlmsg {Number of pages}]
+       label $base.f0.fs.l4 \
+               -anchor e -borderwidth 1 \
+               -relief sunken -text 0 -textvariable PgAcVar(tblinfo,numpages) \
+               -width 200 
+       label $base.f0.fs.last \
+               -borderwidth 0 \
+               -relief raised -text { } 
+       label $base.f0.lstat \
+               -borderwidth 0 -font $PgAcVar(pref,font_bold) -relief raised \
+               -text " [intlmsg Statistics] "
+       label $base.f0.lid \
+               -borderwidth 0 -font $PgAcVar(pref,font_bold) -relief raised \
+               -text " [intlmsg Identification] "
+       place $base.l0 \
+               -x 15 -y 13 -width 96 -height 23 -anchor nw -bordermode ignore 
+       place $base.l1 \
+               -x 111 -y 15 -width 96 -height 23 -anchor nw -bordermode ignore 
+       place $base.l2 \
+               -x 207 -y 15 -width 96 -height 23 -anchor nw -bordermode ignore 
+       place $base.l3 \
+               -x 303 -y 15 -width 96 -height 23 -anchor nw -bordermode ignore 
+       place $base.l \
+               -x 5 -y 35 -width 511 -height 357 -anchor nw -bordermode ignore 
+       place $base.btnclose \
+               -x 425 -y 5 -width 91 -height 26 -anchor nw -bordermode ignore 
+       place $base.f1 \
+               -x 15 -y 500 -width 490 -height 335 -anchor nw -bordermode ignore 
+       pack $base.f1.ft \
+               -in .pgaw:TableInfo.f1 -anchor center -expand 0 -fill x -side top 
+       pack $base.f1.ft.t1 \
+               -in .pgaw:TableInfo.f1.ft -anchor center -expand 1 -fill x -side left 
+       pack $base.f1.ft.t2 \
+               -in .pgaw:TableInfo.f1.ft -anchor center -expand 0 -fill none -side left 
+       pack $base.f1.ft.t3 \
+               -in .pgaw:TableInfo.f1.ft -anchor center -expand 0 -fill none -side left 
+       pack $base.f1.ft.lnn \
+               -in .pgaw:TableInfo.f1.ft -anchor center -expand 0 -fill none -side left 
+       pack $base.f1.ft.ls \
+               -in .pgaw:TableInfo.f1.ft -anchor center -expand 0 -fill none -side top 
+       pack $base.f1.fb \
+               -in .pgaw:TableInfo.f1 -anchor center -expand 0 -fill x -side bottom 
+       grid $base.f1.fb.addcolbtn \
+               -in .pgaw:TableInfo.f1.fb -column 0 -row 0 -columnspan 1 -rowspan 1 
+       grid $base.f1.fb.rencolbtn \
+               -in .pgaw:TableInfo.f1.fb -column 1 -row 0 -columnspan 1 -rowspan 1 
+       grid $base.f1.fb.addidxbtn \
+               -in .pgaw:TableInfo.f1.fb -column 2 -row 0 -columnspan 1 -rowspan 1 
+       pack $base.f1.lb \
+               -in .pgaw:TableInfo.f1 -anchor center -expand 1 -fill both -pady 1 -side left 
+       pack $base.f1.vsb \
+               -in .pgaw:TableInfo.f1 -anchor center -expand 0 -fill y -side right 
+       place $base.f2 \
+               -x 15 -y 500 -width 490 -height 335 -anchor nw -bordermode ignore 
+       pack $base.f2.fl \
+               -in .pgaw:TableInfo.f2 -anchor center -expand 0 -fill both -side left 
+       pack $base.f2.fl.t \
+               -in .pgaw:TableInfo.f2.fl -anchor center -expand 0 -fill x -pady 1 -side top 
+       pack $base.f2.fl.delidxbtn \
+               -in .pgaw:TableInfo.f2.fl -anchor center -expand 0 -fill none -side bottom 
+       pack $base.f2.fl.ilb \
+               -in .pgaw:TableInfo.f2.fl -anchor center -expand 1 -fill both -pady 1 -side left 
+       pack $base.f2.fl.vsb \
+               -in .pgaw:TableInfo.f2.fl -anchor center -expand 0 -fill y -side right 
+       pack $base.f2.fr \
+               -in .pgaw:TableInfo.f2 -anchor center -expand 1 -fill both -padx 1 -side right 
+       pack $base.f2.fr.t \
+               -in .pgaw:TableInfo.f2.fr -anchor center -expand 0 -fill x -pady 1 -side top 
+       pack $base.f2.fr.clusterbtn \
+               -in .pgaw:TableInfo.f2.fr -anchor center -expand 0 -fill none -side bottom 
+       pack $base.f2.fr.fp \
+               -in .pgaw:TableInfo.f2.fr -anchor center -expand 0 -fill x -pady 1 -side top 
+       grid $base.f2.fr.fp.lu \
+               -in .pgaw:TableInfo.f2.fr.fp -column 0 -row 0 -columnspan 1 -rowspan 1 -sticky w 
+       grid $base.f2.fr.fp.vu \
+               -in .pgaw:TableInfo.f2.fr.fp -column 1 -row 0 -columnspan 1 -rowspan 1 -padx 5 \
+               -sticky w 
+       grid $base.f2.fr.fp.lc \
+               -in .pgaw:TableInfo.f2.fr.fp -column 0 -row 2 -columnspan 1 -rowspan 1 -sticky w 
+       grid $base.f2.fr.fp.vc \
+               -in .pgaw:TableInfo.f2.fr.fp -column 1 -row 2 -columnspan 1 -rowspan 1 -padx 5 \
+               -sticky w 
+       pack $base.f2.fr.lic \
+               -in .pgaw:TableInfo.f2.fr -anchor center -expand 0 -fill x -side top 
+       pack $base.f2.fr.lb \
+               -in .pgaw:TableInfo.f2.fr -anchor center -expand 1 -fill both -pady 1 -side left 
+       pack $base.f2.fr.vsb \
+               -in .pgaw:TableInfo.f2.fr -anchor center -expand 0 -fill y -side right 
+       place $base.f3 \
+               -x 15 -y 500 -width 490 -height 335 -anchor nw -bordermode ignore 
+       pack $base.f3.ft \
+               -in .pgaw:TableInfo.f3 -anchor center -expand 0 -fill x -pady 1 -side top 
+       pack $base.f3.ft.luser \
+               -in .pgaw:TableInfo.f3.ft -anchor center -expand 1 -fill x -side left 
+       pack $base.f3.ft.lselect \
+               -in .pgaw:TableInfo.f3.ft -anchor center -expand 0 -fill none -side left 
+       pack $base.f3.ft.lupdate \
+               -in .pgaw:TableInfo.f3.ft -anchor center -expand 0 -fill none -side left 
+       pack $base.f3.ft.linsert \
+               -in .pgaw:TableInfo.f3.ft -anchor center -expand 0 -fill none -side left 
+       pack $base.f3.ft.lrule \
+               -in .pgaw:TableInfo.f3.ft -anchor center -expand 0 -fill none -side left 
+       pack $base.f3.ft.ls \
+               -in .pgaw:TableInfo.f3.ft -anchor center -expand 0 -fill none -side top 
+       pack $base.f3.fb \
+               -in .pgaw:TableInfo.f3 -anchor center -expand 0 -fill x -side bottom 
+       grid $base.f3.fb.adduserbtn \
+               -in .pgaw:TableInfo.f3.fb -column 0 -row 0 -columnspan 1 -rowspan 1 
+       grid $base.f3.fb.chguserbtn \
+               -in .pgaw:TableInfo.f3.fb -column 1 -row 0 -columnspan 1 -rowspan 1 
+       pack $base.f3.plb \
+               -in .pgaw:TableInfo.f3 -anchor center -expand 1 -fill both -pady 1 -side left 
+       pack $base.f3.vsb \
+               -in .pgaw:TableInfo.f3 -anchor center -expand 0 -fill y -side right 
+       place $base.lline \
+               -x 16 -y 32 -width 94 -height 6 -anchor nw -bordermode ignore 
+       place $base.f0 \
+               -x 15 -y 45 -width 490 -height 335 -anchor nw -bordermode ignore 
+       place $base.f0.fi \
+               -x 5 -y 15 -width 300 -height 140 -anchor nw -bordermode ignore 
+       grid columnconf $base.f0.fi 1 -weight 1
+       grid rowconf $base.f0.fi 6 -weight 1
+       grid $base.f0.fi.l1 \
+               -in .pgaw:TableInfo.f0.fi -column 0 -row 0 -columnspan 1 -rowspan 1 -sticky w 
+       grid $base.f0.fi.l2 \
+               -in .pgaw:TableInfo.f0.fi -column 1 -row 0 -columnspan 1 -rowspan 1 -padx 2 \
+               -pady 2 
+       grid $base.f0.fi.l3 \
+               -in .pgaw:TableInfo.f0.fi -column 0 -row 1 -columnspan 1 -rowspan 1 -sticky w 
+       grid $base.f0.fi.l4 \
+               -in .pgaw:TableInfo.f0.fi -column 1 -row 1 -columnspan 1 -rowspan 1 -padx 2 \
+               -pady 2 
+       grid $base.f0.fi.l5 \
+               -in .pgaw:TableInfo.f0.fi -column 0 -row 2 -columnspan 1 -rowspan 1 -sticky w 
+       grid $base.f0.fi.l6 \
+               -in .pgaw:TableInfo.f0.fi -column 1 -row 2 -columnspan 1 -rowspan 1 -padx 2 \
+               -pady 2 
+       grid $base.f0.fi.l7 \
+               -in .pgaw:TableInfo.f0.fi -column 0 -row 3 -columnspan 1 -rowspan 1 -sticky w 
+       grid $base.f0.fi.l8 \
+               -in .pgaw:TableInfo.f0.fi -column 1 -row 3 -columnspan 1 -rowspan 1 -padx 2 \
+               -pady 2 
+       grid $base.f0.fi.l9 \
+               -in .pgaw:TableInfo.f0.fi -column 0 -row 4 -columnspan 1 -rowspan 1 -sticky w 
+       grid $base.f0.fi.l10 \
+               -in .pgaw:TableInfo.f0.fi -column 1 -row 4 -columnspan 1 -rowspan 1 -padx 2 \
+               -pady 2 
+       grid $base.f0.fi.l11 \
+               -in .pgaw:TableInfo.f0.fi -column 0 -row 5 -columnspan 1 -rowspan 1 -sticky w 
+       grid $base.f0.fi.l12 \
+               -in .pgaw:TableInfo.f0.fi -column 1 -row 5 -columnspan 1 -rowspan 1 -padx 2 \
+               -pady 2 
+       grid $base.f0.fi.last \
+               -in .pgaw:TableInfo.f0.fi -column 0 -row 6 -columnspan 1 -rowspan 1 
+       place $base.f0.fs \
+               -x 310 -y 15 -width 175 -height 50 -anchor nw -bordermode ignore 
+       grid columnconf $base.f0.fs 1 -weight 1
+       grid rowconf $base.f0.fs 2 -weight 1
+       grid $base.f0.fs.l1 \
+               -in .pgaw:TableInfo.f0.fs -column 0 -row 0 -columnspan 1 -rowspan 1 -sticky w 
+       grid $base.f0.fs.l2 \
+               -in .pgaw:TableInfo.f0.fs -column 1 -row 0 -columnspan 1 -rowspan 1 -padx 2 \
+               -pady 2 -sticky w 
+       grid $base.f0.fs.l3 \
+               -in .pgaw:TableInfo.f0.fs -column 0 -row 1 -columnspan 1 -rowspan 1 -sticky w 
+       grid $base.f0.fs.l4 \
+               -in .pgaw:TableInfo.f0.fs -column 1 -row 1 -columnspan 1 -rowspan 1 -padx 2 \
+               -pady 2 -sticky w 
+       grid $base.f0.fs.last \
+               -in .pgaw:TableInfo.f0.fs -column 0 -row 2 -columnspan 1 -rowspan 1 
+       place $base.f0.lstat \
+               -x 315 -y 5 -height 18 -anchor nw -bordermode ignore 
+       place $base.f0.lid \
+               -x 10 -y 5 -height 16 -anchor nw -bordermode ignore 
+}
+
+
+proc vTclWindow.pgaw:AddIndex {base} {
+       if {$base == ""} {
+               set base .pgaw:AddIndex
+       }
+       if {[winfo exists $base]} {
+               wm deiconify $base; return
+       }
+       toplevel $base -class Toplevel
+       wm focusmodel $base passive
+       wm geometry $base 334x203+265+266
+       wm maxsize $base 1009 738
+       wm minsize $base 1 1
+       wm overrideredirect $base 0
+       wm resizable $base 0 0
+       wm deiconify $base
+       wm title $base [intlmsg "Add new index"]
+       frame $base.f \
+               -borderwidth 2 -height 75 -relief groove -width 125 
+       frame $base.f.fin \
+               -height 75 -relief groove -width 125 
+       label $base.f.fin.lin \
+               -borderwidth 0 -relief raised -text [intlmsg {Index name}]
+       entry $base.f.fin.ein \
+               -background #fefefe -borderwidth 1 -width 28 -textvariable PgAcVar(addindex,indexname) 
+       checkbutton $base.f.cbunique -borderwidth 1 \
+               -offvalue { } -onvalue unique -text [intlmsg {Is unique ?}] -variable PgAcVar(addindex,unique)
+       label $base.f.ls1 \
+               -anchor w -background #dfdbdf -borderwidth 0 -foreground #000086 \
+               -justify left -relief raised -textvariable PgAcVar(addindex,indexfields) \
+               -wraplength 300 
+       label $base.f.lif \
+               -borderwidth 0 -relief raised -text "[intlmsg {Index fields}]:"
+       label $base.f.ls2 \
+               -borderwidth 0 -relief raised -text { } 
+       label $base.f.ls3 \
+               -borderwidth 0 -relief raised -text { } 
+       frame $base.fb \
+               -height 75 -relief groove -width 125 
+       button $base.fb.btncreate -command Tables::createNewIndex \
+               -padx 9 -pady 3 -text [intlmsg Create]
+       button $base.fb.btncancel \
+               -command {Window destroy .pgaw:AddIndex} -padx 9 -pady 3 -text [intlmsg Cancel]
+       pack $base.f \
+               -in .pgaw:AddIndex -anchor center -expand 1 -fill both -side top 
+       grid $base.f.fin \
+               -in .pgaw:AddIndex.f -column 0 -row 0 -columnspan 1 -rowspan 1 
+       grid $base.f.fin.lin \
+               -in .pgaw:AddIndex.f.fin -column 0 -row 0 -columnspan 1 -rowspan 1 
+       grid $base.f.fin.ein \
+               -in .pgaw:AddIndex.f.fin -column 1 -row 0 -columnspan 1 -rowspan 1 
+       grid $base.f.cbunique \
+               -in .pgaw:AddIndex.f -column 0 -row 5 -columnspan 1 -rowspan 1 
+       grid $base.f.ls1 \
+               -in .pgaw:AddIndex.f -column 0 -row 3 -columnspan 1 -rowspan 1 
+       grid $base.f.lif \
+               -in .pgaw:AddIndex.f -column 0 -row 2 -columnspan 1 -rowspan 1 -sticky w 
+       grid $base.f.ls2 \
+               -in .pgaw:AddIndex.f -column 0 -row 1 -columnspan 1 -rowspan 1 
+       grid $base.f.ls3 \
+               -in .pgaw:AddIndex.f -column 0 -row 4 -columnspan 1 -rowspan 1 
+       pack $base.fb \
+               -in .pgaw:AddIndex -anchor center -expand 0 -fill x -side bottom 
+       grid $base.fb.btncreate \
+               -in .pgaw:AddIndex.fb -column 0 -row 0 -columnspan 1 -rowspan 1 
+       grid $base.fb.btncancel \
+               -in .pgaw:AddIndex.fb -column 1 -row 0 -columnspan 1 -rowspan 1 
+}
+
+
+proc vTclWindow.pgaw:AddField {base} {
+       if {$base == ""} {
+               set base .pgaw:AddField
+       }
+       if {[winfo exists $base]} {
+               wm deiconify $base; return
+       }
+       toplevel $base -class Toplevel
+       wm focusmodel $base passive
+       wm geometry $base 302x114+195+175
+       wm maxsize $base 1009 738
+       wm minsize $base 1 1
+       wm overrideredirect $base 0
+       wm resizable $base 0 0
+       wm deiconify $base
+       wm title $base [intlmsg "Add new column"]
+       label $base.l1 \
+               -borderwidth 0 -text [intlmsg {Field name}]
+       entry $base.e1 \
+               -background #fefefe -borderwidth 1 -textvariable PgAcVar(addfield,name) 
+       bind $base.e1 <Key-KP_Enter> {
+               focus .pgaw:AddField.e2
+       }
+       bind $base.e1 <Key-Return> {
+               focus .pgaw:AddField.e2
+       }
+       label $base.l2 \
+               -borderwidth 0 \
+               -text [intlmsg {Field type}]
+       entry $base.e2 \
+               -background #fefefe -borderwidth 1 -textvariable PgAcVar(addfield,type) 
+       bind $base.e2 <Key-KP_Enter> {
+               Tables::addNewColumn
+       }
+       bind $base.e2 <Key-Return> {
+               Tables::addNewColumn
+       }
+       button $base.b1 \
+               -borderwidth 1 -command Tables::addNewColumn -text [intlmsg {Add field}]
+       button $base.b2 \
+               -borderwidth 1 -command {Window destroy .pgaw:AddField} -text [intlmsg Cancel]
+       place $base.l1 \
+               -x 25 -y 10 -anchor nw -bordermode ignore 
+       place $base.e1 \
+               -x 98 -y 7 -width 178 -height 22 -anchor nw -bordermode ignore 
+       place $base.l2 \
+               -x 25 -y 40 -anchor nw -bordermode ignore 
+       place $base.e2 \
+               -x 98 -y 37 -width 178 -height 22 -anchor nw -bordermode ignore 
+       place $base.b1 \
+               -x 70 -y 75 -anchor nw -bordermode ignore 
+       place $base.b2 \
+               -x 160 -y 75 -anchor nw -bordermode ignore 
+}
+
+
+proc vTclWindow.pgaw:RenameField {base} {
+       if {$base == ""} {
+               set base .pgaw:RenameField
+       }
+       if {[winfo exists $base]} {
+               wm deiconify $base; return
+       }
+       toplevel $base -class Toplevel
+       wm focusmodel $base passive
+       wm geometry $base 215x75+258+213
+       wm maxsize $base 1009 738
+       wm minsize $base 1 1
+       wm overrideredirect $base 0
+       wm resizable $base 0 0
+       wm deiconify $base
+       wm title $base [intlmsg "Rename column"]
+       label $base.l1 \
+               -borderwidth 0 -text [intlmsg {New name}]
+       entry $base.e1 \
+               -background #fefefe -borderwidth 1 -textvariable PgAcVar(tblinfo,new_cn)
+       bind $base.e1 <Key-KP_Enter> "Tables::renameColumn"
+       bind $base.e1 <Key-Return> "Tables::renameColumn"
+       frame $base.f \
+               -height 75 -relief groove -width 147 
+       button $base.f.b1 \
+               -borderwidth 1 -command Tables::renameColumn -text [intlmsg Rename]
+       button $base.f.b2 \
+               -borderwidth 1 -command {Window destroy .pgaw:RenameField} -text [intlmsg Cancel]
+       label $base.l2 -borderwidth 0 
+       grid $base.l1 \
+               -in .pgaw:RenameField -column 0 -row 0 -columnspan 1 -rowspan 1 
+       grid $base.e1 \
+               -in .pgaw:RenameField -column 1 -row 0 -columnspan 1 -rowspan 1 
+       grid $base.f \
+               -in .pgaw:RenameField -column 0 -row 4 -columnspan 2 -rowspan 1 
+       grid $base.f.b1 \
+               -in .pgaw:RenameField.f -column 0 -row 0 -columnspan 1 -rowspan 1 
+       grid $base.f.b2 \
+               -in .pgaw:RenameField.f -column 1 -row 0 -columnspan 1 -rowspan 1 
+       grid $base.l2 \
+               -in .pgaw:RenameField -column 0 -row 3 -columnspan 1 -rowspan 1 
+}
+
+proc vTclWindow.pgaw:Permissions {base} {
+       if {$base == ""} {
+               set base .pgaw:Permissions
+       }
+       if {[winfo exists $base]} {
+               wm deiconify $base; return
+       }
+       toplevel $base -class Toplevel
+       wm focusmodel $base passive
+       wm geometry $base 273x147+256+266
+       wm maxsize $base 1009 738
+       wm minsize $base 1 1
+       wm overrideredirect $base 0
+       wm resizable $base 0 0
+       wm deiconify $base
+       wm title $base [intlmsg "Permissions"]
+       frame $base.f1 \
+               -height 103 -relief groove -width 125 
+       label $base.f1.l \
+               -borderwidth 0 -relief raised -text [intlmsg {User name}]
+       entry $base.f1.ename -textvariable PgAcVar(permission,username) \
+               -background #fefefe -borderwidth 1 
+       label $base.f1.l2 \
+               -borderwidth 0 -relief raised -text { } 
+       label $base.f1.l3 \
+               -borderwidth 0 -relief raised -text { } 
+       frame $base.f2 \
+               -height 75 -relief groove -borderwidth 2 -width 125 
+       checkbutton $base.f2.cb1 -borderwidth 1 -padx 4 -pady 4 \
+               -text [intlmsg select] -variable PgAcVar(permission,select) 
+       checkbutton $base.f2.cb2 -borderwidth 1 -padx 4 -pady 4 \
+               -text [intlmsg update] -variable PgAcVar(permission,update)
+       checkbutton $base.f2.cb3 -borderwidth 1 -padx 4 -pady 4 \
+               -text [intlmsg insert] -variable PgAcVar(permission,insert)
+       checkbutton $base.f2.cb4 -borderwidth 1 -padx 4 -pady 4 \
+               -text [intlmsg rule] -variable PgAcVar(permission,rule)
+       frame $base.fb \
+               -height 75 -relief groove -width 125 
+       button $base.fb.btnsave -command Tables::savePermissions \
+               -padx 9 -pady 3 -text [intlmsg Save]
+       button $base.fb.btncancel -command {Window destroy .pgaw:Permissions} \
+               -padx 9 -pady 3 -text [intlmsg Cancel]
+       pack $base.f1 \
+               -in .pgaw:Permissions -anchor center -expand 0 -fill none -side top 
+       grid $base.f1.l \
+               -in .pgaw:Permissions.f1 -column 0 -row 1 -columnspan 1 -rowspan 1 
+       grid $base.f1.ename \
+               -in .pgaw:Permissions.f1 -column 1 -row 1 -columnspan 1 -rowspan 1 -padx 2 
+       grid $base.f1.l2 \
+               -in .pgaw:Permissions.f1 -column 0 -row 0 -columnspan 1 -rowspan 1 
+       grid $base.f1.l3 \
+               -in .pgaw:Permissions.f1 -column 0 -row 2 -columnspan 1 -rowspan 1 
+       pack $base.f2 \
+               -in .pgaw:Permissions -anchor center -expand 0 -fill none -side top 
+       grid $base.f2.cb1 \
+               -in .pgaw:Permissions.f2 -column 0 -row 1 -columnspan 1 -rowspan 1 -sticky w 
+       grid $base.f2.cb2 \
+               -in .pgaw:Permissions.f2 -column 1 -row 1 -columnspan 1 -rowspan 1 -sticky w 
+       grid $base.f2.cb3 \
+               -in .pgaw:Permissions.f2 -column 0 -row 2 -columnspan 1 -rowspan 1 -sticky w 
+       grid $base.f2.cb4 \
+               -in .pgaw:Permissions.f2 -column 1 -row 2 -columnspan 1 -rowspan 1 -sticky w 
+       pack $base.fb \
+               -in .pgaw:Permissions -anchor center -expand 0 -fill none -pady 3 -side bottom 
+       grid $base.fb.btnsave \
+               -in .pgaw:Permissions.fb -column 0 -row 0 -columnspan 1 -rowspan 1 
+       grid $base.fb.btncancel \
+               -in .pgaw:Permissions.fb -column 1 -row 0 -columnspan 1 -rowspan 1 
+}
diff --git a/src/bin/pgaccess/lib/users.tcl b/src/bin/pgaccess/lib/users.tcl
new file mode 100644 (file)
index 0000000..18204e0
--- /dev/null
@@ -0,0 +1,155 @@
+namespace eval Users {
+
+proc {new} {} {
+global PgAcVar
+       Window show .pgaw:User
+       wm transient .pgaw:User .pgaw:Main
+       set PgAcVar(user,action) "CREATE"
+       set PgAcVar(user,name) {}
+       set PgAcVar(user,password) {}
+       set PgAcVar(user,createdb) NOCREATEDB
+       set PgAcVar(user,createuser) NOCREATEUSER
+       set PgAcVar(user,verifypassword) {}
+       set PgAcVar(user,validuntil) {}
+       focus .pgaw:User.e1
+}
+
+proc {design} {username} {
+global PgAcVar CurrentDB
+       Window show .pgaw:User
+       tkwait visibility .pgaw:User
+       wm transient .pgaw:User .pgaw:Main
+       wm title .pgaw:User [intlmsg "Change user"]
+       set PgAcVar(user,action) "ALTER"
+       set PgAcVar(user,name) $username
+       set PgAcVar(user,password) {} ; set PgAcVar(user,verifypassword) {}
+       pg_select $CurrentDB "select *,date(valuntil) as valdata from pg_user where usename='$username'" tup {
+               if {$tup(usesuper)=="t"} {
+                       set PgAcVar(user,createuser) CREATEUSER
+               } else {
+                       set PgAcVar(user,createuser) NOCREATEUSER
+               }
+               if {$tup(usecreatedb)=="t"} {
+                       set PgAcVar(user,createdb) CREATEDB
+               } else {
+                       set PgAcVar(user,createdb) NOCREATEDB
+               }
+               if {$tup(valuntil)!=""} {
+                       set PgAcVar(user,validuntil) $tup(valdata)
+               } else {
+                       set PgAcVar(user,validuntil) {}
+               }
+       }
+       .pgaw:User.e1 configure -state disabled
+       .pgaw:User.b1 configure -text [intlmsg Save]
+       focus .pgaw:User.e2
+}
+
+proc {save} {} {
+global PgAcVar CurrentDB
+       set PgAcVar(user,name) [string trim $PgAcVar(user,name)]
+       set PgAcVar(user,password) [string trim $PgAcVar(user,password)]
+       set PgAcVar(user,verifypassword) [string trim $PgAcVar(user,verifypassword)]
+       if {$PgAcVar(user,name)==""} {
+               showError [intlmsg "User without name?"]
+               focus .pgaw:User.e1
+               return
+       }
+       if {$PgAcVar(user,password)!=$PgAcVar(user,verifypassword)} {
+               showError [intlmsg "Passwords do not match!"]
+               set PgAcVar(user,password) {} ; set PgAcVar(user,verifypassword) {}
+               focus .pgaw:User.e2
+               return
+       }
+       set cmd "$PgAcVar(user,action) user \"$PgAcVar(user,name)\""
+       if {$PgAcVar(user,password)!=""} {
+               set cmd "$cmd WITH PASSWORD \"$PgAcVar(user,password)\" "
+       }
+       set cmd "$cmd $PgAcVar(user,createdb) $PgAcVar(user,createuser)"
+       if {$PgAcVar(user,validuntil)!=""} {
+               set cmd "$cmd VALID UNTIL '$PgAcVar(user,validuntil)'"
+       }
+       if {[sql_exec noquiet $cmd]} {
+               Window destroy .pgaw:User
+               Mainlib::cmd_Users
+       }
+}
+
+}
+
+proc vTclWindow.pgaw:User {base} {
+       if {$base == ""} {
+               set base .pgaw:User
+       }
+       if {[winfo exists $base]} {
+               wm deiconify $base; return
+       }
+       toplevel $base -class Toplevel
+       wm focusmodel $base passive
+       wm geometry $base 263x220+233+165
+       wm maxsize $base 1009 738
+       wm minsize $base 1 1
+       wm overrideredirect $base 0
+       wm resizable $base 0 0
+       wm deiconify $base
+       wm title $base [intlmsg "Define new user"]
+       label $base.l1 \
+               -borderwidth 0 -anchor w -text [intlmsg "User name"]
+       entry $base.e1 \
+               -background #fefefe -borderwidth 1 -textvariable PgAcVar(user,name) 
+       bind $base.e1 <Key-Return> "focus .pgaw:User.e2"
+       bind $base.e1 <Key-KP_Enter> "focus .pgaw:User.e2"
+       label $base.l2 \
+               -borderwidth 0 -text [intlmsg Password]
+       entry $base.e2 \
+               -background #fefefe -borderwidth 1 -show * -textvariable PgAcVar(user,password) 
+       bind $base.e2 <Key-Return> "focus .pgaw:User.e3"
+       bind $base.e2 <Key-KP_Enter> "focus .pgaw:User.e3"
+       label $base.l3 \
+               -borderwidth 0 -text [intlmsg {verify password}]
+       entry $base.e3 \
+               -background #fefefe -borderwidth 1 -show * -textvariable PgAcVar(user,verifypassword) 
+       bind $base.e3 <Key-Return> "focus .pgaw:User.cb1"
+       bind $base.e3 <Key-KP_Enter> "focus .pgaw:User.cb1"
+       checkbutton $base.cb1 \
+               -borderwidth 1 -offvalue NOCREATEDB -onvalue CREATEDB \
+               -text [intlmsg {Allow user to create databases}] -variable PgAcVar(user,createdb) 
+       checkbutton $base.cb2 \
+               -borderwidth 1 -offvalue NOCREATEUSER -onvalue CREATEUSER \
+               -text [intlmsg {Allow user to create other users}] -variable PgAcVar(user,createuser) 
+       label $base.l4 \
+               -borderwidth 0 -anchor w -text [intlmsg {Valid until (date)}]
+       entry $base.e4 \
+               -background #fefefe -borderwidth 1 -textvariable PgAcVar(user,validuntil)
+       bind $base.e4 <Key-Return> "focus .pgaw:User.b1"
+       bind $base.e4 <Key-KP_Enter> "focus .pgaw:User.b1"
+       button $base.b1 \
+               -borderwidth 1 -command Users::save -text [intlmsg Create]
+       button $base.b2 \
+               -borderwidth 1 -command {Window destroy .pgaw:User} -text [intlmsg Cancel]
+       place $base.l1 \
+               -x 5 -y 7 -height 16 -anchor nw -bordermode ignore 
+       place $base.e1 \
+               -x 109 -y 5 -width 146 -height 20 -anchor nw -bordermode ignore 
+       place $base.l2 \
+               -x 5 -y 35 -anchor nw -bordermode ignore 
+       place $base.e2 \
+               -x 109 -y 32 -width 146 -height 20 -anchor nw -bordermode ignore 
+       place $base.l3 \
+               -x 5 -y 60 -anchor nw -bordermode ignore 
+       place $base.e3 \
+               -x 109 -y 58 -width 146 -height 20 -anchor nw -bordermode ignore 
+       place $base.cb1 \
+               -x 5 -y 90 -anchor nw -bordermode ignore 
+       place $base.cb2 \
+               -x 5 -y 115 -anchor nw -bordermode ignore 
+       place $base.l4 \
+               -x 5 -y 145 -height 16 -anchor nw -bordermode ignore 
+       place $base.e4 \
+               -x 110 -y 143 -width 146 -height 20 -anchor nw -bordermode ignore 
+       place $base.b1 \
+               -x 45 -y 185 -anchor nw -width 70 -height 25 -bordermode ignore 
+       place $base.b2 \
+               -x 140 -y 185 -anchor nw -width 70 -height 25 -bordermode ignore 
+}
+
diff --git a/src/bin/pgaccess/lib/views.tcl b/src/bin/pgaccess/lib/views.tcl
new file mode 100644 (file)
index 0000000..dc520a5
--- /dev/null
@@ -0,0 +1,45 @@
+namespace eval Views {
+
+proc {new} {} {
+global PgAcVar
+       set PgAcVar(query,oid) 0
+       set PgAcVar(query,name) {}
+       Window show .pgaw:QueryBuilder
+       set PgAcVar(query,asview) 1
+       .pgaw:QueryBuilder.saveAsView configure -state disabled
+}
+
+
+proc {open} {viewname} {
+global PgAcVar
+       if {$viewname==""} return;
+       set wn [Tables::getNewWindowName]
+       Tables::createWindow
+       set PgAcVar(mw,$wn,query) "select * from \"$viewname\""
+       set PgAcVar(mw,$wn,isaquery) 0
+       set PgAcVar(mw,$wn,updatable) 0
+       Tables::loadLayout $wn $viewname
+       Tables::selectRecords $wn $PgAcVar(mw,$wn,query)
+}
+
+
+proc {design} {viewname} {
+global PgAcVar CurrentDB
+       set vd {}
+       wpg_select $CurrentDB "select pg_get_viewdef('$viewname')as vd" tup {
+               set vd $tup(vd)
+       }
+       if {$vd==""} {
+               showError "[intlmsg {Error retrieving view definition for}] '$viewname'!"
+               return
+       }
+       Window show .pgaw:QueryBuilder
+       .pgaw:QueryBuilder.text1 delete 0.0 end
+       .pgaw:QueryBuilder.text1 insert end $vd
+       set PgAcVar(query,asview) 1
+       .pgaw:QueryBuilder.saveAsView configure -state disabled
+       set PgAcVar(query,name) $viewname
+}
+
+
+}
diff --git a/src/bin/pgaccess/lib/visualqb.tcl b/src/bin/pgaccess/lib/visualqb.tcl
new file mode 100644 (file)
index 0000000..dc4189e
--- /dev/null
@@ -0,0 +1,776 @@
+namespace eval VisualQueryBuilder {
+
+# The following array will hold all the local variables
+
+variable vqb
+
+proc {addNewTable} {{tabx 0} {taby 0} {alias -1}} {
+global PgAcVar CurrentDB
+variable vqb
+if {$vqb(newtablename)==""} return
+set fldlist {}
+setCursor CLOCK
+wpg_select $CurrentDB "select attnum,attname from pg_class,pg_attribute where (pg_class.relname='$vqb(newtablename)') and (pg_class.oid=pg_attribute.attrelid) and (attnum>0) order by attnum" rec {
+               lappend fldlist $rec(attname)
+}
+setCursor DEFAULT
+if {$fldlist==""} {
+       showError [format [intlmsg "Table '%s' not found!"] $vqb(newtablename)]
+       return
+}
+if {$alias==-1} {
+       set tabnum $vqb(ntables)
+} else {
+       regsub t $alias "" tabnum
+}
+set vqb(tablename$tabnum) $vqb(newtablename)
+set vqb(tablestruct$tabnum) $fldlist
+set vqb(tablealias$tabnum) "t$tabnum"
+set vqb(ali_t$tabnum) $vqb(newtablename)
+set vqb(tablex$tabnum) $tabx
+set vqb(tabley$tabnum) $taby
+
+incr vqb(ntables)
+if {$vqb(ntables)==1} {
+       repaintAll
+} else {
+       drawTable [expr $vqb(ntables)-1]
+}
+set vqb(newtablename) {}
+focus .pgaw:VisualQuery.fb.entt
+}
+
+proc {computeSQL} {} {
+global PgAcVar
+variable vqb
+set sqlcmd "select "
+#rjr 8Mar1999 added logical return state for results
+for {set i 0} {$i<[llength $vqb(resfields)]} {incr i} {
+       if {[lindex $vqb(resreturn) $i]==[intlmsg Yes]} {
+               if {$sqlcmd!="select "} {set sqlcmd "$sqlcmd, "}
+               set sqlcmd "$sqlcmd[lindex $vqb(restables) $i].\"[lindex $vqb(resfields) $i]\""
+       }
+}
+set tables {}
+for {set i 0} {$i<$vqb(ntables)} {incr i} {
+       set thename {}
+       catch {set thename $vqb(tablename$i)}
+       if {$thename!=""} {lappend tables "\"$vqb(tablename$i)\" $vqb(tablealias$i)"}
+}
+set sqlcmd "$sqlcmd from [join $tables ,] "
+set sup1 {}
+if {[llength $vqb(links)]>0} {
+       set sup1 "where "
+       foreach link $vqb(links) {
+               if {$sup1!="where "} {set sup1 "$sup1 and "}
+               set sup1 "$sup1 ([lindex $link 0].\"[lindex $link 1]\"=[lindex $link 2].\"[lindex $link 3]\")"
+       }
+}
+for {set i 0} {$i<[llength $vqb(resfields)]} {incr i} {
+       set crit [lindex $vqb(rescriteria) $i]
+       if {$crit!=""} {
+               if {$sup1==""} {set sup1 "where "}
+               if {[string length $sup1]>6} {set sup1 "$sup1 and "}
+               set sup1 "$sup1 ([lindex $vqb(restables) $i].\"[lindex $vqb(resfields) $i]\" $crit) "        
+       }        
+}
+set sqlcmd "$sqlcmd $sup1"
+set sup2 {}
+for {set i 0} {$i<[llength $vqb(ressort)]} {incr i} {
+       set how [lindex $vqb(ressort) $i]
+       if {$how!="unsorted"} {
+               if {$how=="Ascending"} {set how asc} else {set how desc}
+               if {$sup2==""} {set sup2 " order by "} else {set sup2 "$sup2,"}
+               set sup2 "$sup2 [lindex $vqb(restables) $i].\"[lindex $vqb(resfields) $i]\" $how "
+       }
+}
+set sqlcmd "$sqlcmd $sup2"
+set vqb(qcmd) $sqlcmd
+return $sqlcmd
+}
+
+proc {deleteObject} {} {
+global PgAcVar
+variable vqb
+# Checking if there is a highlighted object (i.e. is selected)
+set obj [.pgaw:VisualQuery.c find withtag hili]
+if {$obj==""} return
+#
+# Is object a link ?
+if {[getTagInfo $obj link]=="s"} {
+       if {[tk_messageBox -title [intlmsg Warning] -icon question -parent .pgaw:VisualQuery -message [intlmsg "Remove link ?"] -type yesno -default no]=="no"} return
+       set linkid [getTagInfo $obj lkid]
+       set vqb(links) [lreplace $vqb(links) $linkid $linkid]
+       .pgaw:VisualQuery.c delete links
+       drawLinks
+       return
+}
+#
+# Is object a result field ?
+if {[getTagInfo $obj res]=="f"} {
+       set col [getTagInfo $obj col]
+       if {$col==""} return
+       if {[tk_messageBox -title [intlmsg Warning] -icon question -parent .pgaw:VisualQuery -message [intlmsg "Remove field from result ?"] -type yesno -default no]=="no"} return
+       set vqb(resfields) [lreplace $vqb(resfields) $col $col]
+       set vqb(ressort) [lreplace $vqb(ressort) $col $col]
+       set vqb(resreturn) [lreplace $vqb(resreturn) $col $col]
+       set vqb(restables) [lreplace $vqb(restables) $col $col]
+       set vqb(rescriteria) [lreplace $vqb(rescriteria) $col $col]
+       drawResultPanel
+       return
+}
+#
+# Is object a table ?
+set tablealias [getTagInfo $obj tab]
+set tablename $vqb(ali_$tablealias)
+if {"$tablename"==""} return
+if {[tk_messageBox -title [intlmsg Warning] -icon question -parent .pgaw:VisualQuery -message [format [intlmsg "Remove table %s from query?"] $tablename] -type yesno -default no]=="no"} return
+for {set i [expr [llength $vqb(restables)]-1]} {$i>=0} {incr i -1} {
+       if {"$tablealias"==[lindex $vqb(restables) $i]} {
+          set vqb(resfields) [lreplace $vqb(resfields) $i $i]
+          set vqb(ressort) [lreplace $vqb(ressort) $i $i]
+          set vqb(resreturn) [lreplace $vqb(resreturn) $i $i]
+          set vqb(restables) [lreplace $vqb(restables) $i $i]
+          set vqb(rescriteria) [lreplace $vqb(rescriteria) $i $i]
+       }
+}
+for {set i [expr [llength $vqb(links)]-1]} {$i>=0} {incr i -1} {
+       set thelink [lindex $vqb(links) $i]
+       if {($tablealias==[lindex $thelink 0]) || ($tablealias==[lindex $thelink 2])} {
+               set vqb(links) [lreplace $vqb(links) $i $i]
+       }
+}
+for {set i 0} {$i<$vqb(ntables)} {incr i} {
+       set temp {}
+       catch {set temp $vqb(tablename$i)}
+       if {"$temp"=="$tablename"} {
+               unset vqb(tablename$i)
+               unset vqb(tablestruct$i)
+               unset vqb(tablealias$i)
+               break
+       }
+}
+unset vqb(ali_$tablealias)
+#incr vqb(ntables) -1
+.pgaw:VisualQuery.c delete tab$tablealias
+.pgaw:VisualQuery.c delete links
+drawLinks
+drawResultPanel
+}
+
+
+proc {dragObject} {w x y} {
+global PgAcVar
+variable vqb
+       if {"$PgAcVar(draginfo,obj)" == ""} {return}
+       set dx [expr $x - $PgAcVar(draginfo,x)]
+       set dy [expr $y - $PgAcVar(draginfo,y)]
+       if {$PgAcVar(draginfo,is_a_table)} {
+               $w move $PgAcVar(draginfo,tabletag) $dx $dy
+               drawLinks
+       } else {
+               $w move $PgAcVar(draginfo,obj) $dx $dy
+       }
+       set PgAcVar(draginfo,x) $x
+       set PgAcVar(draginfo,y) $y
+}
+
+
+proc {dragStart} {w x y} {
+global PgAcVar
+variable vqb
+PgAcVar:clean draginfo,*
+set PgAcVar(draginfo,obj) [$w find closest $x $y]
+if {[getTagInfo $PgAcVar(draginfo,obj) r]=="ect"} {
+       # If it'a a rectangle, exit
+       set PgAcVar(draginfo,obj) {}
+       return
+}
+.pgaw:VisualQuery configure -cursor hand1
+.pgaw:VisualQuery.c raise $PgAcVar(draginfo,obj)
+set PgAcVar(draginfo,table) 0
+if {[getTagInfo $PgAcVar(draginfo,obj) table]=="header"} {
+       set PgAcVar(draginfo,is_a_table) 1
+       set taglist [.pgaw:VisualQuery.c gettags $PgAcVar(draginfo,obj)]
+       set PgAcVar(draginfo,tabletag) [lindex $taglist [lsearch -regexp $taglist "^tab\[0-9\]*"]]
+       .pgaw:VisualQuery.c raise $PgAcVar(draginfo,tabletag)
+       .pgaw:VisualQuery.c itemconfigure [.pgaw:VisualQuery.c find withtag hili] -fill black
+       .pgaw:VisualQuery.c dtag [.pgaw:VisualQuery.c find withtag hili] hili
+       .pgaw:VisualQuery.c addtag hili withtag $PgAcVar(draginfo,obj)
+       .pgaw:VisualQuery.c itemconfigure hili -fill blue
+} else {
+       set PgAcVar(draginfo,is_a_table) 0
+}
+set PgAcVar(draginfo,x) $x
+set PgAcVar(draginfo,y) $y
+set PgAcVar(draginfo,sx) $x
+set PgAcVar(draginfo,sy) $y
+}
+
+
+proc {dragStop} {x y} {
+global PgAcVar
+variable vqb
+# when click Close, ql window is destroyed but event ButtonRelease-1 is fired
+if {![winfo exists .pgaw:VisualQuery]} return;
+.pgaw:VisualQuery configure -cursor left_ptr
+set este {}
+catch {set este $PgAcVar(draginfo,obj)}
+if {$este==""} return
+# Re-establish the normal paint order so
+# information won't be overlapped by table rectangles
+# or link lines
+.pgaw:VisualQuery.c lower $PgAcVar(draginfo,obj)
+.pgaw:VisualQuery.c lower rect
+.pgaw:VisualQuery.c lower links
+set vqb(panstarted) 0
+if {$PgAcVar(draginfo,is_a_table)} {
+       set tabnum [getTagInfo $PgAcVar(draginfo,obj) tabt]
+       foreach w [.pgaw:VisualQuery.c find withtag $PgAcVar(draginfo,tabletag)] {
+               if {[lsearch [.pgaw:VisualQuery.c gettags $w] outer] != -1} {
+                       foreach [list vqb(tablex$tabnum) vqb(tabley$tabnum) x1 y1] [.pgaw:VisualQuery.c coords $w] {}
+               }
+       }
+       set PgAcVar(draginfo,obj) {}
+       .pgaw:VisualQuery.c delete links
+       drawLinks
+       return
+}
+.pgaw:VisualQuery.c move $PgAcVar(draginfo,obj) [expr $PgAcVar(draginfo,sx)-$x] [expr $PgAcVar(draginfo,sy)-$y]
+if {($y>$vqb(yoffs)) && ($x>$vqb(xoffs))} {
+       # Drop position : inside the result panel
+       # Compute the offset of the result panel due to panning
+       set resoffset [expr [lindex [.pgaw:VisualQuery.c bbox resmarker] 0]-$vqb(xoffs)]
+       set newfld [.pgaw:VisualQuery.c itemcget $PgAcVar(draginfo,obj) -text]
+       set tabtag [getTagInfo $PgAcVar(draginfo,obj) tab]
+       set col [expr int(($x-$vqb(xoffs)-$resoffset)/$vqb(reswidth))]
+       set vqb(resfields) [linsert $vqb(resfields) $col $newfld]
+       set vqb(ressort) [linsert $vqb(ressort) $col unsorted]
+       set vqb(rescriteria) [linsert $vqb(rescriteria) $col {}]
+       set vqb(restables) [linsert $vqb(restables) $col $tabtag]
+       set vqb(resreturn) [linsert $vqb(resreturn) $col [intlmsg Yes]]
+       drawResultPanel    
+} else {
+       # Drop position : in the table panel
+       set droptarget [.pgaw:VisualQuery.c find overlapping $x $y $x $y]
+       set targettable {}
+       foreach item $droptarget {
+               set targettable [getTagInfo $item tab]
+               set targetfield [getTagInfo $item f-]
+               if {($targettable!="") && ($targetfield!="")} {
+                       set droptarget $item
+                       break
+               }
+       }
+       # check if target object isn't a rectangle
+       if {[getTagInfo $droptarget rec]=="t"} {set targettable {}}
+       if {$targettable!=""} {
+               # Target has a table
+               # See about originate table
+               set sourcetable [getTagInfo $PgAcVar(draginfo,obj) tab]
+               if {$sourcetable!=""} {
+                       # Source has also a tab .. tag
+                       set sourcefield [getTagInfo $PgAcVar(draginfo,obj) f-]
+                       if {$sourcetable!=$targettable} {
+                               lappend vqb(links) [list $sourcetable $sourcefield $targettable $targetfield]
+                               drawLinks
+                       }
+               }
+       }
+}
+# Erase information about onbject beeing dragged
+set PgAcVar(draginfo,obj) {}
+}
+
+
+proc {getTableList} {} {
+global PgAcVar
+variable vqb
+       set tablelist {}
+       foreach name [array names vqb tablename*] {
+               regsub tablename $name "" num
+               lappend tablelist $vqb($name) $vqb(tablex$num) $vqb(tabley$num) t$num
+       }
+       return $tablelist
+}
+
+
+proc {getLinkList} {} {
+global PgAcVar
+variable vqb
+       set linklist {}
+       foreach l $vqb(links) {
+               lappend linklist [lindex $l 0] [lindex $l 1] [lindex $l 2] [lindex $l 3] 
+               }
+       return $linklist
+}
+
+
+proc {loadVisualLayout} {} {
+global PgAcVar
+variable vqb
+       init
+       foreach {t x y a} $PgAcVar(query,tables) {set vqb(newtablename) $t; addNewTable $x $y $a}
+       foreach {t0 f0 t1 f1} $PgAcVar(query,links) {lappend vqb(links) [list $t0 $f0 $t1 $f1]}
+       foreach {f t s c r} $PgAcVar(query,results) {addResultColumn $f $t $s $c $r}
+       repaintAll
+}
+
+
+proc {findField} {alias field} {
+       foreach obj [.pgaw:VisualQuery.c find withtag f-${field}] {
+               if {[lsearch [.pgaw:VisualQuery.c gettags $obj] tab$alias] != -1} {return $obj}
+       }
+       return -1
+}
+
+
+proc {getResultList} {} {
+global PgAcVar
+variable vqb
+       set reslist {}
+       for {set i 0} {$i < [llength $vqb(resfields)]} {incr i} {
+               lappend reslist [lindex $vqb(resfields) $i]
+               lappend reslist [lindex $vqb(restables) $i]
+               lappend reslist [lindex $vqb(ressort) $i]
+               lappend reslist [lindex $vqb(rescriteria) $i]
+               lappend reslist [lindex $vqb(resreturn) $i]
+       }
+       return $reslist
+}
+
+
+proc {addResultColumn} {f t s c r} {
+global PgAcVar
+variable vqb
+       lappend vqb(resfields) $f
+       lappend vqb(restables) $t
+       lappend vqb(ressort) $s
+       lappend vqb(rescriteria) $c
+       lappend vqb(resreturn) $r
+}
+
+
+proc {drawLinks} {} {
+global PgAcVar
+variable vqb
+.pgaw:VisualQuery.c delete links
+set i 0
+foreach link $vqb(links) {
+       # Compute the source and destination right edge
+       set sre [lindex [.pgaw:VisualQuery.c bbox tab[lindex $link 0]] 2]
+       set dre [lindex [.pgaw:VisualQuery.c bbox tab[lindex $link 2]] 2]
+       # Compute field bound boxes
+       set sbbox [.pgaw:VisualQuery.c bbox [findField [lindex $link 0] [lindex $link 1]]]
+       set dbbox [.pgaw:VisualQuery.c bbox [findField [lindex $link 2] [lindex $link 3]]]
+       # Compute the auxiliary lines
+       if {[lindex $sbbox 2] < [lindex $dbbox 0]} {
+               # Source object is on the left of target object
+               set x1 $sre
+               set y1 [expr ([lindex $sbbox 1]+[lindex $sbbox 3])/2]
+               .pgaw:VisualQuery.c create line $x1 $y1 [expr $x1+10] $y1 -tags [subst {links lkid$i}] -width 3
+               set x2 [lindex $dbbox 0]
+               set y2 [expr ([lindex $dbbox 1]+[lindex $dbbox 3])/2]
+               .pgaw:VisualQuery.c create line [expr $x2-10] $y2 $x2 $y2 -tags [subst {links lkid$i}] -width 3
+               .pgaw:VisualQuery.c create line [expr $x1+10] $y1 [expr $x2-10] $y2 -tags [subst {links lkid$i}] -width 2
+       } else {
+               # source object is on the right of target object
+               set x1 [lindex $sbbox 0]
+               set y1 [expr ([lindex $sbbox 1]+[lindex $sbbox 3])/2]
+               .pgaw:VisualQuery.c create line $x1 $y1 [expr $x1-10] $y1 -tags [subst {links lkid$i}] -width 3
+               set x2 $dre
+               set y2 [expr ([lindex $dbbox 1]+[lindex $dbbox 3])/2]
+               .pgaw:VisualQuery.c create line $x2 $y2 [expr $x2+10] $y2 -width 3 -tags [subst {links lkid$i}]
+               .pgaw:VisualQuery.c create line [expr $x1-10] $y1 [expr $x2+10] $y2 -tags [subst {links lkid$i}] -width 2
+       }
+       incr i
+}
+.pgaw:VisualQuery.c lower links
+.pgaw:VisualQuery.c bind links <Button-1> {VisualQueryBuilder::linkClick %x %y}
+}
+
+
+proc {repaintAll} {} {
+global PgAcVar
+variable vqb
+.pgaw:VisualQuery.c delete all
+set posx 20
+foreach tn [array names vqb tablename*] {
+       regsub tablename $tn "" it
+       drawTable $it
+}
+.pgaw:VisualQuery.c lower rect
+.pgaw:VisualQuery.c create line 0 $vqb(yoffs) 10000 $vqb(yoffs) -width 3
+.pgaw:VisualQuery.c create rectangle 0 $vqb(yoffs) 10000 5000 -fill #FFFFFF
+for {set i [expr 15+$vqb(yoffs)]} {$i<500} {incr i 15} {
+       .pgaw:VisualQuery.c create line $vqb(xoffs) $i 10000 $i -fill #CCCCCC -tags {resgrid}
+}    
+for {set i $vqb(xoffs)} {$i<10000} {incr i $vqb(reswidth)} {
+       .pgaw:VisualQuery.c create line $i [expr 1+$vqb(yoffs)] $i 10000 -fill #cccccc -tags {resgrid}
+}
+# Make a marker for result panel offset calculations (due to panning)
+.pgaw:VisualQuery.c create line $vqb(xoffs) $vqb(yoffs) $vqb(xoffs) 500 -tags {resmarker resgrid}
+.pgaw:VisualQuery.c create rectangle 0 $vqb(yoffs) $vqb(xoffs) 5000 -fill #EEEEEE -tags {reshdr}
+.pgaw:VisualQuery.c create text 5 [expr 1+$vqb(yoffs)]  -text [intlmsg Field] -anchor nw -font $PgAcVar(pref,font_normal) -tags {reshdr}
+.pgaw:VisualQuery.c create text 5 [expr 16+$vqb(yoffs)] -text [intlmsg Table] -anchor nw -font $PgAcVar(pref,font_normal) -tags {reshdr}
+.pgaw:VisualQuery.c create text 5 [expr 31+$vqb(yoffs)] -text [intlmsg Sort] -anchor nw -font $PgAcVar(pref,font_normal) -tags {reshdr}
+.pgaw:VisualQuery.c create text 5 [expr 46+$vqb(yoffs)] -text [intlmsg Criteria] -anchor nw -font $PgAcVar(pref,font_normal) -tags {reshdr}
+.pgaw:VisualQuery.c create text 5 [expr 61+$vqb(yoffs)] -text [intlmsg Return] -anchor nw -font $PgAcVar(pref,font_normal) -tags {reshdr}
+
+drawLinks
+drawResultPanel
+
+.pgaw:VisualQuery.c bind mov <Button-1> {VisualQueryBuilder::dragStart %W %x %y}
+.pgaw:VisualQuery.c bind mov <B1-Motion> {VisualQueryBuilder::dragObject %W %x %y}
+bind .pgaw:VisualQuery <ButtonRelease-1> {VisualQueryBuilder::dragStop %x %y}
+bind .pgaw:VisualQuery <Button-1> {VisualQueryBuilder::canvasClick %x %y %W}
+bind .pgaw:VisualQuery <B1-Motion> {VisualQueryBuilder::panning %x %y}
+bind .pgaw:VisualQuery <Key-Delete> {VisualQueryBuilder::deleteObject}
+}
+
+
+proc {drawResultPanel} {} {
+global PgAcVar
+variable vqb
+# Compute the offset of the result panel due to panning
+set resoffset [expr [lindex [.pgaw:VisualQuery.c bbox resmarker] 0]-$vqb(xoffs)]
+.pgaw:VisualQuery.c delete resp
+for {set i 0} {$i<[llength $vqb(resfields)]} {incr i} {
+       .pgaw:VisualQuery.c create text [expr $resoffset+4+$vqb(xoffs)+$i*$vqb(reswidth)] [expr 1+$vqb(yoffs)] -text [lindex $vqb(resfields) $i] -anchor nw -tags [subst {resf resp col$i}] -font $PgAcVar(pref,font_normal)
+       .pgaw:VisualQuery.c create text [expr $resoffset+4+$vqb(xoffs)+$i*$vqb(reswidth)] [expr 16+$vqb(yoffs)] -text $vqb(ali_[lindex $vqb(restables) $i]) -anchor nw -tags {resp rest} -font $PgAcVar(pref,font_normal)
+       .pgaw:VisualQuery.c create text [expr $resoffset+4+$vqb(xoffs)+$i*$vqb(reswidth)] [expr 31+$vqb(yoffs)] -text [lindex $vqb(ressort) $i] -anchor nw -tags {resp sort} -font $PgAcVar(pref,font_normal)
+       if {[lindex $vqb(rescriteria) $i]!=""} {
+               .pgaw:VisualQuery.c create text [expr $resoffset+4+$vqb(xoffs)+$i*$vqb(reswidth)]  [expr $vqb(yoffs)+46+15*0] -anchor nw -text [lindex $vqb(rescriteria) $i]  -font $PgAcVar(pref,font_normal) -tags [subst {resp cr-c$i-r0}]
+       }
+       .pgaw:VisualQuery.c create text [expr $resoffset+4+$vqb(xoffs)+$i*$vqb(reswidth)] [expr 61+$vqb(yoffs)] -text [lindex $vqb(resreturn) $i] -anchor nw -tags {resp retval} -font $PgAcVar(pref,font_normal)
+}
+.pgaw:VisualQuery.c raise reshdr
+.pgaw:VisualQuery.c bind resf <Button-1> {VisualQueryBuilder::resultFieldClick %x %y}
+.pgaw:VisualQuery.c bind sort <Button-1> {VisualQueryBuilder::toggleSortMode %W %x %y}
+.pgaw:VisualQuery.c bind retval <Button-1> {VisualQueryBuilder::toggleReturn %W %x %y}
+}
+
+
+proc {drawTable} {it} {
+global PgAcVar
+variable vqb
+if {$vqb(tablex$it)==0} {
+       set posy 10
+       set allbox [.pgaw:VisualQuery.c bbox rect]
+       if {$allbox==""} {set posx 10} else {set posx [expr 20+[lindex $allbox 2]]}
+       set vqb(tablex$it) $posx
+       set vqb(tabley$it) $posy
+} else {
+       set posx [expr int($vqb(tablex$it))]
+       set posy [expr int($vqb(tabley$it))]
+}
+set tablename $vqb(tablename$it)
+set tablealias $vqb(tablealias$it)
+.pgaw:VisualQuery.c create text $posx $posy -text "$tablename" -anchor nw -tags [subst {tab$tablealias f-oid mov tableheader}] -font $PgAcVar(pref,font_bold)
+incr posy 16
+foreach fld $vqb(tablestruct$it) {
+   .pgaw:VisualQuery.c create text $posx $posy -text $fld -fill #010101 -anchor nw -tags [subst {f-$fld tab$tablealias mov}] -font $PgAcVar(pref,font_normal)
+   incr posy 14
+}
+set reg [.pgaw:VisualQuery.c bbox tab$tablealias]
+.pgaw:VisualQuery.c create rectangle [lindex $reg 0] [lindex $reg 1] [lindex $reg 2] [lindex $reg 3] -fill #EEEEEE -tags [subst {rect outer tab$tablealias}]
+.pgaw:VisualQuery.c create line [lindex $reg 0] [expr [lindex $reg 1]+15] [lindex $reg 2] [expr [lindex $reg 1]+15] -tags [subst {rect tab$tablealias}]
+.pgaw:VisualQuery.c lower tab$tablealias
+.pgaw:VisualQuery.c lower rect
+}
+
+
+proc {getTagInfo} {obj prefix} {
+variable vqb
+       set taglist [.pgaw:VisualQuery.c gettags $obj]
+       set tagpos [lsearch -regexp $taglist "^$prefix"]
+       if {$tagpos==-1} {return ""}
+       set thattag [lindex $taglist $tagpos]
+       return [string range $thattag [string length $prefix] end]
+}
+
+proc {init} {} {
+global PgAcVar
+variable vqb
+       catch { unset vqb }
+       set vqb(yoffs) 360
+       set vqb(xoffs) 50
+       set vqb(reswidth) 150
+       set vqb(resfields) {}
+       set vqb(resreturn) {}
+       set vqb(ressort) {}
+       set vqb(rescriteria) {}
+       set vqb(restables) {}
+       set vqb(critedit) 0
+       set vqb(links) {}
+       set vqb(ntables) 0
+       set vqb(newtablename) {}
+}
+
+
+proc {linkClick} {x y} {
+global PgAcVar
+variable vqb
+       set obj [.pgaw:VisualQuery.c find closest $x $y 1 links]
+       if {[getTagInfo $obj link]!="s"} return
+       .pgaw:VisualQuery.c itemconfigure [.pgaw:VisualQuery.c find withtag hili] -fill black
+       .pgaw:VisualQuery.c dtag [.pgaw:VisualQuery.c find withtag hili] hili
+       .pgaw:VisualQuery.c addtag hili withtag $obj
+       .pgaw:VisualQuery.c itemconfigure $obj -fill blue
+}
+
+
+proc {panning} {x y} {
+global PgAcVar
+variable vqb
+       set panstarted 0
+       catch {set panstarted $vqb(panstarted) }
+       if {!$panstarted} return
+       set dx [expr $x-$vqb(panstartx)]
+       set dy [expr $y-$vqb(panstarty)]
+       set vqb(panstartx) $x
+       set vqb(panstarty) $y
+       if {$vqb(panobject)=="tables"} {
+               .pgaw:VisualQuery.c move mov $dx $dy
+               .pgaw:VisualQuery.c move links $dx $dy
+               .pgaw:VisualQuery.c move rect $dx $dy
+       } else {
+               .pgaw:VisualQuery.c move resp $dx 0
+               .pgaw:VisualQuery.c move resgrid $dx 0
+               .pgaw:VisualQuery.c raise reshdr
+       }
+}
+
+
+proc {resultFieldClick} {x y} {
+global PgAcVar
+variable vqb
+       set obj [.pgaw:VisualQuery.c find closest $x $y]
+       if {[getTagInfo $obj res]!="f"} return
+       .pgaw:VisualQuery.c itemconfigure [.pgaw:VisualQuery.c find withtag hili] -fill black
+       .pgaw:VisualQuery.c dtag [.pgaw:VisualQuery.c find withtag hili] hili
+       .pgaw:VisualQuery.c addtag hili withtag $obj
+       .pgaw:VisualQuery.c itemconfigure $obj -fill blue
+}
+
+
+proc {showSQL} {} {
+global PgAcVar
+variable vqb
+       set sqlcmd [computeSQL]
+       .pgaw:VisualQuery.c delete sqlpage
+       .pgaw:VisualQuery.c create rectangle 0 0 2000 [expr $vqb(yoffs)-1] -fill #ffffff -tags {sqlpage}
+       .pgaw:VisualQuery.c create text 10 10 -text $sqlcmd -anchor nw -width 550 -tags {sqlpage} -font $PgAcVar(pref,font_normal)
+       .pgaw:VisualQuery.c bind sqlpage <Button-1> {.pgaw:VisualQuery.c delete sqlpage}
+}
+
+
+proc {toggleSortMode} {w x y} {
+global PgAcVar
+variable vqb
+       set obj [$w find closest $x $y]
+       set taglist [.pgaw:VisualQuery.c gettags $obj]
+       if {[lsearch $taglist sort]==-1} return
+       set how [.pgaw:VisualQuery.c itemcget $obj -text]
+       if {$how=="unsorted"} {
+               set how Ascending
+       } elseif {$how=="Ascending"} {
+               set how Descending
+       } else {
+               set how unsorted
+       }
+       set col [expr int(($x-$vqb(xoffs))/$vqb(reswidth))]
+       set vqb(ressort) [lreplace $vqb(ressort) $col $col $how]
+       .pgaw:VisualQuery.c itemconfigure $obj -text $how
+}
+
+
+#rjr 8Mar1999 toggle logical return state for result
+proc {toggleReturn} {w x y} {
+global PgAcVar
+variable vqb
+       set obj [$w find closest $x $y]
+       set taglist [.pgaw:VisualQuery.c gettags $obj]
+       if {[lsearch $taglist retval]==-1} return
+       set how [.pgaw:VisualQuery.c itemcget $obj -text]
+       if {$how==[intlmsg Yes]} {
+               set how [intlmsg No]
+       } else {
+               set how [intlmsg Yes]
+       } 
+       set col [expr int(($x-$vqb(xoffs))/$vqb(reswidth))]
+       set vqb(resreturn) [lreplace $vqb(resreturn) $col $col $how]
+       .pgaw:VisualQuery.c itemconfigure $obj -text $how
+}
+
+
+proc {canvasClick} {x y w} {
+global PgAcVar
+variable vqb
+set vqb(panstarted) 0
+if {$w==".pgaw:VisualQuery.c"} {
+       set canpan 1
+       if {$y<$vqb(yoffs)} {
+               if {[llength [.pgaw:VisualQuery.c find overlapping $x $y $x $y]]!=0} {set canpan 0}
+                       set vqb(panobject) tables
+       } else {
+               set vqb(panobject) result
+       }
+       if {$canpan} {
+               .pgaw:VisualQuery configure -cursor hand1
+               set vqb(panstartx) $x
+               set vqb(panstarty) $y
+               set vqb(panstarted) 1
+       }
+}
+set isedit 0
+catch {set isedit $vqb(critedit)}
+# Compute the offset of the result panel due to panning
+set resoffset [expr [lindex [.pgaw:VisualQuery.c bbox resmarker] 0]-$vqb(xoffs)]
+if {$isedit} {
+       set vqb(rescriteria) [lreplace $vqb(rescriteria) $vqb(critcol) $vqb(critcol) $vqb(critval)]
+       .pgaw:VisualQuery.c delete cr-c$vqb(critcol)-r$vqb(critrow)
+       .pgaw:VisualQuery.c create text [expr $resoffset+4+$vqb(xoffs)+$vqb(critcol)*$vqb(reswidth)] [expr $vqb(yoffs)+46+15*$vqb(critrow)] -anchor nw -text $vqb(critval) -font $PgAcVar(pref,font_normal) -tags [subst {resp cr-c$vqb(critcol)-r$vqb(critrow)}]
+       set vqb(critedit) 0
+}
+catch {destroy .pgaw:VisualQuery.entc}
+if {$y<[expr $vqb(yoffs)+46]} return
+if {$x<[expr $vqb(xoffs)+5]} return
+set col [expr int(($x-$vqb(xoffs)-$resoffset)/$vqb(reswidth))]
+if {$col>=[llength $vqb(resfields)]} return
+set nx [expr $col*$vqb(reswidth)+8+$vqb(xoffs)+$resoffset]
+set ny [expr $vqb(yoffs)+76]
+# Get the old criteria value
+set vqb(critval) [lindex $vqb(rescriteria) $col]
+entry .pgaw:VisualQuery.entc -textvar VisualQueryBuilder::vqb(critval) -borderwidth 0 -background #FFFFFF -highlightthickness 0 -selectborderwidth 0  -font $PgAcVar(pref,font_normal)
+place .pgaw:VisualQuery.entc -x $nx -y $ny -height 14
+focus .pgaw:VisualQuery.entc
+bind .pgaw:VisualQuery.entc <Button-1> {set VisualQueryBuilder::vqb(panstarted) 0}
+set vqb(critcol) $col
+set vqb(critrow) 0
+set vqb(critedit) 1
+}
+
+
+proc {saveToQueryBuilder} {} {
+global PgAcVar
+variable vqb
+       Window show .pgaw:QueryBuilder
+       .pgaw:QueryBuilder.text1 delete 1.0 end
+       set vqb(qcmd) [computeSQL]
+       set PgAcVar(query,tables) [getTableList]
+       set PgAcVar(query,links) [getLinkList]
+       set PgAcVar(query,results) [getResultList]
+       .pgaw:QueryBuilder.text1 insert end $vqb(qcmd)
+       focus .pgaw:QueryBuilder
+}
+
+
+proc {executeSQL} {} {
+global PgAcVar
+variable vqb
+       set vqb(qcmd) [computeSQL]
+       set wn [Tables::getNewWindowName]
+       set PgAcVar(mw,$wn,query) [subst $vqb(qcmd)]
+       set PgAcVar(mw,$wn,updatable) 0
+       set PgAcVar(mw,$wn,isaquery) 1
+       Tables::createWindow
+       Tables::loadLayout $wn nolayoutneeded
+       Tables::selectRecords $wn $PgAcVar(mw,$wn,query)
+}
+
+
+proc {createDropDown} {} {
+global PgAcVar
+variable vqb
+       if {[winfo exists .pgaw:VisualQuery.ddf]} {
+               destroy .pgaw:VisualQuery.ddf
+       } else {
+               create_drop_down .pgaw:VisualQuery 70 27 200
+               focus .pgaw:VisualQuery.ddf.sb
+               foreach tbl [Database::getTablesList] {.pgaw:VisualQuery.ddf.lb insert end $tbl}
+               bind .pgaw:VisualQuery.ddf.lb <ButtonRelease-1> {
+                       set i [.pgaw:VisualQuery.ddf.lb curselection]
+                       if {$i!=""} {
+                               set VisualQueryBuilder::vqb(newtablename) [.pgaw:VisualQuery.ddf.lb get $i]
+                               VisualQueryBuilder::addNewTable
+                       }
+                       destroy .pgaw:VisualQuery.ddf
+                       break
+               }
+       }
+}
+
+}
+
+proc vTclWindow.pgaw:VisualQuery {base} {
+global PgAcVar
+       if {$base == ""} {
+               set base .pgaw:VisualQuery
+       }
+       if {[winfo exists $base]} {
+               wm deiconify $base; return
+       }
+       toplevel $base -class Toplevel
+       wm focusmodel $base passive
+       wm geometry $base 759x530+10+13
+       wm maxsize $base 1009 738
+       wm minsize $base 1 1
+       wm overrideredirect $base 0
+       wm resizable $base 1 1
+       wm deiconify $base
+       wm title $base [intlmsg "Visual query designer"]
+       bind $base <B1-Motion> {
+               VisualQueryBuilder::panning %x %y
+       }
+       bind $base <Button-1> {
+               VisualQueryBuilder::canvasClick %x %y %W
+       }
+       bind $base <ButtonRelease-1> {
+               VisualQueryBuilder::dragStop %x %y
+       }
+       bind $base <Key-Delete> {
+               VisualQueryBuilder::deleteObject
+       }
+       bind $base <Key-F1> "Help::load visual_designer"
+       canvas $base.c  -background #fefefe -borderwidth 2 -height 207 -relief ridge  -takefocus 0 -width 295 
+       frame $base.fb -height 75 -width 125 
+       label $base.fb.l12  -borderwidth 0 -text "[intlmsg {Add table}] "
+       entry $base.fb.entt  -background #fefefe -borderwidth 1 -highlightthickness 1 \
+               -selectborderwidth 0 -textvariable VisualQueryBuilder::vqb(newtablename) 
+       bind $base.fb.entt <Key-Return> {
+               VisualQueryBuilder::addNewTable
+       }
+       button $base.fb.bdd  -borderwidth 1 \
+               -command VisualQueryBuilder::createDropDown -image dnarw 
+       button $base.fb.showbtn \
+               -command VisualQueryBuilder::showSQL \
+               -text [intlmsg {Show SQL}]
+       button $base.fb.execbtn \
+               -command VisualQueryBuilder::executeSQL \
+               -text [intlmsg {Execute SQL}]
+       button $base.fb.stoqb \
+               -command VisualQueryBuilder::saveToQueryBuilder \
+               -text [intlmsg {Save to query builder}]
+       button $base.fb.exitbtn \
+               -command {Window destroy .pgaw:VisualQuery} \
+               -text [intlmsg Close]
+       place $base.c  -x 5 -y 30 -width 750 -height 500 -anchor nw -bordermode ignore 
+       place $base.fb \
+               -x 5 -y 0 -width 753 -height 31 -anchor nw -bordermode ignore 
+       pack $base.fb.l12 \
+               -in .pgaw:VisualQuery.fb -anchor center -expand 0 -fill none -side left 
+       pack $base.fb.entt \
+               -in .pgaw:VisualQuery.fb -anchor center -expand 0 -fill none -side left 
+       pack $base.fb.bdd \
+               -in .pgaw:VisualQuery.fb -anchor center -expand 0 -fill none -side left 
+       pack $base.fb.exitbtn \
+               -in .pgaw:VisualQuery.fb -anchor center -expand 0 -fill none -side right 
+       pack $base.fb.stoqb \
+               -in .pgaw:VisualQuery.fb -anchor center -expand 0 -fill none -side right 
+       pack $base.fb.execbtn \
+               -in .pgaw:VisualQuery.fb -anchor center -expand 0 -fill none -side right 
+       pack $base.fb.showbtn \
+               -in .pgaw:VisualQuery.fb -anchor center -expand 0 -fill none -side right 
+}
+
diff --git a/src/bin/pgaccess/main.tcl b/src/bin/pgaccess/main.tcl
new file mode 100644 (file)
index 0000000..1a3d84e
--- /dev/null
@@ -0,0 +1,250 @@
+#!/bin/sh
+# the next line restarts using wish \
+exec wish "$0" "$@"
+
+image create bitmap dnarw -data  {
+#define down_arrow_width 15
+#define down_arrow_height 15
+static char down_arrow_bits[] = {
+       0x00,0x80,0x00,0x80,0x00,0x80,0x00,0x80,
+       0x00,0x80,0xf8,0x8f,0xf0,0x87,0xe0,0x83,
+       0xc0,0x81,0x80,0x80,0x00,0x80,0x00,0x80,
+       0x00,0x80,0x00,0x80,0x00,0x80
+       }
+}
+
+
+proc {intlmsg} {msg} {
+global PgAcVar Messages
+       if {$PgAcVar(pref,language)=="english"} { return $msg }
+       if { ! [array exists Messages] } { return $msg }
+       if { ! [info exists Messages($msg)] } { return $msg }
+       return $Messages($msg)
+}
+
+proc {PgAcVar:clean} {prefix} {
+global PgAcVar
+       foreach key [array names PgAcVar $prefix] {
+               set PgAcVar($key) {}
+               unset PgAcVar($key)
+       }
+}
+
+
+proc {find_PGACCESS_HOME} {} {
+global PgAcVar env
+       if {! [info exists env(PGACCESS_HOME)]} {
+               set home [file dirname [info script]]
+               switch [file pathtype $home] {
+                       absolute {set env(PGACCESS_HOME) $home}
+                       relative {set env(PGACCESS_HOME) [file join [pwd] $home]}
+                       volumerelative {
+                               set curdir [pwd]
+                               cd $home
+                               set env(PGACCESS_HOME) [file join [pwd] [file dirname [file join [lrange [file split $home] 1 end]]]]
+                               cd $curdir
+                       }
+               }
+       }
+       if {![file isdir $env(PGACCESS_HOME)]} {
+               set PgAcVar(PGACCESS_HOME) [pwd]
+       } else {
+               set PgAcVar(PGACCESS_HOME) $env(PGACCESS_HOME)
+       }
+}
+
+
+proc init {argc argv} {
+global PgAcVar CurrentDB
+       find_PGACCESS_HOME
+       # Loading all defined namespaces
+       foreach module {mainlib database tables queries visualqb forms views functions reports scripts users sequences schema help preferences} {
+               source [file join $PgAcVar(PGACCESS_HOME) lib $module.tcl]
+       }
+       set PgAcVar(currentdb,host) localhost
+       set PgAcVar(currentdb,pgport) 5432
+       set CurrentDB {}
+       set PgAcVar(tablist) [list Tables Queries Views Sequences Functions Reports Forms Scripts Users Schema]
+       set PgAcVar(activetab) {}
+       set PgAcVar(query,tables) {}
+       set PgAcVar(query,links) {}
+       set PgAcVar(query,results) {}
+       set PgAcVar(mwcount) 0
+       Preferences::load
+}
+
+proc {wpg_exec} {db cmd} {
+global PgAcVar
+       set PgAcVar(pgsql,cmd) "never executed"
+       set PgAcVar(pgsql,status) "no status yet"
+       set PgAcVar(pgsql,errmsg) "no error message yet"
+       if {[catch {
+               Mainlib::sqlw_display $cmd
+               set PgAcVar(pgsql,cmd) $cmd
+               set PgAcVar(pgsql,res) [pg_exec $db $cmd]
+               set PgAcVar(pgsql,status) [pg_result $PgAcVar(pgsql,res) -status]
+               set PgAcVar(pgsql,errmsg) [pg_result $PgAcVar(pgsql,res) -error]
+       } tclerrmsg]} {
+               showError [format [intlmsg "Tcl error executing pg_exec %s\n\n%s"] $cmd $tclerrmsg]
+               return 0
+       }
+       return $PgAcVar(pgsql,res)
+}
+
+
+proc {wpg_select} {args} {
+       Mainlib::sqlw_display "[lindex $args 1]"
+       uplevel pg_select $args
+}
+
+
+proc {create_drop_down} {base x y w} {
+global PgAcVar
+       if {[winfo exists $base.ddf]} return;
+       frame $base.ddf -borderwidth 1 -height 75 -relief raised -width 55
+       listbox $base.ddf.lb -background #fefefe -foreground #000000 -selectbackground #c3c3c3 -borderwidth 1  -font $PgAcVar(pref,font_normal)  -highlightthickness 0 -selectborderwidth 0 -yscrollcommand [subst {$base.ddf.sb set}]
+       scrollbar $base.ddf.sb -borderwidth 1 -command [subst {$base.ddf.lb yview}] -highlightthickness 0 -orient vert
+       place $base.ddf -x $x -y $y -width $w -height 185 -anchor nw -bordermode ignore
+       place $base.ddf.lb -x 1 -y 1 -width [expr $w-18] -height 182 -anchor nw -bordermode ignore
+       place $base.ddf.sb -x [expr $w-15] -y 1 -width 14 -height 183 -anchor nw -bordermode ignore
+}
+
+
+proc {setCursor} {{type NORMAL}} {
+       if {[lsearch -exact "CLOCK WAIT WATCH" [string toupper $type]] != -1} {
+               set type watch
+       } else {
+               set type left_ptr
+       }
+       foreach wn [winfo children .] {
+               catch {$wn configure -cursor $type}
+       }
+       update ; update idletasks 
+}
+
+
+proc {parameter} {msg} {
+global PgAcVar
+       Window show .pgaw:GetParameter
+       focus .pgaw:GetParameter.e1
+       set PgAcVar(getqueryparam,var) ""
+       set PgAcVar(getqueryparam,flag) 0
+       set PgAcVar(getqueryparam,msg) $msg
+       bind .pgaw:GetParameter <Destroy> "set PgAcVar(getqueryparam,flag) 1"
+       grab .pgaw:GetParameter
+       tkwait variable PgAcVar(getqueryparam,flag)
+       if {$PgAcVar(getqueryparam,result)} {
+               return $PgAcVar(getqueryparam,var)
+       } else {
+               return ""
+       }
+}
+
+
+proc {showError} {emsg} {
+   bell ; tk_messageBox -title [intlmsg Error] -icon error -message $emsg
+}
+
+
+proc {sql_exec} {how cmd} {
+global PgAcVar CurrentDB
+       if {[set pgr [wpg_exec $CurrentDB $cmd]]==0} {
+               return 0
+       }
+       if {($PgAcVar(pgsql,status)=="PGRES_COMMAND_OK") || ($PgAcVar(pgsql,status)=="PGRES_TUPLES_OK")} {
+               pg_result $pgr -clear
+               return 1
+       }       
+       if {$how != "quiet"} {
+               showError [format [intlmsg "Error executing query\n\n%s\n\nPostgreSQL error message:\n%s\nPostgreSQL status:%s"] $cmd $PgAcVar(pgsql,errmsg) $PgAcVar(pgsql,status)]
+       }
+       pg_result $pgr -clear
+       return 0
+}
+
+
+
+proc {main} {argc argv} {
+global PgAcVar CurrentDB tcl_platform
+       load libpgtcl[info sharedlibextension]
+       catch {Mainlib::draw_tabs}
+       set PgAcVar(opendb,username) {}
+       set PgAcVar(opendb,password) {}
+       if {$argc>0} {
+               set PgAcVar(opendb,dbname) [lindex $argv 0]
+               set PgAcVar(opendb,host) localhost
+               set PgAcVar(opendb,pgport) 5432
+               Mainlib::open_database
+       } elseif {$PgAcVar(pref,autoload) && ($PgAcVar(pref,lastdb)!="")} {
+               set PgAcVar(opendb,dbname) $PgAcVar(pref,lastdb)
+               set PgAcVar(opendb,host) $PgAcVar(pref,lasthost)
+               set PgAcVar(opendb,pgport) $PgAcVar(pref,lastport)
+               catch {set PgAcVar(opendb,username) $PgAcVar(pref,lastusername)}
+               if {[set openmsg [Mainlib::open_database]]!=""} {
+                       if {[regexp "no password supplied" $openmsg]} {
+                               Window show .pgaw:OpenDB
+                               focus .pgaw:OpenDB.f1.e5
+                               wm transient .pgaw:OpenDB .pgaw:Main
+                       }
+               }
+               
+       }
+       wm protocol .pgaw:Main WM_DELETE_WINDOW {
+               catch {pg_disconnect $CurrentDB}
+               exit
+       }
+}
+
+
+proc {Window} {args} {
+global vTcl
+       set cmd [lindex $args 0]
+       set name [lindex $args 1]
+       set newname [lindex $args 2]
+       set rest [lrange $args 3 end]
+       if {$name == "" || $cmd == ""} {return}
+       if {$newname == ""} {
+               set newname $name
+       }
+       set exists [winfo exists $newname]
+       switch $cmd {
+               show {
+                       if {$exists == "1" && $name != "."} {wm deiconify $name; return}
+                       if {[info procs vTclWindow(pre)$name] != ""} {
+                               eval "vTclWindow(pre)$name $newname $rest"
+                       }
+                       if {[info procs vTclWindow$name] != ""} {
+                               eval "vTclWindow$name $newname $rest"
+                       }
+                       if {[info procs vTclWindow(post)$name] != ""} {
+                               eval "vTclWindow(post)$name $newname $rest"
+                       }
+               }
+               hide    { if $exists {wm withdraw $newname; return} }
+               iconify { if $exists {wm iconify $newname; return} }
+               destroy { if $exists {destroy $newname; return} }
+       }
+}
+
+proc vTclWindow. {base} {
+       if {$base == ""} {
+               set base .
+       }
+       wm focusmodel $base passive
+       wm geometry $base 1x1+0+0
+       wm maxsize $base 1009 738
+       wm minsize $base 1 1
+       wm overrideredirect $base 0
+       wm resizable $base 1 1
+       wm withdraw $base
+       wm title $base "vt.tcl"
+}
+
+
+init $argc $argv
+
+Window show .
+Window show .pgaw:Main
+
+main $argc $argv
+
diff --git a/src/bin/pgaccess/pgaccess b/src/bin/pgaccess/pgaccess
new file mode 100755 (executable)
index 0000000..41fd5ca
--- /dev/null
@@ -0,0 +1,10 @@
+#!/bin/sh
+
+PATH_TO_WISH=/usr/bin/wish
+PGACCESS_HOME=/usr/local/pgaccess
+
+export PATH_TO_WISH
+export PGACCESS_HOME
+
+exec ${PATH_TO_WISH} ${PGACCESS_HOME}/main.tcl "$@"
+
diff --git a/src/bin/pgaccess/win32/dll/libpgtcl80.dll-6.4.2 b/src/bin/pgaccess/win32/dll/libpgtcl80.dll-6.4.2
new file mode 100644 (file)
index 0000000..3e631d5
Binary files /dev/null and b/src/bin/pgaccess/win32/dll/libpgtcl80.dll-6.4.2 differ
diff --git a/src/bin/pgaccess/win32/dll/libpgtcl80.dll-6.5.1 b/src/bin/pgaccess/win32/dll/libpgtcl80.dll-6.5.1
new file mode 100644 (file)
index 0000000..5c47c88
Binary files /dev/null and b/src/bin/pgaccess/win32/dll/libpgtcl80.dll-6.5.1 differ
diff --git a/src/bin/pgaccess/win32/dll/libpgtcl81.dll-6.5.1 b/src/bin/pgaccess/win32/dll/libpgtcl81.dll-6.5.1
new file mode 100644 (file)
index 0000000..d687f30
Binary files /dev/null and b/src/bin/pgaccess/win32/dll/libpgtcl81.dll-6.5.1 differ
diff --git a/src/bin/pgaccess/win32/dll/libpgtcl82.dll-6.5.1 b/src/bin/pgaccess/win32/dll/libpgtcl82.dll-6.5.1
new file mode 100644 (file)
index 0000000..cefe7ee
Binary files /dev/null and b/src/bin/pgaccess/win32/dll/libpgtcl82.dll-6.5.1 differ
diff --git a/src/bin/pgaccess/win32/dll/libpq.dll-6.4.2 b/src/bin/pgaccess/win32/dll/libpq.dll-6.4.2
new file mode 100644 (file)
index 0000000..1079f2f
Binary files /dev/null and b/src/bin/pgaccess/win32/dll/libpq.dll-6.4.2 differ
diff --git a/src/bin/pgaccess/win32/dll/libpq.dll-6.5.1 b/src/bin/pgaccess/win32/dll/libpq.dll-6.5.1
new file mode 100644 (file)
index 0000000..67a39e7
Binary files /dev/null and b/src/bin/pgaccess/win32/dll/libpq.dll-6.5.1 differ