• last updated 16 hours ago
Constraints
Constraints: committers
 
Constraints: files
Constraints: dates
Fix potential problems when calling polymorphic SQL functions from Tcl

Some functions are defined in the database with the same number of

arguments but different types, e.g., first argument "package_key"

(type text) or "package_id" (type integer). This is fine from the SQL

standpoint, but when calling from Tcl via bind-vars

(e.g. ":package_id"), everything is passed as a string, and

potentially, the wrong function is called.

Now, all the automatically generated subs are generated with casts,

when the integer based variant must be called.

Some examples:

Before:

set s [ns_pg_bind 0or1row $__DB {select apm__set_value(:package_id,:parameter_name,:attr_value)}]

set s [ns_pg_bind 0or1row $__DB {select apm__get_value(:package_id,:parameter_name)}]

Now:

set s [ns_pg_bind 0or1row $__DB {select apm__set_value(CAST(:package_id AS integer),:parameter_name,:attr_value)}]

set s [ns_pg_bind 0or1row $__DB {select apm__get_value(CAST(:package_id AS integer),:parameter_name)}]

- bumped version number to 5.10.1b11

  1. … 2 more files in changeset.
improved souce code documentation

silence warning about query names in the log file

Fine-tuning the new db function interface

#

# Check, wether we have to regenerate the database function interface.

#

# - During initial setup, there are no db-functions, so nothing has to

# be done.

#

# - During regular startup of the server, the generation of the stub

# interface happens in the *init procs (hopefully this is always

# sufficient, but seems so)

#

# - During reloads of acs-db-*-procs, the base classes are interface

# objects are recreated and cleaned up from all prior definitons,

# which means that in this situations, we have to regeneate the

# interface.

#

# - One might call manually the regeneration, when database functions

# have been altered and no restart is desired.

#

Update of SQL function calling interface to make it usable during initial bootstrap

- add sanity checks and produce error messages,

when function args are incorrect.

- do not throw errors in case it is called before the

table acs_function_args was created (during boot)

- added preliminary "list" call to acs::dc

- added first *-init.tcl to be called after loading

the *-proc.tcl files.

- removed all references to the ::xo::* namespace

  1. … 3 more files in changeset.
improve spelling and formulations

  1. … 2 more files in changeset.
Added new interface for calling database functions

This is tested for PostgreSQL and Oracle and the drivers nsdb and nsdbi.

For details, see https://openacs.org/xowiki/calling-database-functions

  1. … 2 more files in changeset.