00-database-procs.tcl

  • last updated 11 hours ago
Constraints
Constraints: committers
 
Constraints: files
Constraints: dates
Fix regression in 'if_no_rows' idiom for db_foreach, document alternative syntax, create a test for db_foreach main functionalities

  1. … 1 more file in changeset.
Bring files on oacs-5-10 in sync with HEAD

  1. … 162 more files in changeset.
Deprecate 'db_nullify_empty_string', essentially just returning the same string it receives

Deprecate 'db_null'

Fix typo (thanks to Thomas Renner)

Cleanup not more relevant comments, remove idiom meant to work in the context of a db_with_handle we are not using anymore

Reuse already existing db_list_of_ns_sets inside db_foreach and db_list_of_lists, as it uses the most native return type: the ns_set

Operate on the original list to not incur in possible memory foortprint inflation via lrange

Exploit new -with_headers flag in db_list_of_lists to reimplement db_foreach in a way that only one db handle is used

Advantages:

- api is now transaction safe (with respect to database operations executed in the code block)

- nested db_foreach statements won't risk to occupy all available handles anymore

Possible drawbacks:

- query result needs to be completely stored inside a list before looping

- calling stack is now one level deeper...

This passes automated tests

Reduce code duplication

Introduce -with_headers flag in db_list_of_lists so names of returned column values can be returned as well as the first list in the result

Reduce code duplication (passes automated tests)

Deprecate duplicated api and replace its only occurence in upstream codebase

  1. … 2 more files in changeset.
make sure not to release handles active in an transaction, transactions are based on handles

activate usage of "ns_db currenthandles" when available

add error, when we are running out of handles

reduce verbosity, deactivate usage 'ns_db currenthandles' for now

fix typo

db_handle reform

Use "ns_db currenthandles" (when available) to implement "db_with_handle"

instead of the old approach based on the global db_state variables.

The enws approach has the advantantge that it is

- more robust (deletion and creation of the per-request variables,

no coherency problem),

- simpler, and

- faster (less overhead per db_with_handle call, simple queries up to 20% faster)

time {db_string . {select object_id from acs_objects limit 1}} 1000

old: 200-230 microseconds per iteration

new: 160-180 microseconds per iteration

Reduce code duplication (passes automated tests)

improve spelling

  1. … 15 more files in changeset.
Whitespace cleanup

Remove proc doc duplication in 'db_1row'. As the proc is essentially a wrapper for 'db_0or1row', just a pointer is better, avoiding future issues if parameters change.

prefer built-in ns_dbquotevalue over DoubleApos

  1. … 2 more files in changeset.
make former private functions, used in several packages to public functions

  1. … 4 more files in changeset.
fix typo

Port from downstream cache transaction logics and fix automated test as now db_transaction will return 0 instead of the empty string (and no particular return value should be assumed)

  1. … 1 more file in changeset.
reduce hammering on nsv for variables that never change. Use namespaced variables instead.

  1. … 3 more files in changeset.
improve spelling

  1. … 10 more files in changeset.
unify spelling of names

  1. … 3 more files in changeset.