🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: news.software.nntp
Article #9096

Suggested API for querying Usenet servers

#9096
From: J.B. Nicholson-Owens
Date: Sun, 07 Jul 1996 00:00
186 lines
8642 bytes
I took the SELECT command from SQL and substituted `newsgroups' and
`headers' for references to `tables' and `columns'.  Also, I tried to keep
things simple and not tie features to the capabilities of a relational
database (no joins, no newsgroup aliasing, no implicit functions like
count() and avg(), and no nested selects (if you want nested if-thens,
you'll have to combine this search command set with something fancier from
your news client).  Keep in mind, this is a first attempt at something that
looks and feels like SQL syntactically but is tailored for Usenet.  I'm not
trying to invent a whole new language, just some one-shot searching commands
that (with a minimal amount of support) can be typed into a dialog panel in
some news client.  All the returned records are specified by the query.

If you're familiar with mSQL and its subset of ANSI SQL (its SELECT command,
in particular), this should look familiar.  I purposefully picked something
that was small and not terribly complex.  Looking at the SELECT command:

  SELECT <header>[, <header>...] FROM <newsgroup>[, <newsgroup>...]
    [WHERE <condition>...]
    [ORDER BY <header> [DESCENDING][, <header> [DESCENDING]...]]

Keywords need not be in all caps as shown nor do they need to be in any
particular layout (I'm laying them out with the hanging indent just to make
it legible here).  The whole query could be given on one line if you want.
``[]'' denotes optional arguments, ``<>'' denotes required arguments.
``...'' denotes repetition of the previous required or optional construct.

<header>

  Can be a single header or list of Usenet article headers separated with
  commas and an optional space.  The specified headers need not exist in all
  articles searched.  You can ORDER BY any headers you want, not just a
  subset of the headers you SELECTed (this may cause news servers to do two
  actions to complete a search -- first, find relevant articles, and second,
  sort them).

  There are some pseudo-headers to consider, headers that are not currently
  used in Usenet articles but are needed for searching purposes:

    ``article-body''     to search in the body of an article.
    ``e-mail-address''   to search in the e-mail address part of the From:
                         header.
    ``real-name''        to search in the real name part of the From:
                         header.
    ``article-number''   to search based on article numbers.

    If you need to refer to a header called `real-name', use a leading
    backslash (`\real-name') (see the examples below).  I've hopefully
    picked unusual but intuitive names for these pseudo-headers.

<newsgroup>

  Can be any single newsgroup, list of newsgroups or wildmat string that
  matches many newsgroups.  Wildmat matches use ``?'' for any single
  character and ``*'' for 0 or more characters.

<condition>

  Is true for any matching article.  Conditions are case insensitive and of
  the form:

    <header> [=|<|>|<>] <value> [AND | OR ]

  A value can use wildmat characters only in strings.  Greater than (>) and
  less than (>) can be used only for numeric and date comparisons.

  You can string together as many AND and OR clauses as you want in the
  WHERE section.  We should also let users use parentheses to force a
  particular interpretation of the AND and OR clauses.

ORDER BY

  Sorts the resulting articles by the named headers in ascending order
  (default) or descending order if the ``DESCENDING'' keyword is stated.
  Each sort criteria can be sorted in ascending or descending order.
  
  When two or more sort headers are listed, the final result is sorted first
  by the first named header, then (if multiple articles have the same value
  for the header first used for sorting) those (and only those articles) are
  sorted by the second named header and so on for every other header
  thereafter.

  DESCENDING refers to the sorting order of the resultant articles. This
  keyword means something different for each type of header:

    Type       DESCENDING order
    ---------- -------------------------
    Numeric    [high end of range], 999, 998, 997, 996, ..., [low end of range]
    String     Z, Y, X, ..., A (perhaps a reverse ASCII will be fine here?)
    Date       ..., [tomorrow], [today], [yesterday], [day before yesterday], ...

Response codes: (more appropriate choices should come with discussion)

  Using RFC-977-like response codes:

    280 article(s) retreived - results follow.
    
    380 query correct so far, send the rest of it.

    480 query correct but couldn't be performed for some reason.
    481 query correct but processing requires too much CPU time, partial
        results follow.

    580 query unimplemented, incorrect or a there was a serious program error.
    581 query syntax is incorrect.
    582 query explicitly includes newsgroups that don't exist at this server.
    583 query explicitly includes distribution keywords that don't exist at
        this server.

Here are some contrived search examples:

  SELECT subject, date, article-body FROM news.*
  WHERE real-name = Pat AND x-newsreader = 'SmartBase 2.1 Gold'
  ORDER BY date DESCENDING, subject

  This returns the Subject:, Date: and article bodies of all the articles in
  news.* newsgroups written by someone with `Pat' in their real name field
  using the `SmartBase 2.1 Gold' software.  The returned set of articles are
  sorted by date.  If there are any two articles with the same date, those
  articles are sorted in place by subject.

Example: ``Show me the entire content of all the articles written by
	   pat@patco.com between April 3, 1995 and December 12, 1995.  Sort
	   the results by date, newest to oldest.''

SELECT * FROM *
WHERE from contains pat@patco.com
  AND date > 19950403*
  AND date < 19951212*
ORDER BY date DESCENDING

{This date construction needs work.  It was something I used off the top of
my head -- YYYYMMDDHHMMSS where all times are either in GMT using a 24-hour
clock.  The use of the asterisk is context sensitive in my made-up example;
here, it means match any hour, minute and second.}

Example: ``In the alt.tv.real-world newsgroup, I would like to see the
	   subject and content of any post written by Neil.''

SELECT subject, article-body FROM alt.tv.real-world
WHERE real-name = Neil

Example: ``List the message-Ids of all the articles written after December
	   1, 1994.''

SELECT message-id FROM *
WHERE date > 19941201

SELECT subject, date, from:, reply-to, article-body FROM *car*

Example: ``Show me all the articles that did not start threads.'' (articles
with References: headers are followups to something, so just show those)

SELECT * FROM *
WHERE references contains *

Example: (NNTP commands without response codes)

  ``ARTICLE <slrn4ts446.i3o.jbn@mystery-train.cu-online.com>''    

SELECT * FROM *
WHERE message-id = <slrn4ts446.i3o.jbn@mystery-train.cu-online.com>

  Since there is only one article with that message-id, this search should
  return only one article.

Example: (searching on headers with the same name as pseudo-headers)

SELECT subject, date, article-body FROM *
WHERE \e-mail-address = abc@def.ghi.org AND \article-body = '-- '

  This returns the subject, date and article bodies of articles where the
  e-mail part of the From: header is abc@def.ghi.org and there are
  sigdashes.  The quotes around the sigdashes insure the space is taken as
  part of the search.

There are undoubtedly tons of problems with this, but in the abstract it
seems to me like a good thing and I hope this suggestion is taken in the
spirit of good will with which it is intended.  I am not suggesting this
should be adopted as-is without prior discussion.  I'm suggesting we start
talking about our needs and draft something to meet those needs.
-- 
Due to local news server and feed problems, I might not see all followups.


Technical Details
Message-ID: <slrn4u0au3.sj4.jbn@mystery-train.cu-online.com>
Path: mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!illumos!news.pugleaf.net!.TX!archive.pugleaf.net!archive.newsdeef.eu!mbox2nntp-news.software.nntp.mbox.zip!not-for-mail

Show Full Headers
Complete Article Headers
Message-ID: <slrn4u0au3.sj4.jbn@mystery-train.cu-online.com>
Subject: Suggested API for querying Usenet servers
Date: Sun, 07 Jul 1996 00:00:00 +0000
From: jbn@mystery-train.cu-online.com (J.B. Nicholson-Owens)
Path: mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!illumos!news.pugleaf.net!.TX!archive.pugleaf.net!archive.newsdeef.eu!mbox2nntp-news.software.nntp.mbox.zip!not-for-mail
X-Deja-AN: 164191093
Distribution: inet
Organization: Organizing Organisms & Organs
Newsgroups: news.software.nntp