Summary:ASTERISK-02932: [patch] CLI 'database showkey <keytree>'
Reporter:Tilghman Lesher (tilghman)Labels:
Date Opened:2004-12-06 11:40:48.000-0600Date Closed:2008-01-15 15:17:45.000-0600
Versions:Frequency of
Environment:Attachments:( 0) 20041206__db_showkey.diff.txt
( 1) 20041221__db_showkey__2.diff.txt
Description:An alternative to showing keys by family, this command shows all the families with a particular key.


Disclaimer on file.
Comments:By: Olle Johansson (oej) 2004-12-19 07:55:03.000-0600

Why is this patch on hold? Let's add it to cvs head!


By: Mark Spencer (markster) 2004-12-19 12:42:40.000-0600

I'm not sure I am following this correctly.  Is the goal to be able to show all database entries whose key *contains* a subkey?  If so, then there should be a while() loop to look for all instances of "/" right to do the comparison, also the documentation pieces have not been updated (which might have helped answer for me what I was looking for).  Other than that this looks ready and is very cleanly implemented.

By: Tilghman Lesher (tilghman) 2004-12-19 22:23:11.000-0600

Not contains a subkey, but rather has a particular key.  For example, we could
have a database containing:

/101/channel1     : Zap/25
/101/location     : 1
/101/ring         : 1
/102/channel1     : SIP/snom220
/102/location     : 3

So we could do a 'database show 101' to show:
/101/channel1     : Zap/25
/101/location     : 1
/101/ring         : 1

And this patch lets us do 'database showkey location' to show:
/101/location     : 1
/102/location     : 3

By: Mark Spencer (markster) 2004-12-20 04:26:29.000-0600

If that's the intent, wouldn't strrchr make more sense or omit that check entirely and check just the last n characters?

By: Tilghman Lesher (tilghman) 2004-12-20 09:23:46.000-0600

6 of one, half a dozen of the other?  Actually, this way is faster, since we don't have to search (for a null) to the end of the key, then search backwards (for our string); we simply search from the beginning of the key (first for a /, then for our string).

By: Mark Spencer (markster) 2004-12-20 19:03:11.000-0600

But then that would suggest that

database showkey location

would not be able to print an entry such as

/foo/bar/location : 3


By: Tilghman Lesher (tilghman) 2004-12-20 23:35:17.000-0600

Yeah, but that's a contrived example.  Who cares, anyway?  <jab>

By: Tilghman Lesher (tilghman) 2004-12-21 11:50:04.000-0600

Technically the revised patch will also work for values of "bar/location" and "foo/bar/location", but given the nature of the ambiguity of the differentiation between families and keys when either can contain slashes, I guess this is okay.

By: Mark Spencer (markster) 2004-12-21 20:10:49.000-0600

Added to CVS with minor improvements, thanks!

By: Russell Bryant (russell) 2004-12-22 17:41:42.000-0600

not in 1.0

By: Digium Subversion (svnbot) 2008-01-15 15:17:45.000-0600

Repository: asterisk
Revision: 4524

U   trunk/db.c

r4524 | markster | 2008-01-15 15:17:45 -0600 (Tue, 15 Jan 2008) | 2 lines

Merge tilghman's "showkey" patch (bug ASTERISK-2932)