From 5a2f3692cf0b2b569cb2db03425b4f62db7a02bf Mon Sep 17 00:00:00 2001 From: Jeff Becker Date: Sun, 24 Sep 2017 10:21:56 -0400 Subject: [PATCH] fix sql query --- contrib/backends/srndv2/src/srnd/nntp.go | 4 ++-- contrib/backends/srndv2/src/srnd/postgres.go | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/contrib/backends/srndv2/src/srnd/nntp.go b/contrib/backends/srndv2/src/srnd/nntp.go index d2b8d0d..afdef77 100644 --- a/contrib/backends/srndv2/src/srnd/nntp.go +++ b/contrib/backends/srndv2/src/srnd/nntp.go @@ -1365,7 +1365,7 @@ func (self *nntpConnection) scrapeServer(daemon *NNTPDaemon, conn *textproto.Con err = conn.PrintfLine("LIST NEWSGROUPS") if err == nil { // read response line - code, _, err := conn.ReadCodeLine(0) + code, line, err := conn.ReadCodeLine(0) if code == 231 || code == 215 { var groups []string // valid response, we expect a multiline @@ -1413,7 +1413,7 @@ func (self *nntpConnection) scrapeServer(daemon *NNTPDaemon, conn *textproto.Con } } else if err == nil { // invalid response no error - log.Println(self.name, "gave us invalid response to newsgroups command", code) + log.Println(self.name, "gave us invalid response to newsgroups command", line) } else { // invalid response with error log.Println(self.name, "error while reading response from newsgroups command", err) diff --git a/contrib/backends/srndv2/src/srnd/postgres.go b/contrib/backends/srndv2/src/srnd/postgres.go index 2b8970a..f601a3b 100644 --- a/contrib/backends/srndv2/src/srnd/postgres.go +++ b/contrib/backends/srndv2/src/srnd/postgres.go @@ -192,7 +192,7 @@ func (self *PostgresDatabase) prepareStatements() { GetMessageIDByHash: "SELECT message_id, message_newsgroup FROM Articles WHERE message_id_hash = $1 LIMIT 1", CheckEncIPBanned: "SELECT 1 FROM EncIPBans WHERE encaddr = $1", GetFirstAndLastForGroup: "WITH x(min_no, max_no) AS ( SELECT MIN(message_no) AS min_no, MAX(message_no) AS max_no FROM ArticleNumbers WHERE newsgroup = $1) SELECT CASE WHEN min_no IS NULL THEN 0 ELSE min_no END AS min_no FROM x UNION SELECT CASE WHEN max_no IS NULL THEN 1 ELSE max_no END AS max_no FROM x", - GetNewsgroupList: "SELECT newsgroup, min(message_no), max(message_no) FROM ArticlePosts GROUP BY newsgroup", + GetNewsgroupList: "SELECT newsgroup, min(message_no), max(message_no) FROM ArticleNumbers GROUP BY newsgroup", GetMessageIDForNNTPID: "SELECT message_id FROM ArticleNumbers WHERE newsgroup = $1 AND message_no = $2 LIMIT 1", GetNNTPIDForMessageID: "SELECT message_no FROM ArticleNumbers WHERE newsgroup = $1 AND message_id = $2 LIMIT 1", IsExpired: "WITH x(msgid) AS ( SELECT message_id FROM Articles WHERE message_id = $1 INTERSECT ( SELECT message_id FROM ArticlePosts WHERE message_id = $1 ) ) SELECT COUNT(*) FROM x",