X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.2]) by svr1.postgresql.org (Postfix) with ESMTP id A6067D1D43B for ; Sat, 6 Mar 2004 21:06:13 +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 23530-04 for ; Sat, 6 Mar 2004 17:06:12 -0400 (AST) Received: from sss.pgh.pa.us (unknown [192.204.191.242]) by svr1.postgresql.org (Postfix) with ESMTP id B8942D1D400 for ; Sat, 6 Mar 2004 17:06:09 -0400 (AST) Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) by sss.pgh.pa.us (8.12.11/8.12.11) with ESMTP id i26L692o018410; Sat, 6 Mar 2004 16:06:09 -0500 (EST) To: siracusa@mindspring.com Cc: Postgres Performance Subject: Re: Feature request: smarter use of conditional indexes In-reply-to: References: Comments: In-reply-to John Siracusa message dated "Sat, 06 Mar 2004 15:51:47 -0500" Date: Sat, 06 Mar 2004 16:06:09 -0500 Message-ID: <18409.1078607169@sss.pgh.pa.us> From: Tom Lane X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200403/76 X-Sequence-Number: 5932 John Siracusa writes: > So apparently all I can do is find out if it's a null test, but not if it is > specifically "IS NOT NULL" No, because once you have determined that the node really IsA NullTest, you can cast the pointer to (NullTest *) and look at the NullTest-specific fields. Think of this as poor man's object-oriented programming: Node is the supertype of Expr which is the supertype of NullTest (and a lot of other kinds of nodes, too). It'd look something like if (IsA(predicate, NullTest) && ((NullTest *) predicate)->nulltesttype == IS_NOT_NULL) { /* check to see if arg field matches either side of opclause, * and if so check whether operator is strict ... */ } You can find plenty of examples of this programming pattern throughout the backend. In fact pred_test_simple_clause is doing exactly this to check that what it's given is an OpExpr and not some other node type. regards, tom lane