Re: [SQL] sysid

2005-11-25 Thread Vivek Khera


On Nov 23, 2005, at 10:45 AM, Alvaro Herrera wrote:


A. R. Van Hook wrote:
It seems that in 8.1.0 we can no longer set the SYSID when adding  
users

and groups.
i.e
template1=# create role hooker sysid 1345;
NOTICE:  SYSID can no longer be specified

I have lots of code that depends on the actual group and user number.
Is there a way to set the user and group number?


No -- fix the code.  Just curious, how can user code depend on the
SYSIDs?  I don't see a way.



If 8.1 doesn't allow you to remove a user who still has rights  
granted, then this should be no problem.  however, in older versions  
you can delete users and leave dangling rights with no way to revoke  
them unless you create a user with that specific ID and then revoke  
the rights, and re-delete the user.



---(end of broadcast)---
TIP 9: In versions below 8.0, the planner will ignore your desire to
  choose an index scan if your joining column's datatypes do not
  match


Re: [SQL] Order of precedence between AND and OR.

2005-11-25 Thread Tom Lane
David Pradier <[EMAIL PROTECTED]> writes:
> But what I couldn't find is if there is an order of precedence between
> AND and OR, that is if the AND expression is calculated before the OR
> one, or anyelse way.

AND first; see
http://www.postgresql.org/docs/8.1/static/sql-syntax.html#SQL-PRECEDENCE
This is required by the SQL spec.

But you probably also want to read
http://www.postgresql.org/docs/8.1/static/sql-expressions.html#SYNTAX-EXPRESS-EVAL

regards, tom lane

---(end of broadcast)---
TIP 1: if posting/reading through Usenet, please send an appropriate
   subscribe-nomail command to [EMAIL PROTECTED] so that your
   message can get through to the mailing list cleanly


[SQL] Order of precedence between AND and OR.

2005-11-25 Thread David Pradier
Hi everybody,

during the code inspection due to our migration to 8.1,
I found a piece of SQL code written like this :

WHERE a AND b OR c AND d

Now, I know that AND and OR are commutative because it's written in the
docs.
But what I couldn't find is if there is an order of precedence between
AND and OR, that is if the AND expression is calculated before the OR
one, or anyelse way.

Could somebody tell me or point me to the right doc ?

Thanks in advance,
David

-- 
David Pradier -- Directeur Technique de Clarisys Informatique -- Chef de projet 
logiciels libres / open-source

---(end of broadcast)---
TIP 1: if posting/reading through Usenet, please send an appropriate
   subscribe-nomail command to [EMAIL PROTECTED] so that your
   message can get through to the mailing list cleanly


Re: [SQL] Variable column names in PL/pgSQL RECORD referencces

2005-11-25 Thread Tom Lane
"Ken Winter" <[EMAIL PROTECTED]> writes:
> In PL/pgSQL, is there a way to put a *variable* column-name in a dot
> notation reference to a RECORD column?

No.  Some of the other, less-strongly-typed PLs can do it.

regards, tom lane

---(end of broadcast)---
TIP 2: Don't 'kill -9' the postmaster


[SQL] Variable column names in PL/pgSQL RECORD referencces

2005-11-25 Thread Ken Winter








(Sorry for the redundancy –
I sent this query earlier but forgot to put a title on it.  Seems like it
would be more useful with a title, so here it is again.  If there’s
a moderator who can delete my earlier message, please do so.)

 

In PL/pgSQL, is there a way
to put a *variable* column-name in a dot notation reference to a RECORD column?

 

For example, suppose I want
to write a function like the following, which is to be called by a "BEFORE
INSERT" trigger:

 

CREATE OR REPLACE FUNCTION foo
(  ) RETURNS TRIGGER AS 

    '

    DECLARE 

   
var VARCHAR;

    BEGIN

   
var := TG_ARGV[0]   

   
NEW. := ''whatever'';

   
RETURN NEW; 

    END;

    '

    LANGUAGE
'plpgsql'

;

 

The aim of this
uninteresting function is to assign the value 'whatever' to the table column
that is passed in by the calling trigger as TG_ARGV[0], i.e. the first calling
argument.  

 

What I don't know is what to
put into the dot notation in place of "." so that the column of NEW that is addressed by the
assignment statement is the one passed in as the first argument.  Is there
any PL/pgSQL construct that could be substituted in here to achieve this
result?

 

If not, can anybody suggest
a way to write a trigger-called function that would accomplish the same result?

 

In case it's not obvious,
the underlying goal is to write a single trigger-called function that could
modify different columns for each trigger that called it, where each trigger
specified the target column by a calling argument (or by any other viable
mechanism).

 

~ TIA

~ Ken

 

 








[SQL] LISTEN/NOTIFY

2005-11-25 Thread Stéphane RIFF

Hi all,

I just saw in the documentation the LISTEN/NOTIFY commands but i don't 
understand how i can use them.


Can someone show me an example in PLPGSQL that use this system ?

=> A process send a NOTIFY command and a LISTEN process execute his own 
commands.


Hope this clear, thanks
Steff

---(end of broadcast)---
TIP 4: Have you searched our list archives?

  http://archives.postgresql.org


Re: [SQL] LISTEN/NOTIFY

2005-11-25 Thread Stéphane RIFF
Forget about this post, i hadn't well understand what i can do with this 
system,

now i find an example in the 8.0 doc with libpq that show me how it works

Sorry
THX
Steff

---(end of broadcast)---
TIP 1: if posting/reading through Usenet, please send an appropriate
  subscribe-nomail command to [EMAIL PROTECTED] so that your
  message can get through to the mailing list cleanly


Re: [SQL] Updatable views: any decent front-ends?

2005-11-25 Thread Thomas Kellerer

Bath, David wrote on 24.11.2005 23:57:

While I can happily create rules on views to allow inserts, updates
and deletes, I can't find a GUI front-end that understands that the
view allows record edits that I can run on linux (whether through X
or web-based doesn't matter) and simply open the relation and edit
data without designing horrible forms with lots of code.

I note that MS-Access allows this, as it asks for the field(s) that
are unique and can be used for updating when you "attach" a table,
but I don't have (or want) a Windows box or MS-Office.

So
1) Does anybody know of a tool that allows easy editing of data in
   views?


You might want to try my SQL Workbench:

http://www.sql-workbench.net

It will not auto-detect the key columns for updating the view, but it 
will allow you to select them manually if needed (for update/delete). 
Maybe I'll add automatic detection of the keys in the near future (if I 
find the time)


It is written in Java (Swing) and thus should (and does) work on Linux.

Whether it qualifies as "decent" is up to you :)


Thomas


---(end of broadcast)---
TIP 4: Have you searched our list archives?

  http://archives.postgresql.org


Re: [SQL] does indexes need statistics?

2005-11-25 Thread Andrew Sullivan
On Thu, Nov 24, 2005 at 07:43:28PM +0100, Mauricio Fernandez A. wrote:
> Is it necesary the statistics be enabled when I create indexes or to
> use them?

Uh, yes, but you can't turn them off.  I suspect I don't understand
your question.  Do you mean the "runtime statistics" section of the
configuration file?  If that's what you mean, then no.  Those aren't
the same thing as the statistical data used by the planner; the
latter is updated when you run "analyse".

A

-- 
Andrew Sullivan  | [EMAIL PROTECTED]
"The year's penultimate month" is not in truth a good way of saying
November.
--H.W. Fowler

---(end of broadcast)---
TIP 5: don't forget to increase your free space map settings