Oct 21, 2008
createdb mumps
Un-tar/compress it with a command like (use latest version number):
tar xvzf mumpscompiler-11.5.src.tar.gz
Descend into the mumpsc directory and type:
configure prefix=/usr --with-pgdb=/usr/include/postgresql or, for Cygwin configure prefix=/usr --with-pgdb=/usr/include make make install
Note the 'pgsql' rather than 'pgdb'. The 'pgsql' enables the SQL command in Mumps/II to accesss PostgreSQL but places global arrays in the native data base. The 'pgdb' option enables SQL command access and places the global arrays in the PostgreSQL data base in a database table named mumps.for Ubuntu: configure prefix=/usr --with-pgsql=/usr/include/postgresql make make install for Cygwin: configure prefix=/usr --with-pgsql=/usr/include
configure prefix=/usr make make install
Note: the configure command may need to be prefixed by ./ and you may see warning messages, this is normal. If you are using 64 bit Ubuntu, add the --with-cpu64 option to the configure lines.
The dbname is where Mumps will store its global arrays.configure prefix=/usr --with-pgdb=/usr/include --with-dbname=fluffy
If you will be connecting to an existing PostgreSQL database, ignore this. Any Mumps globals you create will be places in a table in the database you connect to named 'mumps.'
If you want to run scripts on a different machine than the one running PostgreSQL, you need to enable TCP/IP connections to PostgreSQL.
To accept TCP/IP connections, you must start postmaster with the -i option and the connecting clients' IP numbers should be in the file pg_hba.conf found in the PostgreSQL data directory.
Note: to enable a group of IP numbers, your IPV4 address should look like:
Where the high order 16 bits must match (134.161) but the remainng 16 bits can be any value. The above would enable any machine on the UNI campus. Alternatively, passwords can be used. See the PostgreSQL documentation.host all all 134.161.0.0/16 trust
To test a connection, try something like:
where the '-h' option specifies the remote host to connect to.psql -h tuatha.cs.uni.edu -d medical
where 'connect-string' is either text or &~exp~ such that 'exp' evaluates to a string of text.
The string is the information needed to connect to the PostgreSQL server. At a minimum, it should include the name of the database being connected to:
dbname=medical
Other options include the host, host address, user, password, etc. See http://www.postgresql.org/docs/8.3/static/libpq-connect.html for a complete list (this is the documentation of the C function PQconnectdb() used to connect to the database but has all the possible options listed). Options you don't include default. For a local server, you probably only need the dbname= parameter and be sure that (1) you are running as a known PostgreSQL user and (2) that you have read/write privs in the directory you are running in.
Examples:
sql/d dbname=medical sql/d host=abc.def.xyz.edu dbname=medical sql/d hostaddr=123.321.432.321 dbname=medical sql/d user=joe password=abc123 dbname=medical host=abc.def.xyz.edu set x="dbname=medical" sql/d &~x~
Disconnect from the database. No parameters, no other commands on the line.
Clear and prepare a mumps database table in PstgreSQL. This removes any previous mumps database table from PostgreSQL and defines a new one. Do this the first time you try to store Mumps global arrays in PostgreSQL. Subsequently, do this only if you want to delete the mumps global array database and start over.
Theis command (no other line options, no other commands on the same line) creates a table named mumps in the current database. Thus, you must be connected with a server and a database before you execute it. Mumps will place its global arrays in this table. The mumps database has eleven columns the first of which is named 'gbl' and the subsequent ones are named a1, a2, ... a10. It may be queried by SELECT statements but this is probably not desireable.
Where 'string' can be text or &~exp~ where 'exp' evaluates to a string. Passes a command to the PostgreSQL server. $test will be true (1) if no error is reported. $zsql will contain any messages or 'ok' if there were none. Do not use this command for SELECT queries.
where 'fileExp' must evaluate to a valid filename in which will be stored the results of the command and 'string' may be a text string or &~exp~ where 'exp' evaluates to valid SQL command text. The tuple output of the command will be stored in the file with TAB characters delimiting the values of the columns.
The sql/t=table,size command is used to switch to a different PostgreSQL table for Mumps global array access.. This command only applies if PostgreSQL is being used as the backend storage facility for the global arrays. Both table and size must be valid Mumps/II expressions. 'table' is the name of the PostgreSQL table which will be used for global array references and size gives the number of columns, exclusive of the global array name column (always column one).
Normally, global array access go to the table named 'mumps' which has eleven columns named 'gbl', 'a1', 'a2', ... 'a10'. Theses are all text columns. Each successive column is a level lower in the Mumps global array tree. Many later columns are NULL.
If you create a table (see example below) and you name the columns appropriately (some prefix subset of the ones above), you can access the table with Mumps global array references.
#!/usr/bin/mumps html Content-type: text/html &!&! html set x="host=tuatha.cs.uni.edu dbname=medical" # Open the connection. # The &~exp~ causes the result of 'exp' to be inserted into the line sql/d &~x~ # $test will be 1 and $zsql will be 'ok' if it worked if $test html Connection to database open
else do . html Connection to database failed . halt # Flush/delete/create a mumps table in the database. sql/f if $test html Mumps tables initialized
else html Mumps table initialization failed
# prepare a query and run it. Output will go to xxx.file # where 'xxx' is the process id of this program set x="select * from ptname;" html Sending query: &~x~
sql/o="/tmp/"_$job_".file" &~x~ set ptname=$zsqlCols // gets column names TAB separated if $test html Query successfully processedelse do . html Query failed. Message=&~$zsql~