The internals of Recital 10 have been extensively modified to provide greatly improved program execution performance. Internals that have been changed include:
Recital is a dynamic programming language particularly suited to the development of database applications. While Recital still supports standard procedural programming, new extensions to the language give you the power and flexibility of object-oriented programming. Object-oriented design and object-oriented programming represent a change in focus from standard procedural programming. Prior to Recital 10 being released, object-oriented programming (OOP) support in Recital was somewhat limited. In Recital 10 the whole OOP engine has been overhauled and is now much more advanced and flexible. See
Enhanced Recital command window
- When using Recital in interactive mode, the command window has been enhanced. Pressing ^w pops up a textedit window which can be used for editing long commands (particularly useful for SQL commands).
- Pressing the Return key echoes it to the output window (useful for clearing text) when using interactive commands.
- Improved command history. When using the up-array and down-array keys from the keyboard to view and/or execute previous commands, duplicate commands are ignored.
- When developing/testing Recital program files from the interactive command window, if an error occurs you can edit the offending program by selecting 'edit' from the error dialog. The file will be opened at the offending line number.
- Command autocompletion using the TAB key
Program editor enhancements
Editing Recital .prg files inside the Recital Workbench on linux will now color code them using vim.
Use Recital in shell scripts
Recital 10 enhances Recital by enabling it to be used in bash shell scripts and in shell commands which use pipes and/or redirect stdin and stdout. If stdin is not redirected then recital will startup and operate as normal in a terminal window. Additionally you can use heredoc to denote a block of recital commands that should be executed. Note that when used in this manner, no UI commands can be executed and no user interaction is allowed.
# recital < mrprog.prg
# recital < myprog.prg > myoutput.txt
# recital > myoutput.txt <
use customers
list structure
END
# echo "select * from sales!customers where overdue" | recital | wc -l
Individual commands can be executed in shell scripts.
# recital -c "create database sales"
# recital -c "create table sales!invoices (id int, name char(25), due date)"
Expressions can be evaluated and used in shell scripts.
# VER=`recital -e "version(1)"`
You can view what command line options are available by typing:
# recital --help
Better Unix/Linux command line integration
Recital 10 supports use of `backticks` in strings.
echo "The default directory is `pwd`"
echo "There are `ls -l *.dbf | wc -l` tables in this directory"
Automatic data type conversions in character expressions
When non-character data is added to strings, the data is automatically converted to a string similar to the etos() functions operates. SET STRICT OFF must be in effect to enable this.
echo "This string can add numerics and dates etc " + 100.89 + " " + date()
Conditional loading of shared libraries
The require_once( Filename ) function will load a Recital library (.prg extension) or C shared library only once. If the library is already loaded the function is ignored. Shared libraries stay in memory until there are no further references to them from any Recital, Recital Server or Recital Web application.
Automatic loading of extension libraries
Recital and C API libraries that reside in the /opt/recital/extensions directory will automatically be loaded into shared global memory by Recital, Recital Web and Recital Server. This results in a big performance improvement when using class libraries and is particularly noticeable when running web applications with Recital Web. Extension libraries can be written in Recital (.prg extension) or in C using the Recital C API in which case they will have a ".so" file extension on linux an a ".dll" extension on windows. Extensions stay in memory until there are no further references to them from any Recital, Recital Server or Recital Web application.
SQL performance improvements
- SQL SELECT improved query optimizer
- Handles index restriction using filtered indexes (INDEX ... FOR ... )
- Handles index restriction with > and >=
- Dramatic improvements to nested SELECT statements
- SmartQuery caching
SQL Select extensions
SELECT * FROM table INTO JSON
SELECT * FROM table INTO OBJECT
SELECT * FROM table INTO HTML
SELECT * FROM table INTO XML
New commands
COPY DATABASE TO [ IF [ NOT ] EXISTS ]
This command is used to copy an existing database to a new database. By default an error will be returned if the target database already exists. Specifing the optional IF NOT EXISTS keywords no error will be returned if the traget database already exists. If the optional IF EXISTS keywords are specfied and the target databases already exists, then it will be removed before the copy. Both the databases must be closed before they can be copied.
SET AUTOHEAL ON/OFF
Enables or disables auto-healing of indexes.
SET FSTATCACHE ON/OFF
Enables or disables caching of file information on a network file system.
SET TXLEVEL TO COMMITTED | UNCOMMITTED
Sets the transaction isolation level for SQL commands.
SET NETWORK ON/OFF
SET NETWORK TO
Enable or disables Recital Clustered File system support which provides superior performance on networked systems using glusterfs or samba.
SET TIMELINE ON/OFF
Enables or disables timelines for the active table.
CLEAR TIMELINE
Clears the timeline for all tables.
LIST TIMELINE [RANGE date [,date] [FOR condition]
Lists the timeline for all or selected tables over a datetime range.
ROLLBACK TIMELINE RANGE date [,date] [FOR condition]
Rolls back data to a previous timeline for all or selected tables over a datetime range.
SET TIMESTAMP TO
Enables a timestamp to be inserted into a field of a record as it is being appended into a table.
SET SMARTQUERY ON/OFF
SET SMARTQUERY TO
Enables or disable SmartQuery caching.
CLEAR SMARTQUERY
Clears the SmartQuery cache for all tables.
EXPLAIN
Explains the execution of a SQL SELECT statement and provides details of how the query is being processed.
FOREACH
Provides a convenient way to iterate over elements in associative or static arrays.
ECHO
Similar to the existing ? command but the string output can contain C-style escaped characters e.g. "\n" and php-style $variable and {expression} substitutions in character strings.
OPTIMIZE
This new command is used to optimize a table by it's primary key. The table is physically ordered by the specified primary key to give better performance when reading rows from the table. If the optional PACK keyword is specified then deleted rows are removed from the table during the optimization process. The optional ALL keyword can be specified to optimize all open tables or the optional DATABASE key word can used to optimize all tables in a specified database. The table being optimized must have a primary key.
SET DATADIR TO [directory]
This new command is used to specify a directory where database tables, memos, indexes, and dictionary files are located. When a table is being opened this directory is searched first before the current directory and the file search path to locate the table and its associated files. This allows the database tables to be relocated to a different file system without the need to change an existing application.
SET DATE TO ISO
Recital now supports SET DATE TO ISO which will set date to a YYYY-MM-DD format. International Standard ISO 8601 specifies numeric representations of date and time. This standard notation helps to avoid confusion in international communication caused by the many different national notations and increases the portability of computer user interfaces. In addition, these formats have several important advantages for computer usage compared to other traditional date and time notations.
Enhancements to existing commands
APPEND TYPE CSV
Appends from a csv file
COPY TYPE CSV
Copies to a csv file
New functions
Outputs an object or dynarray variable as html
print_html( object as object )
Outputs an object or dynarray variable as xml
print_xml( object as object )
Outputs an object or dynarray variable as json
print_json( object as object )
Create a dynarray
object = array( [ key => value [, key => value] ] )
Create an anonomous object
object = object( [ property => value [, property => value] ] )
Run linux commands (optionally piped together) and return the output
character = pipetostr( "linux | commands | like | this" )
Save an object or dynarray to an external .obf file (object serialization)
saveobject(oName as object, cFilename as character)
Load an object or dynarray from an external .obf file (object deserialization)
object = loadobject(cFilename as character)
Time function with msecs granularity
numeric = timeofday( [mode as numeric] )
XML functions
character = xml_encode(da as object [, roottagname as character, rowtagname as character] )
object = xml_decode(xmlstring as character [, roottagname as character, rowtagname as character] )
character =
xml_scatter( [wka as numeric] )
numeric =
xml_gather( xmlstring as character )
Linux messaging functions (hint: use with xml_encode() and xml_decode() to pass objects between processes)
numeric = mqcreate(name, as character, mode as numeric)
numeric = mqopen(name as character, mode as numeric)
mqclose(mqdes as numeric)
numeric = mqsend(mqds as numeric, data as character)
character = mqreceive(mqdes as numeric)
numeric = mqcurmsgs(mqdes as numeric)
TCP/IP socket function
fp = fsockopen(address as character, port as numeric) as numeric
( use fputs(), fgets(), fflush(), fread(), fclose() with this function )
fopen() function enhanced
The fopen() function can now be used to open http://www.xxx.com/page URL's
The fopen() function can also be used to open linux fifo pipes with fifo://pipename
( use fputs(), fgets(), fflush(), fread(), fclose() with this function )
URL function
character = geturl( url as character [, timeout as numeric] )
C-style printf(), sprintf() and fprintf() functions
printf( format as character [, args...])
character = sprintf( format as character [, args...])
fprintf( fp as numeric, format as character [, args...])
The format can contain any of the following formatting characters:
%s %d %f %y %t %T %l %L
Each formatting character sequence can optionally contain a width and decimal places (only relevant for numeric)
Left justify by placing a '-' directly following the '%' character e.g. %-20s or %-14.2f.
When %s is specified, the corresponding argument is converted to character format (similar to specifying etos().
%t and %T are for formating datetime data types.
%y is for formatting currency data types
%l and %L is for formatting logical datatypes.
tostring() function (synonymous with etos()
character = tostring( expression )
Returns the current transaction isolation level
character = txlevel()
Fills an array with elements of a string separated by newline (default)
numeric = alines(arrayname, string as character [,flags as numeric [, separator as character] ] )
Returns a string describing the last operating system error message. If the optional error number is
specified then the related operating system error message will be returned.
character = strerror( [ errno as numeric ] )
Returns all the fields in the current row as a string. The string will begin with the uniquied row identifier and then the deleted flag, followed by the data in the record. An optional workarea can be specified, otherwise the current workarea will be used.
character = rtos( [workarea as numeric] )
Returns true if the session is running from a terminal (not a batch job)
logical = isatty()
Returns information showing who has a file open and whether it is exclusive or shared.
character = lockinfo(filename as character)
New functions to handle ini / configuration files
Sets a key/value pair in a section of an ini/configuration file
ini_set(Section as character, Key as character, Value as character[, Filename as character]) as logical
Gets a value for a key in a section of an ini/configuration file
ini_get( Section as character, Key as character[[[, Default as character], Filename as character], Macros as logical]) as character
Sets all key/value pairs for a section of an ini/configuration file
ini_setsection(object as object, Section as character[, Filename as character]) as logical
Gets all key/value pairs for a section of an ini/configuration file
ini_getsection(Section as character[[, Filename as character], Macros as logical]) as object
A typical ini/configuration file looks like this:
# comment lines are preceeded by a '#'
; or a ';'
#
# "Sections" are enclosed in [ and ]
[global]
; key/value pairs are contained in the sections and are written like this
key1 = value
key2 = value2
; You can include macros in the key/value pairs.
key3 = This is $(key2) and $(key1)
Notes:
- If "Filename" is not specified then it will default to the recital system configuration file /etc/recital.conf
- It "Macros" is not specified both ini_get( ) and ini_getsection( ) will not expand macros. Set it to true if you want macros expanded
- ini_getsection( ) returns a dynamic array which allows you to reference key/value pairs, update them, and write them back to the configuration file.
- You should set the file permissions on /etc/recital.conf to 755 to prevent changes to the recital system configuration file
New PHP-compatible functions to reduce learning curve for PHP developers
(Click here for function details and examples)
number = strcmp( expC1, expC2 )
number = strcasecmp( expC1, expC2 )
number = strpos( expC1, expC2 )
logical = in_array( expC, expA )
character = strstr( expC1, expC2 )
number = strlen( expC1 )
unset( variable )
isset( variable )
die( exp )
exit( exp )
object = array( )
character = base64_encode( expC )
character = base64_decode( expC )
number = filesize( expC )
logical = function_exists( expC )
print_r( expO )
character = str_replace( needle, replace, haystack )
character = strtolower( expC )
character = strtoupper( expC )
character = ucfirst( expC )
character = str_pad( expC, expN [, expC] )
character = html_entities( expC )
character = html_entity_decode( expC )
require( Filename )
require_once( Filename )
include( Filename )
include_once( Filename )
character = strftime( format [, datetime ])
Determine if a variable is of a specific type
logical = is_array( exp )
logical = is_object( exp )
logical = is_string( exp )
logical = is_int( exp )
logical = is_float( exp )
Wraps a string to given line width (defaults to 80)
character = wordwrap( character string [, numeric line_length [, character break_char [, logical cut ] ] ] )
The implode() function returns a string from the elements of an array
character = implode(separator as character, arrayname)
The explode() function breaks a string into an array
array = explode(separator as character, string as character)
Bug fixes
Deprecated features
The following features are no longer supported and have been removed from Recital 10
- The ASSIST command and the shell dba script
- The INFO command and the dbinfo script
- The DESIGN command and the dbdesign script
- SET MAXDBO command is ignored
- DB_MAXWKA environment variable in recital.conf is ignored
- shell commands dbc, dbvideo
- The Recital database library has been discontinued. The Recital/SDK C extensions API should be used instead.