I would like to create a copy of the structure only of an existing database without it data to a new database (same server).
I am using PHP 5.2.14
I tried:
CREATE DATABASE base3 WITH TEMPLATE base2 OWNER postgres;
And got this error:
ERROR: source database "base2" is being accessed by other users
********** Error **********
ERROR: source database "base2" is being accessed by other users
SQL state: 55006
I tried adding this code:
SELECT pg_terminate_backend(pg_stat_activity.procpid) FROM pg_stat_activity WHERE pg_stat_activity.datname = 'base2' AND procpid <> pg_backend_pid();
and get this error:
ERROR: function pg_terminate_backend(integer) does not exist
LINE 1: SELECT pg_terminate_backend(pg_stat_activity.procpid) FROM p...
^
HINT: No function matches the given name and argument types. You might need to add explicit type casts.
********** Error **********
ERROR: function pg_terminate_backend(integer) does not exist
SQL state: 42883
Hint: No function matches the given name and argument types. You might need to add explicit type casts.
Character: 8
Thanks if advance for your help.
In PostgreSQL 9.2 and above you should use pg_terminate_backend with integer argument and use pid field. Example bellow:
SELECT pg_terminate_backend(pid)
FROM pg_stat_activity
WHERE datname = 'base2' AND pid <> pg_backend_pid();
Server Signaling Functions:
pg_cancel_backend and pg_terminate_backend send signals (SIGINT or SIGTERM respectively) to backend processes identified by process ID. The process ID of an active backend can be found from the pid column of the pg_stat_activity view, or by listing the postgres processes on the server (using ps on Unix or the Task Manager on Windows). The role of an active backend can be found from the usename column of the pg_stat_activity view.
pg_stat_activity was made available in version 8.4 and ownward.
Older version user can use these functions
as listed on documentation page
https://www.postgresql.org/docs/8.1/static/functions-admin.html
Related
When I try to create a new service using db-connected in Apigility, I'm getting the error Error saving field. After receive the error, the service is created but if I select this one, I receive the error Unable to fetch service.
It seems to happen always when I create a db-connected service in a table with name containing "_".
The error that I'm getting in console is:
[Error] Failed to load resource: the server responded with a status of 404 (Not Found) (Hookit-V1-Rest-Vitrine_usuario-Controller, line 0)
I checked the module's config and the parameters are have been created.
in module's config in node zf-apigility O removed the parameter resource_class and the run the service... It worked.
but I can't sync the service in admin.
Does someone knows how to solve it to sync the service in Apigility's admin?
Alessandro Garcez is correct. This issue was resolved in this merge https://github.com/zfcampus/zf-apigility-admin-ui/pull/59
However, this merge has been overwritten and in the latest version, you will get the same issue. I have made a pull request to bring back the fix that Alessandro Garcez mentioned.
It seems that when the new service is created, if the table name contains an underscore ( _ ), the API will convert this to what looks like CamelCase.
But when the UI then wants to create the fields for this newly created service, it (the UI) will still use the tablename with the underscore in it, when accessing the api (/apigility/api/module//rest/--Rest--Controller/input-filter)
But the API will this time expect the controller-part being specified with the tablename camedcased:
(/apigility/api/module//rest/--Rest--Controller/input-filter)
It had already been fixed but was undone, I don't know why.
There is a opened discussion https://github.com/zfcampus/zf-apigility-admin-ui/issues/78.
For now is possible follow this way:
Change the function capitalizeFirstLetter in file src/apigility-ui/service/api.service.js adding the line var string = string.replace(/(\w)/g, function(,letter) { return letter.toUpperCase(); }); before the return.
I've been using Couchbase for a large project where we only consume data, but have no requrirement to actually write to the Couchbase cluster. I want to write some management tools and be able to create Design Documents and Views through the API and not the web console.
Creating Documents is not an issue at all, but whenever I use setDesignDoc() I get the following error message:
Fatal error: Uncaught exception 'CouchbaseLibcouchbaseException' with message 'Failed to store design doc: Invalid input/arguments' in ....
I can get the actual view data from the source with getDesignDoc() and use it for the creating that design document on the destination server like so:
$connandleDestination->setDesignDoc( "myDesignDoc", $connSource->getDesignDoc("myDesignDoc") );
And that's where I get the above error message.
I'm using the PHP SDK by the way with the latest version against Couchbase 2.5.1
Can you confirm if what you've given as your example is the exact code you're using?
$connandleDestination->setDesignDoc( "myDesignDoc", $connSource->getDesignDoc("myDesignDoc") );
What you've given would not work as, from the API docs, the syntax is as follows:
setDesignDoc(string $name, string $document) : bool
Hence, it would appear you are trying to set a new doc, myDesignDoc to be equal to the design doc myDesignDoc, which would either not exist, or have no effect (as setting something to equal itself causes no change - and creating a new design doc with the name of an existing one will simply overwrite it).
Did you instead mean to just use get()? get() would return a document (which would be valid in the setDesignDoc input, and that document could have the same name as the new design doc to be created.
So The Direct Project strikes again. I'm no expert in LDAP, but I'm trying to set up a test environment since the standard requires any package to support getting certificates from LDAP as well as DNS CERT, regardless of which method is implemented by the package.
According to the documentation, the prescribed sequence of events (trimmed for relevance) from section "3.3.3 LDAP query":
* Discover the Base DNs
Branches in LDAP must be defined by a “Base DN”. The list of Base DNs that are
provided by a LDAP directory are found by doing a LDAP Query with a NULL (i.e.
“”) Base DN, and ObjectClass=”DN”.
* Query across the Base DN for entries where "Mail" contains the endpoint address
I'm trying to implement this process in php, using the ldap_* functions, but their way doesn't seem to work. Obviously, NULL is not the same as an empty string (the latter makes any call to ldap_search return a "No such object" error), and "DN" isn't a valid value for an ObjectClass attribute.
So, TL;DR, is there another way an anonymous remote user retrieve the (list of?) base DNs that I'm missing?
UPDATE: Reworded the title to reflect the root cause of my problem: Reading the rootDSE from PHP when the ldap_* api doesn't allow you to specify 'base' scope.
So another read through the docs answered my question for me.
Apparently, the only difference between ldap_search(), ldap_list(), and ldap_read() are the scopes (LDAP_SCOPE_SUBTREE (sub), LDAP_SCOPE_ONELEVEL (one), and LDAP_SCOPE_BASE (base), respectively). So using ldap_read() instead of the others will allow one to get the rootDSE.
In the root dse. See "namingContexts".
Update:
In java:
LDAPConnection conn = new LDAPConnection(hostname,port);
SearchRequest req = new SearchRequest("",SearchScope.BASE,"(&)","+");
SearchResult result = conn.search(req);
// If the search succeeds, the result will comprise one entry,
// and that entry is the Root DSE:
dn:
subschemaSubentry: cn=schema
namingContexts: C=us
vendorName: UnboundID Corp.
vendorVersion: UnboundID Directory Server 4.1.0.6
Using php driver 1.3.2 and mongodb 2.2, I am trying to use readPreference to direct an aggregate query to one of the secondaries in my replica set. Seems whatever I try, the aggregate query is executed on the primary server.
Basic example:
$db = new \MongoClient('rs1.example:27017,rs2.example:27017,rs3.example:27017', array('replicaSet' => 'myRs') );
$db->setReadPreference( \MongoClient::RP_SECONDARY );
$results = $db->tracking->sessions->aggregate( array( ... ) );
I enabled MongoLog and got the following results:
The aggregate method shows: REPLSET INFO: - connection: type: PRIMARY
If I use find instead, it shows: REPLSET INFO: - connection: type: SECONDARY
Is this a bug with the php driver? Anyone else run into this? Thought I would toss it on SO before adding it as a bug in their Jira.
All command queries through the PHP driver are currently directed to primary servers. We have several old tickets related to this, originating with requests to direct count commands to secondaries, but it was a non-trivial change that requiring checking the command against a whitelist to ensure it is read-only. The current ticket tracking this fix is PHP-535, which I linked to the issue you opened, PHP-662.
If you need an immediate work-around, you can call find() on the $cmd collection directly, passing the same $command array argument that you'd typically pass to MongoDB::command() as the argument to find(). Kristina documented this solution in this JIRA comment, and although she used slaveOkay() in that example, it should also work with read preferences.
I wanted to make a tryout this weekend with Cassandra + PHP in my testing environment. So after a few hours of headache trying to install it, I finally succeeded and got it running.
However, I've tried out the different PHP wrappers for cassandra, and I have totally failed to connect with anyone. SimpleCassie which I want to use, gives the following error when I run the following code:
/*
* setting new column (and key if not exist)
* #return - (false) on failure
*/
$cassie->keyspace('MyApp')->cf('Users')->key('user1')->column('name')->set('Marcin');
$cassie->column('surname')->set('Rosinski');
Error:
cassandra_InvalidRequestException: in /var/www/cassie/SimpleCassie.php on line 7257
What Can I do to make it work?
Thanks!
"Invalid request could mean keyspace or column family does not exist, required parameters are missing, or a parameter is malformed. why contains an associated error message."
My qualified guess is that you have forgot to add a keyspace called 'MyApp', and inside that keyspace create a column family called 'Users'