Received: from sss.pgh.pa.us ([192.204.191.242]) by postgresql.org (8.11.3/8.11.1) with ESMTP id f67JBIa07263 for ; Sat, 7 Jul 2001 15:11:18 -0400 (EDT) (envelope-from tgl@sss.pgh.pa.us) Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) by sss.pgh.pa.us (8.11.4/8.11.4) with ESMTP id f67JBFJ28863; Sat, 7 Jul 2001 15:11:15 -0400 (EDT) To: "Josh Berkus" cc: pgsql-sql@postgresql.org Subject: Re: creating variable views In-reply-to: References: Comments: In-reply-to "Josh Berkus" message dated "Fri, 06 Jul 2001 15:51:44 -0700" Date: Sat, 07 Jul 2001 15:11:15 -0400 Message-ID: <28860.994533075@sss.pgh.pa.us> From: Tom Lane X-Archive-Number: 200107/86 X-Sequence-Number: 3870 "Josh Berkus" writes: > All this function does is format output, rather than perform any fancy > manipulation. I find that the Postgres view optimizer has no trouble > with such functions. > More complex functions, like qf_calc_next_invoice_date(VARCHAR) which > calculates a client's next invoice date based on their invoice interval > plus certain system variables pretty much kills the view optimizer if I > do a WHERE on that column, since the optimizer doesn't know what to > expect from the function. I don't understand the distinction you're trying to make here. In general, a view column that is implemented as a function will give the optimizer headaches if you refer to it in WHERE --- the simplicity or complexity of the function has got nothing to do with that AFAICS. > That was an example of the sort of sweeping user access change one might > be asked to implement. For example, you might set up the system at the > start so that only the Sysadmin can "void" (cancel) financial > transactions for security purposes. However, changes in your company's > business policies in 3 months may dictate that the whole accounting > dept. needs to be able to void. Using SQL DB security, this can be a > serious headache, as opposed to a single update with an interface-based > system. Seems to me that such a change could be trivial, or a serious headache, with *either* SQL GRANT-based security or application-based security. The critical factor is going to be whether you represented the "voiding" access privilege separately from the other special privileges of the sysadmin. I don't see how one implementation is going to encourage you to have that foresight better than the other one would. regards, tom lane