X-Original-To: pgsql-sql-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.2]) by svr1.postgresql.org (Postfix) with ESMTP id 41826D1D38B for ; Fri, 5 Mar 2004 15:30:16 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) with ESMTP id 64214-01 for ; Fri, 5 Mar 2004 11:30:18 -0400 (AST) Received: from ll.mit.edu (LLMAIL.LL.MIT.EDU [129.55.12.40]) by svr1.postgresql.org (Postfix) with ESMTP id E16A3D1D313 for ; Fri, 5 Mar 2004 11:30:12 -0400 (AST) Received: (from smtp@localhost) by ll.mit.edu (8.12.10/8.8.8) id i25FUCw6013583; Fri, 5 Mar 2004 10:30:12 -0500 (EST) Received: from sty.llan.ll.mit.edu( ), claiming to be "sty.llan" via SMTP by llpost, id smtpdAAAFlaaj4; Fri Mar 5 10:23:45 2004 Date: Fri, 5 Mar 2004 10:23:45 -0500 From: george young To: Tom Lane Cc: pgsql-sql@postgresql.org Subject: Re: debugging query to put message in pg logfile? Message-Id: <20040305102345.60293483.gry@ll.mit.edu> In-Reply-To: <28982.1078436101@sss.pgh.pa.us> References: <20040304153219.210f3648.gry@ll.mit.edu> <28982.1078436101@sss.pgh.pa.us> Reply-To: gry@ll.mit.edu Organization: MIT Lincoln Laboratory X-Mailer: Sylpheed version 0.9.7 (GTK+ 1.2.10; i686-pc-linux-gnu) Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200403/43 X-Sequence-Number: 17142 On Thu, 04 Mar 2004 16:35:01 -0500 Tom Lane threw this fish to the penguins: > george young writes: > > I've started putting debugging queries like: > > select "opwin.py: committing step signoff" > > in my app, just to have an entry in the postgres logfile. > > > Is there some cheaper (or more appropriate) sql statement that will show > > up in the postgres log? > > You could just send SQL comments: > > -- opwin.py: committing step signoff > > One advantage of this is that you can merge the comments with actual > commands, thus not incurring even a network round-trip time for them. > If you do send it separately, it will act like an empty query string. > > People tend not to think of this because psql strips -- comments before > sending commands. But I believe all the lower-level libraries will pass > them through. (If you need to pass loggable comments through psql, I > think the /* ... */ form will work.) Alas no: Python 2.3.3 (#1, Jan 3 2004, 07:17:11) [GCC 3.3.2] on linux2 >>> import pgdb >>> db=pgdb.connect(host='ivy:5433',database='pigtest') >>> c=db.cursor() >>> cur.execute('-- the rain') Traceback (most recent call last): File "", line 1, in ? File "/usr/local/lib/python2.3/site-packages/pgdb.py", line 189, in execute self.executemany(operation, (params,)) File "/usr/local/lib/python2.3/site-packages/pgdb.py", line 210, in executemany raise OperationalError, "internal error in '%s'" % sql pgdb.OperationalError: internal error in '-- the rain' Likewise for /* comments */. :-( I'll continue this on the pygresql mailing list; and I guess stick to "select 'comment text'" for now... Thanks, -- George Young -- "Are the gods not just?" "Oh no, child. What would become of us if they were?" (CSL)