view release on metacpan or search on metacpan
matrixssl-1-8-6-open/src/crypto/peersec/arc4.c view on Meta::CPAN
*/
#define ARC4_MAX_BYTES 0x40000000
/******************************************************************************/
/*
SSL_RSA_WITH_RC4_* cipher callbacks
*/
void matrixArc4Init(sslCipherContext_t *ctx, unsigned char *key, int32 keylen)
{
unsigned char index1, index2, tmp, *state;
short counter;
view all matches for this distribution
view release on metacpan or search on metacpan
lib/Crypt/MatrixSSL3.pm view on Meta::CPAN
$server_index = create_SSL_server();
Tells the XS module to allocate a new server structure. The returned index
must be saved and then used one time to initialize the server structure and then
each time a new client connection is accepted in order to set SNI/ALPN callbacks.
=head1 CLASSES
Constructors for all classes will throw exception on error instead of
returning error as matrixSslNew*() functions do. Exception will be
lib/Crypt/MatrixSSL3.pm view on Meta::CPAN
MATRIXSSL_REQUEST_SEND.
When this object will be destroyed will call:
matrixSslDeleteSession( $ssl )
More information about callbacks L</certValidator> and L</extensionCback>
in the L</CALLBACKS> section.
=head2 Crypt::MatrixSSL3::Server
lib/Crypt/MatrixSSL3.pm view on Meta::CPAN
an ALPN callback. More information about callback L</ALPNCallback>
in the L</CALLBACKS> section.
=back
=head3 set_callbacks
$ssl->set_callbacks( $server_index, $ssl_id );
Parameters:
=over
lib/Crypt/MatrixSSL3.pm view on Meta::CPAN
any of the client's protocols the XS module will send an appropriate
response and the client will receive a SSL_ALERT_NO_APP_PROTOCOL alert.
Will be called with 2 parameters:
$ssl_id - this is the $ssl_id used in the $ssl->set_callbacks(...) call
$app_proto - scalar with the negociated protocol name
=head2 VHIndexCallback
Will be called whenever we have a successful match against the hostname
specified by the client in its SNI extension. This will inform the Perl
code which virtual host the current SSL session belongs to.
Will be called with 3 parameters:
$ssl_id - this is the $ssl_id used in the $ssl->set_callbacks(...) call
$index - a 0-based int specifying which virtual host matchd the client requested hostname
$match - a scalar containing the hostname sent in the client's SNI TLS extension
Doesn't return anything.
lib/Crypt/MatrixSSL3.pm view on Meta::CPAN
# the client sent its request
# sets up the matrixSSL ALPN callback that will get called when the client sends an ALPN extension
# the &ALPNCallback is called with the provided $ssl_id and the selected protocol
$cssl->set_callbacks($server_index, $sll_id);
# further initialization stuff after accepting the client
...
}
view all matches for this distribution
view release on metacpan or search on metacpan
lib/Net/NSS/SSL.pm view on Meta::CPAN
=item set_pkcs11_pin_arg ( $arg : scalar )
=item get_pkcs11_pin_arg ( ) : scalar
Sets or gets the argument that is passed along to pkcs11 callbacks for the given socket. I<$arg> can be any Perl scalar
but in most cases you'll just want this to be a string.
The default password callback (L<Crypt::NSS::PKCS11/set_password_hook>), returns this value.
=item set_URL ( $host : string )
view all matches for this distribution
view release on metacpan or search on metacpan
lib/Crypt/OTR.pm view on Meta::CPAN
use Crypt::OTR;
# call near the beginning of your program
Crypt::OTR->init;
# create OTR object, set up callbacks
my $otr = new Crypt::OTR(
account_name => "alice", # name of account associated with this keypair
protocol_name => "my_protocol_name", # e.g. 'AIM'
max_message_size => 1024, # how much to fragment
);
view all matches for this distribution
view release on metacpan or search on metacpan
inc/My/Module/Build.pm view on Meta::CPAN
=item I<find_test_files_predicate()>
=item I<find_test_files_in_directories()>
Those two methods are used as callbacks by L</find_test_files>;
subclasses of I<My::Module::Build> may therefore find it convenient to
overload them. I<find_test_files_in_directories> should return a list
of the directories in which to search for test files.
I<find_test_files_predicate> gets passed the name of each file found
in these directories in the same way as a L<File::Find> C<wanted> sub
view all matches for this distribution
view release on metacpan or search on metacpan
static BIO* sv_bio_create(void) {
SV *sv = newSVpvn("",0);
/* create an in-memory BIO abstraction and callbacks */
BIO *bio = BIO_new(BIO_s_mem());
#if OPENSSL_VERSION_NUMBER >= 0x30000000L
BIO_set_callback_ex(bio, bio_write_cb);
#else
view all matches for this distribution
view release on metacpan or search on metacpan
static BIO* sv_bio_create(void) {
SV *sv = newSVpvn("", 0);
/* create an in-memory BIO abstraction and callbacks */
BIO *bio = BIO_new(BIO_s_mem());
BIO_set_callback(bio, bio_write_cb);
BIO_set_callback_arg(bio, (void *)sv);
view all matches for this distribution
view release on metacpan or search on metacpan
crypt_pkcs11.c view on Meta::CPAN
return SvIOK(sv) ? 1 : 0;
}
/* TODO:
* Change Mutex design to incapsulate an object that refers to the CODE
* references and mutex data to allow for per PKCS11 object mutex callbacks.
* Also store them in the PKCS11 object for cleanup.
*/
void crypt_pkcs11_xs_setCreateMutex(SV* pCreateMutex) {
croak("Mutex functions are currently not supported");
view all matches for this distribution
view release on metacpan or search on metacpan
eval "package $caller; use POE;";
}
# XXX We assume that there will never be two Curses::UI::POE sessions.
my @modal_objects;
my @modal_callbacks;
# The session needed to make curses run in POE.
sub new {
my ($type, %options) = @_;
my $self = &Curses::UI::new(@_);
# Reset focus
$top->{-focus} = 0;
# Dispatch callback.
my $args = pop @modal_callbacks;
my $sub = shift @$args;
&{$sub}(@$args);
}
sub keyin {
$this->{-has_modal_focus} = 1;
$this->focus;
$this->draw;
push @modal_objects, $this;
push @modal_callbacks, undef;
# This is reentrant into the POE::Kernel
while ( $this->{-has_modal_focus} ) {
$poe_kernel->loop_do_timeslice;
}
$this->{-focus} = 0;
pop @modal_callbacks;
pop @modal_objects;
return $this;
}
}
{
no warnings "redefine";
# None of this work's if POE isn't running...
# Redefine the callbackmodalfocus to ensure that callbacks and objects make
# it on to our own private stack.
sub Curses::UI::Widget::callbackmodalfocus {
my ($this, $cb) = @_;
# "Fake" focus for this object.
push @modal_objects, $this;
if (defined $cb) {
# They need a callback, so register it.
push @modal_callbacks, $cb;
} else {
# Push a null callback.
push @modal_callbacks, [sub { }];
}
# We assume our callers are going to return immediately back to the
# main event loop, so we don't need a recursive call.
return;
view all matches for this distribution
view release on metacpan or search on metacpan
lib/Curses/UI.pm view on Meta::CPAN
=head2 -userdata
Takes a scalar (frequently a hashref) as its argument, and stows that
scalar inside the Curses::UI object where it can be retrieved with the
L<#userdata> method. Handy inside callbacks and the like.
=head2 -default_colors
Directs the underlying Curses library to allow use of default color
pairs on terminals. Is preset to true and you almost certainly don't
view all matches for this distribution
view release on metacpan or search on metacpan
0.19 - 2012-12-12
* fixed croak error location in AUTOLOAD relaying at first
* removed Cv::alias
* removed global data in Cv.xs
* rewrote cv::error to use Perl error handler $Cv::ERROR
* rewrote other callbacks
* separated Highgui
* s/:nomore/-more/
* fixed // op for perl-5.8.9
* rewrote CV_FOURCC
* MYEXTLIB is no longer needed
view all matches for this distribution
view release on metacpan or search on metacpan
lib/Cvs/Simple.pm view on Meta::CPAN
Permitted values of CMD are C<All> (executed on every line of
output), C<add>, C<commit>, C<checkout>, C<diff>, C<update>. CMD is also
permitted to be undef, in which case, it will be assumed to be C<All>.
cvs_cmd passes two arguments to callbacks: the actual command called, and the
line returned by CVS.
See the tests for examples of callbacks.
=item
=item unset_callback ( CMD )
lib/Cvs/Simple.pm view on Meta::CPAN
C</usr/bin/cvs>.
=item cvs_cmd ( )
cvs_cmd() does the actual work of calling the equivalent CVS command. If any
callbacks have been set, they will be executed for every line received from
the command. If no callbacks have been set, all output is to STDOUT.
=item external( REPOSITORY )
Specify an "external" repository. This can be a genuinely remote
repository in C<:ext:user@repos.tld:/path/to/cvsroot> format, or an
lib/Cvs/Simple.pm view on Meta::CPAN
=over 4
=item 1. Note that C<Cvs::Simple> carries out no input validation; everything is
passed on to CVS. Similarly, the caller will receive no response on the
success (or otherwise) of the transaction, unless appropriate callbacks have
been set.
=item 2. The C<cvs_cmd> method is quite simplistic; it's basically a pipe from
the equivalent CVS command line (with STDERR redirected). If a more
sophisticated treatment, over-ride C<cvs_cmd>, perhaps with something based on
view all matches for this distribution
view release on metacpan or search on metacpan
lib/DB/Object/Query/Element.pm view on Meta::CPAN
}
return(0);
}
# The placeholder, such as ?, $2, ?2, or others supported by the driver
sub placeholder { return( shift->_set_get_scalar_as_object( { field => 'placeholder', callbacks => {
set => sub
{
# $val is a scalar object (Module::Generic::Scalar)
my( $self, $val ) = @_;
my $placeholder_re = $self->query_object->database_object->_placeholder_regexp;
lib/DB/Object/Query/Element.pm view on Meta::CPAN
sub query_object { return( shift->_set_get_object( 'query_object', 'DB::Object::Query', @_ ) ); }
# The field data type to be used when binding parameters
# sub type { return( shift->_set_get_scalar_as_object( 'type', @_ ) ); }
sub type { return( shift->_set_get_scalar_as_object( { field => 'type', callbacks =>
{
get => sub
{
my( $self, $val ) = @_;
my $field = $self->field;
view all matches for this distribution
view release on metacpan or search on metacpan
lib/DBD/CSV.pm view on Meta::CPAN
our @c_SHORT = qw( eof
eol sep_char quote_char escape_char binary decode_utf8 auto_diag
diag_verbose blank_is_undef empty_is_undef allow_whitespace
allow_loose_quotes allow_loose_escapes allow_unquoted_escape
always_quote quote_empty quote_space escape_null quote_binary
keep_meta_info callbacks );
package DBD::CSV;
use strict;
view all matches for this distribution
view release on metacpan or search on metacpan
Beginnings of support for reading longs (except Illustra says they're normal)
1998/09/30: 0.03 released (without these changes listed, oops)
Set $h->err to MI_ERROR when errors occur
(it is checked by at least the test suite, so it can't be left as zero)
Log callbacks to DBILOGFP if DBI_TRACE>=3
Don't try to describe queries with no fields, such as inserts and deletes
Fixed table_info so it actually does something useful
Fix up tests so they actually all pass (by ignoring some of them until later)
ChopBlanks somewhat supported (FETCH returns undef)
1998/09/29: 0.02_001
Added table_info support (not that dbish seems to notice)
Have a go at implementing $h->errstr and $h->state ($h->err is useless)
- callbacks no longer warn
Add mostly empty dbd_bind_ph and completely empty dbd_st_blob_read
Pathetic attempt at supporting {TYPE} info. Illustra doesn't help
Replace useless test.pl with Jochen Wiedmann's DBD-test
1998/09/22: 0.02 released
view all matches for this distribution
view release on metacpan or search on metacpan
lib/DBD/Mock.pm view on Meta::CPAN
=over 4
=item Connection Callbacks
This feature allows you to define callbacks that get executed when
C<< DBI->connect >> is called.
To set a series of callbacks you use the
C<DBD::Mock::dr::set_connect_callbacks> function
use DBD::Mock::dr;
DBD::Mock::dr::set_connect_callbacks( sub {
my ( $dbh, $dsn, $user, $password, $attributes ) = @_;
$dbh->{mock_add_resultset} = {
sql => 'SELECT foo FROM bar',
results => [[ 'foo' ], [ 10 ]]
};
} );
To set more than one callback to you can simply add extra callbacks to your
call to C<DBD::Mock::dr::set_connect_callbacks>
DBD::Mock::dr::set_connect_callbacks(
sub {
my ( $dbh, $dsn, $user, $password, $attributes ) = @_;
$dbh->{mock_add_resultset} = {
sql => 'SELECT foo FROM bar',
lib/DBD/Mock.pm view on Meta::CPAN
results => [[ 'foo' ], [ 10 ]]
};
}
);
Or you can extend the existing set of callbacks with the
C<DBD::Mock::dr::add_connect_callbacks> function
DBD::Mock::dr::add_connect_callbacks( sub {
( my $dbh, $dsn, $user, $password, $attributes ) = @_;
$dbh->{mock_add_resultset} = {
sql => 'SELECT bar FROM foo',
results => [[ 'bar' ], [ 50 ]]
view all matches for this distribution
view release on metacpan or search on metacpan
examples/ora_explain.pl view on Meta::CPAN
->grid(-column => 0, -row => 2, -sticky => "w");
$box->Entry(-textvariable => \$database, -width => 30)
->grid(-column => 1, -row => 2, -sticky => "w");
$box->pack(-expand => 1, -fill => "both", -ipadx => 6, -ipady => 6);
# Create the buttons & callbacks
$box = $LoginDialog->Frame(-borderwidth => 1, -relief => "raised");
my $cb = sub
{
if (! eval { login($database, $username, $password); })
{
examples/ora_explain.pl view on Meta::CPAN
->pack(-side => "left", -anchor => "e", -expand => 1);
$box->Entry(-textvariable => \$schema, -width => 30)
->pack(-side => "right", -anchor => "w", -expand => 1);
$box->pack(-expand => 1, -fill => "both", -ipadx => 6, -ipady => 6);
# Create the buttons & callbacks
$box = $SchemaDialog->Frame(-borderwidth => 1, -relief => "raised");
my $cb = sub
{
# Try changing to the specified schema
$schema = uc($schema);
examples/ora_explain.pl view on Meta::CPAN
# Clear the frames
$GrabSql->delete("1.0", "end");
$GrabDetails->delete("1.0", "end");
$GrabStatus->configure(-text => "Please wait...");
# Define the callbacks for highlighting etc
my $highlight = sub
{
my ($text, $tag) = @_;
$text->tag("configure", $tag, -relief => "raised", -borderwidth => 1);
};
examples/ora_explain.pl view on Meta::CPAN
# Otherwise, build the grab window
$GrabMain = $PlanMain->Toplevel(-title => "$ProgName - SQL cache");
$GrabMain->protocol("WM_DELETE_WINDOW", sub { $GrabMain->withdraw(); });
# Defaults & callbacks
my $ordering = "";
my $order_by = "";
my $sort_by = "";
my $no_sys = 1;
my $user = "";
view all matches for this distribution
view release on metacpan or search on metacpan
lib/DBD/PO/db.pm view on Meta::CPAN
@_,
{isa => 'DBI::db'},
{type => ARRAYREF | SCALAR | HASHREF},
{
type => SCALAR | ARRAYREF,
callbacks => {
check_keys => sub {
my $check_key = shift;
if (ref $check_key eq 'ARRAY') {
return 1;
}
view all matches for this distribution
view release on metacpan or search on metacpan
- I8N docs and error messages
- Change quote and dequote functions to take Sv instead of string so that
things like arrays can be serialized by the quote function. This will
take care of broken chopblanks and pg_bool_tf (pass the quote/dequote
options struct to function quote/dequote functions)
- Allow user callbacks to quote user-defined types
- Revisit the use of version.pm
- Test heavily with a thread-enabled Perl
- Remove libpq dependency
- Handle and/or better tests for different encoding, especially those not
supported as a server encoding (e.g. BIG5)
view all matches for this distribution
view release on metacpan or search on metacpan
} a_sqlany_data_info;
/** An enumeration of the callback types.
*
* The callback types correspond to the embedded SQL callback types.
* For more information about embedded SQL callbacks, see
* \salink{db_register_a_callback function, "http://dcx.sybase.com/goto?page=sa160/en/dbprogramming/db-register-a-callback-esql.html", "programming", "db-register-a-callback-esql"}.
*
* \hideinitializers
* \sa sqlany_register_callback()
*/
view all matches for this distribution
view release on metacpan or search on metacpan
lib/DBD/SQLcipher.pm view on Meta::CPAN
is a UTF-8 rendering of the SQL statement text as the statement
first begins executing.
=back
Additional callbacks might occur as each triggered subprogram is
entered. The callbacks for triggers contain a UTF-8 SQL comment
that identifies the trigger.
See also L<DBI/TRACING> for better tracing options.
=head2 $dbh->sqlite_profile( $code_ref )
lib/DBD/SQLcipher.pm view on Meta::CPAN
=head1 DRIVER CONSTANTS
A subset of SQLcipher C constants are made available to Perl,
because they may be needed when writing
hooks or authorizer callbacks. For accessing such constants,
the C<DBD::SQLcipher> module must be explicitly C<use>d at compile
time. For example, an authorizer that forbids any
DELETE operation would be written as follows :
use DBD::SQLcipher;
lib/DBD/SQLcipher.pm view on Meta::CPAN
my $overlapping = $dbh->selectcol_arrayref($overlap_sql,undef,
$minLong, $maxLong, $minLat, $maxLat);
For more detail, please see the SQLcipher R-Tree page
(L<http://www.sqlite.org/rtree.html>). Note that custom R-Tree
queries using callbacks, as mentioned in the prior link, have not been
implemented yet.
=head1 VIRTUAL TABLES IMPLEMENTED IN PERL
SQLcipher has a concept of "virtual tables" which look like regular
lib/DBD/SQLcipher.pm view on Meta::CPAN
=head2 Stream API for Blobs
Reading/writing into blobs using C<sqlite2_blob_open> / C<sqlite2_blob_close>.
=head2 Support for custom callbacks for R-Tree queries
Custom queries of a R-Tree index using a callback are possible with
the SQLcipher C API (L<http://www.sqlite.org/rtree.html>), so one could
potentially use a callback that narrowed the result set down based
on a specific need, such as querying for overlapping circles.
view all matches for this distribution
view release on metacpan or search on metacpan
**
** ^The callback function registered by sqlite3_trace() is invoked at
** various times when an SQL statement is being run by [sqlite3_step()].
** ^The sqlite3_trace() callback is invoked with a UTF-8 rendering of the
** SQL statement text as the statement first begins executing.
** ^(Additional sqlite3_trace() callbacks might occur
** as each triggered subprogram is entered. The callbacks for triggers
** contain a UTF-8 SQL comment that identifies the trigger.)^
**
** The [SQLITE_TRACE_SIZE_LIMIT] compile-time option can be used to limit
** the length of [bound parameter] expansion in the output of sqlite3_trace().
**
** aggregate. ^A scalar SQL function requires an implementation of the xFunc
** callback only; NULL pointers must be passed as the xStep and xFinal
** parameters. ^An aggregate SQL function requires an implementation of xStep
** and xFinal and NULL pointer must be passed for xFunc. ^To delete an existing
** SQL function or aggregate, pass NULL pointers for all three function
** callbacks.
**
** ^The sixth, seventh, eighth and ninth parameters (xStep, xFinal, xValue
** and xInverse) passed to sqlite3_create_window_function are pointers to
** C-language callbacks that implement the new function. xStep and xFinal
** must both be non-NULL. xValue and xInverse may either both be NULL, in
** which case a regular aggregate function is created, or must both be
** non-NULL, in which case the new function may be used as either an aggregate
** or aggregate window function. More details regarding the implementation
** of aggregate window functions are
/*
** CAPI3REF: Setting The Result Of An SQL Function
** METHOD: sqlite3_context
**
** These routines are used by the xFunc or xFinal callbacks that
** implement SQL functions and aggregates. See
** [sqlite3_create_function()] and [sqlite3_create_function16()]
** for additional information.
**
** These functions work very much like the [parameter binding] family of
** ^The sqlite3_commit_hook(D,C,P) and sqlite3_rollback_hook(D,C,P) functions
** return the P argument from the previous call of the same function
** on the same [database connection] D, or NULL for
** the first call for each function on D.
**
** The commit and rollback hook callbacks are not reentrant.
** The callback implementation must not do anything that will modify
** the database connection that invoked the callback. Any actions
** to modify the database connection must be deferred until after the
** completion of the [sqlite3_step()] call that triggered the commit
** or rollback hook in the first place.
** [database connection]; each call to [sqlite3_preupdate_hook()] overrides
** the previous setting.
** ^The preupdate hook is disabled by invoking [sqlite3_preupdate_hook()]
** with a NULL pointer as the second parameter.
** ^The third parameter to [sqlite3_preupdate_hook()] is passed through as
** the first parameter to callbacks.
**
** ^The preupdate hook only fires for changes to real database tables; the
** preupdate hook is not invoked for changes to [virtual tables] or to
** system tables like sqlite_master or sqlite_stat1.
**
** ^The [sqlite3_preupdate_old(D,N,P)] interface writes into P a pointer to
** a [protected sqlite3_value] that contains the value of the Nth column of
** the table row before it is updated. The N parameter must be between 0
** and one less than the number of columns or the behavior will be
** undefined. This must only be used within SQLITE_UPDATE and SQLITE_DELETE
** preupdate callbacks; if it is used by an SQLITE_INSERT callback then the
** behavior is undefined. The [sqlite3_value] that P points to
** will be destroyed when the preupdate callback returns.
**
** ^The [sqlite3_preupdate_new(D,N,P)] interface writes into P a pointer to
** a [protected sqlite3_value] that contains the value of the Nth column of
** the table row after it is updated. The N parameter must be between 0
** and one less than the number of columns or the behavior will be
** undefined. This must only be used within SQLITE_INSERT and SQLITE_UPDATE
** preupdate callbacks; if it is used by an SQLITE_DELETE callback then the
** behavior is undefined. The [sqlite3_value] that P points to
** will be destroyed when the preupdate callback returns.
**
** ^The [sqlite3_preupdate_depth(D)] interface returns 0 if the preupdate
** callback was invoked as a result of a direct insert, update, or delete
);
/*
** A pointer to a structure of the following type is passed as the first
** argument to callbacks registered using rtree_geometry_callback().
*/
struct sqlite3_rtree_geometry {
void *pContext; /* Copy of pContext passed to s_r_g_c() */
int nParam; /* Size of array aParam[] */
sqlite3_rtree_dbl *aParam; /* Parameters passed to SQL geom function */
Vdbe *pReprepare; /* VM being reprepared (sqlite3Reprepare()) */
const char *zTail; /* All SQL text past the last semicolon parsed */
Table *pNewTable; /* A table being constructed by CREATE TABLE */
Index *pNewIndex; /* An index being constructed by CREATE INDEX */
Trigger *pNewTrigger; /* Trigger under construct by a CREATE TRIGGER */
const char *zAuthContext; /* The 6th parameter to db->xAuth callbacks */
#ifndef SQLITE_OMIT_VIRTUALTABLE
Token sArg; /* Complete text of a module argument */
Table **apVtabLock; /* Pointer to virtual tables needing locking */
#endif
Table *pZombieTab; /* List of Table objects to delete after code gen */
SQLITE_PRIVATE void sqlite3SelectWalkAssert2(Walker*, Select*);
#endif
/*
** Return code from the parse-tree walking primitives and their
** callbacks.
*/
#define WRC_Continue 0 /* Continue down into children */
#define WRC_Prune 1 /* Omit children but continue walking siblings */
#define WRC_Abort 2 /* Abandon the tree walk */
return rc;
}
/*
** Register this backup object with the associated source pager for
** callbacks when pages are changed or the cache invalidated.
*/
static void attachBackupObject(sqlite3_backup *p){
sqlite3_backup **pp;
assert( sqlite3BtreeHoldsMutex(p->pSrc) );
pp = sqlite3PagerBackupPtr(sqlite3BtreePager(p->pSrc));
p->rc = SQLITE_NOMEM_BKPT;
}
/* If the auto-commit flag is set to true, then any locks that were held
** by connection db have now been released. Call sqlite3ConnectionUnlocked()
** to invoke any required unlock-notify callbacks.
*/
if( db->autoCommit ){
sqlite3ConnectionUnlocked(db);
}
sqlite3OomFault(pCtx->pOut->db);
}
/*
** This function is called after a transaction has been committed. It
** invokes callbacks registered with sqlite3_wal_hook() as required.
*/
static int doWalCallbacks(sqlite3 *db){
int rc = SQLITE_OK;
#ifndef SQLITE_OMIT_WAL
int i;
}else{
nName = sqlite3Strlen30(zName);
#ifndef SQLITE_OMIT_VIRTUALTABLE
/* This call is Ok even if this savepoint is actually a transaction
** savepoint (and therefore should not prompt xSavepoint()) callbacks.
** If this is a transaction savepoint being opened, it is guaranteed
** that the db->aVTrans[] array is empty. */
assert( db->autoCommit==0 || db->nVTrans==0 );
rc = sqlite3VtabSavepoint(db, SAVEPOINT_BEGIN,
db->nStatement+db->nSavepoint);
** WRC_Continue Continue descending down the tree.
**
** WRC_Prune Do not descend into child nodes, but allow
** the walk to continue with sibling nodes.
**
** WRC_Abort Do no more callbacks. Unwind the stack and
** return from the top-level walk call.
**
** The return value from this routine is WRC_Abort to abandon the tree walk
** and WRC_Continue to continue.
*/
}
/*
** Walk all expressions associated with SELECT statement p. Do
** not invoke the SELECT callback on p, but do (of course) invoke
** any expr callbacks and SELECT callbacks that come from subqueries.
** Return WRC_Abort or WRC_Continue.
*/
SQLITE_PRIVATE int sqlite3WalkSelectExpr(Walker *pWalker, Select *p){
if( sqlite3WalkExprList(pWalker, p->pEList) ) return WRC_Abort;
if( sqlite3WalkExpr(pWalker, p->pWhere) ) return WRC_Abort;
return pExpr->u.zToken[4]==0;
}
/*
** These routines are Walker callbacks used to check expressions to
** see if they are "constant" for some definition of constant. The
** Walker.eCode value determines the type of "constant" we are looking
** for.
**
** These callback routines are used to implement the following:
** sqlite3ExprIsConstant() pWalker->eCode==1
** sqlite3ExprIsConstantNotJoin() pWalker->eCode==2
** sqlite3ExprIsTableConstant() pWalker->eCode==3
** sqlite3ExprIsConstantOrFunction() pWalker->eCode==4 or 5
**
** In all cases, the callbacks set Walker.eCode=0 and abort if the expression
** is found to not be a constant.
**
** The sqlite3ExprIsConstantOrFunction() is used for evaluating expressions
** in a CREATE TABLE statement. The Walker.eCode value is 5 when parsing
** an existing schema and 4 when processing a new statement. A bound
return rc;
}
/*
** Push an authorization context. After this routine is called, the
** zArg3 argument to authorization callbacks will be zContext until
** popped. Or if pParse==0, this routine is a no-op.
*/
SQLITE_PRIVATE void sqlite3AuthContextPush(
Parse *pParse,
AuthContext *pContext,
/* ColNames: */ 0, 0,
/* iArg: */ SQLITE_DeferFKs },
#endif
#endif
#if !defined(SQLITE_OMIT_FLAG_PRAGMAS)
{/* zName: */ "empty_result_callbacks",
/* ePragTyp: */ PragTyp_FLAG,
/* ePragFlg: */ PragFlg_Result0|PragFlg_NoColumns1,
/* ColNames: */ 0, 0,
/* iArg: */ SQLITE_NullCallback },
#endif
**
** The fake column name is an empty string. It is possible for a table to
** have a column named by the empty string, in which case there is no way to
** distinguish between an unreferenced table and an actual reference to the
** "" column. The original design was for the fake column name to be a NULL,
** which would be unambiguous. But legacy authorization callbacks might
** assume the column name is non-NULL and segfault. The use of an empty
** string for the fake column name seems safer.
*/
if( pItem->colUsed==0 ){
sqlite3AuthCheck(pParse, SQLITE_READ, pItem->zName, "", pItem->zDatabase);
** This function invokes either the xRollback or xCommit method
** of each of the virtual tables in the sqlite3.aVTrans array. The method
** called is identified by the second argument, "offset", which is
** the offset of the method to call in the sqlite3_module structure.
**
** The array is cleared after invoking the callbacks.
*/
static void callFinaliser(sqlite3 *db, int offset){
int i;
if( db->aVTrans ){
VTable **aVTrans = db->aVTrans;
sqlite3CollapseDatabaseArray(db);
assert( db->nDb<=2 );
assert( db->aDb==db->aDbStatic );
/* Tell the code in notify.c that the connection no longer holds any
** locks and does not require any further unlock-notify callbacks.
*/
sqlite3ConnectionClosed(db);
for(i=sqliteHashFirst(&db->aFunc); i; i=sqliteHashNext(i)){
FuncDef *pNext, *p;
** a deadlock.
**
** Otherwise, make arrangements to invoke xNotify when pOther drops
** its locks.
**
** Each call to this routine overrides any prior callbacks registered
** on the same "db". If xNotify==0 then any prior callbacks are immediately
** cancelled.
*/
SQLITE_API int sqlite3_unlock_notify(
sqlite3 *db,
void (*xNotify)(void **, int),
** allocate a larger array from the heap has failed.
**
** This is a difficult situation to handle. Returning an error
** code to the caller is insufficient, as even if an error code
** is returned the transaction on connection db will still be
** closed and the unlock-notify callbacks on blocked connections
** will go unissued. This might cause the application to wait
** indefinitely for an unlock-notify callback that will never
** arrive.
**
** Instead, invoke the unlock-notify callback with the context
** array already accumulated. We can then clear the array and
** begin accumulating any further context pointers without
** requiring any dynamic allocation. This is sub-optimal because
** it means that instead of one callback with a large array of
** context pointers the application will receive two or more
** callbacks with smaller arrays of context pointers, which will
** reduce the applications ability to prioritize multiple
** connections. But it is the best that can be done under the
** circumstances.
*/
xUnlockNotify(aArg, nArg);
pCsr->nTerm = apSegment[0]->nTerm;
pCsr->zTerm = apSegment[0]->zTerm;
/* If this is a prefix-search, and if the term that apSegment[0] points
** to does not share a suffix with pFilter->zTerm/nTerm, then all
** required callbacks have been made. In this case exit early.
**
** Similarly, if this is a search for an exact match, and the first term
** of segment apSegment[0] is not a match, exit early.
*/
if( pFilter->zTerm && !isScan ){
** int iStart // Byte offset of start of token within input text
** int iEnd // Byte offset of end of token within input text
** int iPos // Position of token in input (first token is 0)
**
** If the callback returns a non-zero value the tokenization is abandoned
** and no further callbacks are issued.
**
** This function returns SQLITE_OK if successful or an SQLite error code
** if an error occurs. If the tokenization was abandoned early because
** the callback returned SQLITE_DONE, this is not an error and this function
** still returns SQLITE_OK. Or, if the tokenization was abandoned early
view all matches for this distribution
view release on metacpan or search on metacpan
imp_dbh->handle_binary_nulls = FALSE;
sqlite3_busy_timeout(imp_dbh->db, SQL_TIMEOUT);
if ((retval = sqlite3_exec(imp_dbh->db, "PRAGMA empty_result_callbacks = ON",
NULL, NULL, &errmsg))
!= SQLITE_OK)
{
/* warn("failed to set pragma: %s\n", errmsg); */
sqlite_error(dbh, (imp_xxh_t*)imp_dbh, retval, errmsg);
view all matches for this distribution
view release on metacpan or search on metacpan
lib/DBD/SQLite.pm view on Meta::CPAN
Defining the column type as C<BLOB> in the DDL is B<not> sufficient.
=item * DBD_SQLITE_STRING_MODE_UNICODE_STRICT: Like
DBD_SQLITE_STRING_MODE_UNICODE_FALLBACK but usually throws an exception
rather than a warning if SQLite sends invalid UTF-8. (In Perl callbacks
from SQLite we still warn instead.)
=item * DBD_SQLITE_STRING_MODE_UNICODE_NAIVE: Like
DBD_SQLITE_STRING_MODE_UNICODE_FALLBACK but uses a "naïve" UTF-8 decoding
method that forgoes validation. This is marginally faster than a validated
lib/DBD/SQLite.pm view on Meta::CPAN
is a UTF-8 rendering of the SQL statement text as the statement
first begins executing.
=back
Additional callbacks might occur as each triggered subprogram is
entered. The callbacks for triggers contain a UTF-8 SQL comment
that identifies the trigger.
See also L<DBI/TRACING> for better tracing options.
=head2 $dbh->sqlite_profile( $code_ref )
lib/DBD/SQLite.pm view on Meta::CPAN
=head1 DRIVER CONSTANTS
A subset of SQLite C constants are made available to Perl,
because they may be needed when writing
hooks or authorizer callbacks. For accessing such constants,
the C<DBD::SQLite> module must be explicitly C<use>d at compile
time. For example, an authorizer that forbids any
DELETE operation would be written as follows :
use DBD::SQLite;
lib/DBD/SQLite.pm view on Meta::CPAN
my $overlapping = $dbh->selectcol_arrayref($overlap_sql,undef,
$minLong, $maxLong, $minLat, $maxLat);
For more detail, please see the SQLite R-Tree page
(L<https://www.sqlite.org/rtree.html>). Note that custom R-Tree
queries using callbacks, as mentioned in the prior link, have not been
implemented yet.
=head1 VIRTUAL TABLES IMPLEMENTED IN PERL
SQLite has a concept of "virtual tables" which look like regular
lib/DBD/SQLite.pm view on Meta::CPAN
=head2 Stream API for Blobs
Reading/writing into blobs using C<sqlite2_blob_open> / C<sqlite2_blob_close>.
=head2 Support for custom callbacks for R-Tree queries
Custom queries of a R-Tree index using a callback are possible with
the SQLite C API (L<https://www.sqlite.org/rtree.html>), so one could
potentially use a callback that narrowed the result set down based
on a specific need, such as querying for overlapping circles.
view all matches for this distribution
view release on metacpan or search on metacpan
return rc;
}
/*
** Push an authorization context. After this routine is called, the
** zArg3 argument to authorization callbacks will be zContext until
** popped. Or if pParse==0, this routine is a no-op.
*/
void sqliteAuthContextPush(
Parse *pParse,
AuthContext *pContext,
view all matches for this distribution
view release on metacpan or search on metacpan
doc/tdatdbd.html view on Meta::CPAN
<tr bgcolor='#E9E9E9'><td align=center valign=top><b>CheckpointCallback</b></td><td align=center valign=top>Optional</td><td valign=top>None</td>
<td valign=top>Ref to a subroutine to be called when a checkpoint event occurs</td></tr>
<tr><td align=center valign=top><b>Context</b></td><td align=center valign=top>Optional</td><td valign=top>None</td>
<td valign=top>Any value the application wishes to pass thru to the callbacks; most often
a hashref with various application specific control attributes</td></tr>
<tr bgcolor='#E9E9E9'><td align=center valign=top><b>ErrorLimit</b></td><td align=center valign=top>Optional</td><td valign=top>1,000,000</td>
<td valign=top>Maximum number of errors to allow before terminating a FASTLOAD or MLOAD</td></tr>
view all matches for this distribution
view release on metacpan or search on metacpan
And the output of course would be:
Preparing q{SELECT 1}
Because callbacks are executed I<before> the methods
they're associated with, you can modify the arguments before they're passed on
to the method call. For example, to make sure that all calls to C<prepare()>
are immediately prepared by L<DBD::Pg>, add a callback that makes sure that
the C<pg_prepare_now> attribute is always set:
Note that we are editing the contents of C<@_> directly. In this case we've
created the attributes hash if it's not passed to the C<prepare> call.
You can also prevent the associated method from ever executing. While a
callback executes, C<$_> holds the method name. (This allows multiple callbacks
to share the same code reference and still know what method was called.)
To prevent the method from
executing, simply C<undef $_>. For example, if you wanted to disable calls to
C<ping()>, you could do this:
print "Executing ", shift->{Statement}, "\n";
}
};
The C<Callbacks> attribute of a database handle isn't copied to any statement
handles it creates. So setting callbacks for a statement handle requires you to
set the C<Callbacks> attribute on the statement handle yourself, as in the
example above, or use the special C<ChildCallbacks> key described below.
B<Special Keys in Callbacks Attribute>
The first is the C<ChildCallbacks> key. When a statement handle is created from
a database handle the C<ChildCallbacks> key of the database handle's
C<Callbacks> attribute, if any, becomes the new C<Callbacks> attribute of the
statement handle.
This allows you to define callbacks for all statement handles created from a
database handle. For example, if you wanted to count how many times C<execute>
was called in your application, you could write:
my $exec_count = 0;
my $dbh = DBI->connect( $dsn, $username, $auth, {
print "The execute method was called $exec_count times\n";
}
The other three special keys are C<connect_cached.new>,
C<connect_cached.connected>, and C<connect_cached.reused>. These keys define
callbacks that are called when C<connect_cached()> is called, but allow
different behaviors depending on whether a new handle is created or a handle
is returned. The callback is invoked with these arguments:
C<$dbh, $dsn, $user, $auth, $attr>.
For example, some applications uses C<connect_cached()> to connect with
a utility method, then it might select the same cached handle and then force
C<AutoCommit> on, forcing a commit of the transaction. See the L</connect_cached>
documentation for one way to deal with that. Here we'll describe an alternative
approach using a callback.
Because the C<connect_cached.new> and C<connect_cached.reused> callbacks are
invoked before C<connect_cached()> has applied the connect attributes, you can
use them to edit the attributes that will be applied. To prevent a cached
handle from having its transactions committed before it's returned, you can
eliminate the C<AutoCommit> attribute in a C<connect_cached.reused> callback,
like so:
The upshot is that new database handles are created with C<AutoCommit>
enabled, while cached database handles are left in whatever transaction state
they happened to be in when retrieved from the cache.
Note that we've also used a lexical for the callbacks hash reference. This is
because C<connect_cached()> returns a new database handle if any of the
attributes passed to is have changed. If we used an inline hash reference,
C<connect_cached()> would return a new database handle every time. Which would
rather defeat the purpose.
A more common application for callbacks is setting connection state only when
a new connection is made (by connect() or connect_cached()). Adding a callback
to the connected method (when using C<connect>) or via
C<connect_cached.connected> (when useing connect_cached()>) makes this easy.
The connected() method is a no-op by default (unless you subclass the DBI and
change it). The DBI calls it to indicate that a new connection has been made
sub dbh {
my $self = shift;
DBI->connect_cached( $dsn, $username, $auth, { Callbacks => $cb });
}
One significant limitation with callbacks is that there can only be one per
method per handle. This means it's easy for one use of callbacks to interfere
with, or typically simply overwrite, another use of callbacks. For this reason
modules using callbacks should document the fact clearly so application authors
can tell if use of callbacks by the module will clash with use of callbacks by
the application.
You might be able to work around this issue by taking a copy of the original
callback and calling it within your own. For example:
view all matches for this distribution
view release on metacpan or search on metacpan
lib/DBICx/Hooks.pm view on Meta::CPAN
delete() calls on your sources.
This can be used to trigger bussiness processes after one of this
operations.
You register callbacks (even multiple callbacks) with a pair
C<Source>/C<Action>. Each callback receives a single parameter, the row
object just created/updated/just deleted.
See L<DBICx::Hooks::Registry> for extra details on the
C<dbic_hooks_registry()> function.
view all matches for this distribution
view release on metacpan or search on metacpan
lib/DBIx/AutoUpgrade/NativeStrings.pm view on Meta::CPAN
# return object
bless $self, $class;
}
sub inject_callbacks {
my ($self, $dbh, @invalid_args) = @_;
# check input args
$dbh->isa('DBI::db') or die '->inject_callbacks() : arg is not a DBI database handle';
!@invalid_args or die '->inject_callbacks() : too many args';
# coderef to be installed as common callback for all methods. This is a closure on $self.
my $upgrade_string_args = sub {
# NOTES: - here there is no unpacking of @_ because DBI callbacks must work directly on @_
# - $_ is the name of the DBI method
# for calls to bind_param() with an explicit bind type, some types should be left untouched (for ex. SQL_BLOB)
return if $_ eq 'bind_param' && $_[3] && !$self->{bind_type_is_string}->($_[3]);
lib/DBIx/AutoUpgrade/NativeStrings.pm view on Meta::CPAN
return; # must end with an empty return (see L<DBI> documentation)
};
# now inject the callback for $dbh methods and for $sth methods
my $parent_callbacks = $dbh->{Callbacks} //= {};
my $child_callbacks = $parent_callbacks->{ChildCallbacks} //= {};
inject_callback($parent_callbacks, $_ => $upgrade_string_args) for @{$self->{dbh_methods}};
inject_callback($child_callbacks, $_ => $upgrade_string_args) for @{$self->{sth_methods}};
}
sub inject_callback {
my ($hash, $key, $coderef) = @_;
lib/DBIx/AutoUpgrade/NativeStrings.pm view on Meta::CPAN
use DBIx::AutoUpgrade::NativeStrings;
use Encode;
my $injector = DBIx::AutoUpgrade::NativeStrings->new(native => 'cp1252');
my $dbh = DBI->connect(@dbi_connection_params);
$injector->inject_callbacks($dbh);
# these strings are semantically equal, but have different internal representations
my $str_utf8 = "il était une bergère, elle vendait ses Åufs en Â¥, ça paie 5¾ â° de mieux quâen â¬",
my $str_native = decode('cp1252', $str_utf8, Encode::LEAVE_SRC);
lib/DBIx/AutoUpgrade/NativeStrings.pm view on Meta::CPAN
=back
=head2 inject_callbacks
$injector->inject_callbacks($dbh);
Injects callbacks into the given database handle.
If that handle already has callbacks for the same methods, the system will arrange for those
other callbacks to be called I<after> all string arguments have been upgraded to utf8.
=head1 ARCHITECTURAL NOTES
=head2 Object-orientedness
lib/DBIx/AutoUpgrade/NativeStrings.pm view on Meta::CPAN
=head2 Possible redundancies
L<DBI> does not precisely document which of its public methods call each other.
For example, one would think that C<execute()> internally calls C<bind_param()>, but this does
not seem to be the case. So, to be on the safe side, callbacks installed here make no assumptions
about string transformations performed by other callbacks. There might be some redundancies,
but it does no harm since strings are never upgraded twice.
=head2 Caveats
The C<bind_param_inout()> method is not covered -- the client program must do the proper updates
view all matches for this distribution
view release on metacpan or search on metacpan
min_chunk_percent => 0.01,
verbose => 0,
);
# DBI callbacks here are the only good way to interfere with COUNT statements
my $dbh = $batch_chunker->dbic_storage->dbh;
$dbh->{Callbacks} = {
ChildCallbacks => {
execute => sub {
my ($sth, $start, $end) = @_;
view all matches for this distribution