src/hg/utils/tdbQuery/tdbQuery.c 1.10
1.10 2009/12/03 10:21:39 kent
Making -strict leave in parents when their children exist.
Index: src/hg/utils/tdbQuery/tdbQuery.c
===================================================================
RCS file: /projects/compbio/cvsroot/kent/src/hg/utils/tdbQuery/tdbQuery.c,v
retrieving revision 1.9
retrieving revision 1.10
diff -b -B -U 4 -r1.9 -r1.10
--- src/hg/utils/tdbQuery/tdbQuery.c 3 Dec 2009 08:59:33 -0000 1.9
+++ src/hg/utils/tdbQuery/tdbQuery.c 3 Dec 2009 10:21:39 -0000 1.10
@@ -759,8 +759,22 @@
}
fprintf(out, "\n");
}
+static boolean tableExistsInSelfOrOffspring(char *db, struct tdbRecord *record)
+/* Return TRUE if table corresponding to track exists in database db. If a parent
+ * track look for tables in kids too. */
+{
+if ( hTableOrSplitExists(db, record->key))
+ return TRUE;
+struct tdbRecord *child;
+for (child = record->children; child != NULL; child = child->next)
+ {
+ if (tableExistsInSelfOrOffspring(db, child))
+ return TRUE;
+ }
+return FALSE;
+}
void tdbQuery(char *sql)
/* tdbQuery - Query the trackDb system using SQL syntax.. */
{
@@ -826,11 +840,12 @@
if (rqlStatementMatch(rql, record))
{
- if (!clStrict || (record->key && hTableOrSplitExists(p->db, record->key)))
+ if (!clStrict || tableExistsInSelfOrOffspring(p->db, record))
{
matchCount += 1;
+// TODO - add limit clause processing here.
if (doSelect)
{
rqlStatementOutput(rql, record, "file", stdout);
}