Re: [GENERAL] 7.4 in-lining of SQL functions

2004-10-14 Thread Tom Lane
Mike Mascari <[EMAIL PROTECTED]> writes: > "Simple SQL functions can now be inlined by including their SQL in the > main query. This improves performance by eliminating per-call overhead. > That means simple SQL functions now behave like macros." > has me a bit worried. What does "simple" mean?

Re: [GENERAL] 'NOW' in UTC with no timezone

2004-10-14 Thread Jaromir Dolecek
Stuart Bishop wrote: > Indeed - I was under the impression that the timezone would be preserved > (which is the case in the external datetime libraries I use), but I now > see that PostgreSQL will lose this information. Err - how come, lose? Jaromir -- Jaromir Dolecek <[EMAIL PROTECTED]>

Re: [GENERAL] 'NOW' in UTC with no timezone

2004-10-14 Thread Stuart Bishop
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 Tom Lane wrote: | Stuart Bishop <[EMAIL PROTECTED]> writes: | |>How much overhead is there in storing a timestamp with timezone as |>opposed to one without? | | | Exactly zero. You have a misconception about what the datatype really | does --- see othe

Re: [GENERAL] Is there an opposite to pg_get_userbyid() ?

2004-10-14 Thread Andreas
Michael Fuhr wrote: On Thu, Oct 14, 2004 at 07:42:22PM +0200, Andreas wrote: or is there a complement to pg_get_userbyid() ? If there is then I've overlooked it in the documentation. It's easy enough to write: Thanks :) I though it was consequent to expect such a function, since there

[GENERAL] test -- please ignore

2004-10-14 Thread Scott Frankel
This is a test -- please ignore ---(end of broadcast)--- TIP 3: 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

[GENERAL] unsubscribe

2004-10-14 Thread Keow Yeong Huat Joseph
Hi, Can anyone tell me how to unsubscribe my address from the mailing list. Thanks.   Regards Joseph

Re: [GENERAL] Is there an opposite to pg_get_userbyid() ?

2004-10-14 Thread Michael Fuhr
On Thu, Oct 14, 2004 at 07:42:22PM +0200, Andreas wrote: > > I'd like to store who changed records on some tables. > I'd prefer not to store the username but rather his/her ID. > Will I allways have to run > select usesysid from pg_user where usename=session_user; > or is there a complement to pg_g

[GENERAL] 7.4 in-lining of SQL functions

2004-10-14 Thread Mike Mascari
Hello. I'm writing SQL functions that take an action code and determine the rows visible by accessing application-maintained privilege tables. Here's an example: CREATE FUNCTION sql_areas(bigint) RETURNS SETOF bigint AS ' SELECT _areas.area FROM _members, _webgroups, _stores, _areas WHERE

[GENERAL] Complex Update Queries with Fromlist

2004-10-14 Thread Mark Dexter
Title: Complex Update Queries with Fromlist In Microsoft SQL Server, I can write an UPDATE query as follows: update orders set RequiredDate = (case when c.City IN ('Seattle','Portland') then o.OrderDate + 2  else o.OrderDate + 1 end) from orders o join customers c on o.Customerid = c.C

Re: [GENERAL] psycopg help

2004-10-14 Thread Lee Harr
My very simple table creation test (based on their "first.py" example is failing ... Here's what I'm trying. Non-pythonated syntax works in pgsql: no go: curs.execute("""CREATE TABLE key_test ( key_col CHAR(9) PRIMARY KEY, nother_col CHAR(256))""") Works fine for me: d=psycopg.

R: [GENERAL] Count Issues

2004-10-14 Thread Luciano Bastianello
SELECT COUNT(*) from mytable --- Bastianello Luciano Software Consultant - Apprentice Sorcerer e-mail: [EMAIL PROTECTED] e-mail: [EMAIL PROTECTED] ICQ: 209754422 - MSN: [EMAIL PROTECTED] --- ---

Re: [GENERAL] Possibly stupid questions re: large tables/files, port 5432 access

2004-10-14 Thread Alvaro Herrera
On Thu, Oct 14, 2004 at 02:00:51PM -0700, Michael Holden wrote: > There is a file located at > > /usr/local/pgsql/data/base/26920/ > > named 35987 that is roughly 750mb. Is there any way to find out what > table or database this file belongs to? Sure, use contrib/oid2name. > I really shouldn

Re: [GENERAL] Count Issues

2004-10-14 Thread John Sidney-Woollett
How about ... select count(distinct this) from table John Sidney-Woollett Dev wrote: Hello all, I am trying to get a total number of rows returned form a query. SELECT count(this) from table group by this Currently it is returning x rows with a count of each of the group by. I need the count of th

Re: [GENERAL] Count Issues

2004-10-14 Thread Steven Klassen
* Dev <[EMAIL PROTECTED]> [2004-10-14 16:54:56 -0400]: > I am trying to get a total number of rows returned form a query. > > SELECT count(this) from table group by this Remove the 'group by' clause -- you don't need it. -- Steven Klassen - Lead Programmer Command Prompt, Inc. - http://www.com

Re: [GENERAL] Count Issues

2004-10-14 Thread Andre Maasikas
Dev wrote: Hello all, I am trying to get a total number of rows returned form a query. SELECT count(this) from table group by this Currently it is returning x rows with a count of each of the group by. I need the count of the rows returned! SELECT COUNT(DISTINCT this) FROM table Andre

Re: [GENERAL] Boolean

2004-10-14 Thread Thomas F . O'Connell
http://www.postgresql.org/docs/7.4/static/datatype-boolean.html CASE WHEN its THEN 'true' ELSE 'false' END -tfo On Oct 14, 2004, at 3:43 PM, Bambero wrote: Postgres returns me 't' or 'f' from boolean field How to change that it returns me 'true' or 'false' replace(its, 'f', 'false') AS its doesn't

[GENERAL] Possibly stupid questions re: large tables/files, port 5432 access

2004-10-14 Thread Michael Holden
Hi, folks There is a file located at /usr/local/pgsql/data/base/26920/ named 35987 that is roughly 750mb. Is there any way to find out what table or database this file belongs to? I really shouldn't have that much data in any of my tables, so I'm fairly certain that this is a bug in my code

[GENERAL] Count Issues

2004-10-14 Thread Dev
Hello all, I am trying to get a total number of rows returned form a query. SELECT count(this) from table group by this Currently it is returning x rows  with a count of each of the group by. I need the count of the rows returned! Any way to do this?   Brian C. Doyle Director, In

[GENERAL] Boolean

2004-10-14 Thread Bambero
Postgres returns me 't' or 'f' from boolean field How to change that it returns me 'true' or 'false' replace(its, 'f', 'false') AS its doesn't work Bambero ---(end of broadcast)--- TIP 9: the planner will ignore your desire to choose an index scan if

Re: [GENERAL] dirty reads

2004-10-14 Thread Bruce Momjian
Josh Close wrote: > Is there a way to do "dirty" reads on postgres? > > If there is an insert of a million records or so, is there a way to > select from those records before it's committed? By your transaction, sure, by another, no. -- Bruce Momjian| http://candle.p

[GENERAL] dirty reads

2004-10-14 Thread Josh Close
Is there a way to do "dirty" reads on postgres? If there is an insert of a million records or so, is there a way to select from those records before it's committed? -Josh ---(end of broadcast)--- TIP 8: explain analyze is your friend

Re: [GENERAL] not using index through procedure

2004-10-14 Thread Robin Ericsson
Martijn van Oosterhout <[EMAIL PROTECTED]> wrote: > One's marked VOLATILE, the other is marked IMMUTABLE. This affects > whether it's considered a constant, the planner estimates and hence > whether it uses the index. Is there even a way to solve it this way via a procedure? I've tried different

Re: [GENERAL] tcl bindings for 8.0

2004-10-14 Thread David Rysdam
David Rysdam wrote: The README from 8.0-beta3 says "This distribution also contains several language bindings, including C and Tcl" but I'm not finding libpgtcl being built, nor can I find a way to tell it to. I see pgtcl is on http://gborg.postgresql.org, so this mean that the README is out o

Re: [GENERAL] creating audit tables

2004-10-14 Thread Ian Harding
Here's what I do... It's not pretty but it works. create table auditlog ( auditwhen timestamp not null default CURRENT_TIMESTAMP, auditwhat char(10) not null, audittable varchar not null, auditkeyval int not null, auditfield varchar not null, oldval

[GENERAL] Does PostgreSQL provide anything comparable with MySQL Cluster?

2004-10-14 Thread nd02tsk
Hello Does PostgreSQL provide anything comparable with the functionality of MySQL Cluster? I appreciate all information. Thank you. Tim ---(end of broadcast)--- TIP 3: if posting/reading through Usenet, please send an appropriate subscribe

Re: [GENERAL] 8.0 questions

2004-10-14 Thread Vivek Khera
> "GS" == Greg Stark <[EMAIL PROTECTED]> writes: GS> David Garamond <[EMAIL PROTECTED]> writes: GS> Another reason to move to 7.4.5 would be that each version GS> introduced changes in behaviour. You're going to be dealing with GS> minor headaches from things like '' not being a valid integer

[GENERAL] tcl bindings for 8.0

2004-10-14 Thread David Rysdam
The README from 8.0-beta3 says "This distribution also contains several language bindings, including C and Tcl" but I'm not finding libpgtcl being built, nor can I find a way to tell it to. I see pgtcl is on http://gborg.postgresql.org, so this mean that the README is out of date and I need to

Re: [GENERAL] creating audit tables

2004-10-14 Thread Scott Cain
Heck! So much for feeling close. It is somewhat frustrating to me that such an obviously useful tool (having and using audit tables) should be so difficult to implement. I thought I had a reasonable chance of doing it in plpgsql because I've written functions in that before--I have no idea how t

Re: [GENERAL] creating audit tables

2004-10-14 Thread Richard Huxton
Scott Cain wrote: I feel like I am getting very close, but I am still not quite there. I rewrote the trigger function below to use execute, but now I get the following error: ERROR: OLD used in query that is not in a rule CONTEXT: PL/pgSQL function "audit_update" line 5 at execute statement It s

[GENERAL] Is there an opposite to pg_get_userbyid() ?

2004-10-14 Thread Andreas
Hi, I'd like to store who changed records on some tables. I'd prefer not to store the username but rather his/her ID. Will I allways have to run select usesysid from pg_user where usename=session_user; or is there a complement to pg_get_userbyid() ? Can I have this as a default-value for a create

Re: [GENERAL] Need some advice on appropriate PL strategy... ["solved/thanks"]

2004-10-14 Thread Michael Fuhr
On Tue, Oct 12, 2004 at 12:20:46PM -0400, Eric D Nielsen wrote: > > I was hoping for a get/easy solution, but those never pan out :) Here's a trivial Python program that handles NOTIFY events; it couldn't get much easier: #!/usr/local/bin/python import psycopg import select conn = psycopg.conn

Re: [GENERAL] Verifying a user.

2004-10-14 Thread Steven Klassen
* Steven Klassen <[EMAIL PROTECTED]> [2004-10-14 10:07:39 -0700]: > CREATE FUNCTION check_passwd(text,text) RETURNS boolean AS 'SELECT > CASE WHEN passwd = md5($2) THEN true ELSE false END FROM pg_shadow > WHERE usename = $1;' LANGUAGE sql; Strike that - go with what Michael recommended. I glance

Re: [GENERAL] Verifying a user.

2004-10-14 Thread Steven Klassen
* Thomas Hallgren <[EMAIL PROTECTED]> [2004-10-14 17:27:20 +0200]: > I'm connected to a database and I want to verify that a username and > password for some user is correct. I know I can verify a users existence > by doing: > > select exists(select * from pg_user where usename = $1) You can g

Re: [GENERAL] Verifying a user.

2004-10-14 Thread Michael Fuhr
On Thu, Oct 14, 2004 at 05:27:20PM +0200, Thomas Hallgren wrote: > I'm connected to a database and I want to verify that a username and > password for some user is correct. I know I can verify a users existence > by doing: > > select exists(select * from pg_user where usename = $1) > > but I wo

Re: [GENERAL] not using index through procedure

2004-10-14 Thread Martijn van Oosterhout
One's marked VOLATILE, the other is marked IMMUTABLE. This affects whether it's considered a constant, the planner estimates and hence whether it uses the index. On Thu, Oct 14, 2004 at 05:30:58PM +0200, Robin Ericsson wrote: > After some discussion on performance list, I guess this is back to a >

Re: [GENERAL] creating audit tables

2004-10-14 Thread Scott Cain
I feel like I am getting very close, but I am still not quite there. I rewrote the trigger function below to use execute, but now I get the following error: ERROR: OLD used in query that is not in a rule CONTEXT: PL/pgSQL function "audit_update" line 5 at execute statement It seems that I am n

Re: [GENERAL] Date format for bulk copy

2004-10-14 Thread Michael Fuhr
On Wed, Oct 13, 2004 at 03:37:14PM -0400, David Rysdam wrote: > Michael Fuhr wrote: > > > >I'd probably choose to extend PostgreSQL rather than hack what > >already exists, though. > > By "extend PostgreSQL" do you mean create a custom input_function for > timestamp? Are there docs that give hint

[GENERAL] Verifying a user.

2004-10-14 Thread Thomas Hallgren
I'm connected to a database and I want to verify that a username and password for some user is correct. I know I can verify a users existence by doing: select exists(select * from pg_user where usename = $1) but I would like to verify the correctness of the password as well. Is there a way to d

Re: [GENERAL] Date format for bulk copy

2004-10-14 Thread Michael Fuhr
On Wed, Oct 13, 2004 at 08:36:50PM +0200, Pierre-Fr?d?ric Caillaud wrote: > > You can have your script make a query in the database to fetch the > data types of the fields and then know which ones are to be transformed > and how. The script would take as arguments a dump file and a

[GENERAL] not using index through procedure

2004-10-14 Thread Robin Ericsson
After some discussion on performance list, I guess this is back to a general question :) This is very simplified query of my real problem, but it should show the way of the problems. CREATE OR REPLACE FUNCTION ago(interval) RETURNS timestamp AS 'SELECT (now() - $1)::timestamp without time zone'

Re: [GENERAL] creating audit tables

2004-10-14 Thread Ian Harding
I think you want to EXECUTE that sql so it doesn't get compiled into the function. http://www.postgresql.org/docs/7.4/static/plpgsql-statements.html#PLPGSQL-STATEMENTS-EXECUTING-DYN - Ian >>> Scott Cain <[EMAIL PROTECTED]> 10/14/04 8:01 AM >>> OK, I've reworked my function and I can now create m

Re: [GENERAL] psql : how to make it more silent....

2004-10-14 Thread David Rysdam
Gaetano Mendola wrote: Patrick Fiche wrote: Hi, When I execute a function, I would like psql to show me only RAISE NOTICE messages but not all function calls Indeed, I currently get some messages that I don't care about : * PL/pgSQL function "adm_user" line 321.. * CONTEXT: SQ

Re: [GENERAL] creating audit tables

2004-10-14 Thread Scott Cain
OK, I've reworked my function and I can now create my functions and triggers; however, when I try to do a test update, I get the following error: ERROR: syntax error at or near "$1" at character 14 CONTEXT: PL/pgSQL function "audit_update" line 7 at SQL statement Which I think corresponds to 'a

Re: [GENERAL] solaris and ps

2004-10-14 Thread Leonardo Francalanci
"In addition, your original invocation of the postmaster command must have a shorter ps status display than that provided by each server process." Yes, using PGDATA instead of the whole path eith the -D option worked: now I can see the different status displays. ---(end of

Re: [GENERAL] solaris and ps

2004-10-14 Thread Michael Fuhr
On Thu, Oct 14, 2004 at 08:24:19AM -0600, Michael Fuhr wrote: > > As far as I can tell, for /usr/ucb/ps the show the replacement > arguments, the sum of the lengths of the replacement arguments > must be 2 or more greater than the sum of the lengths of the > original arguments. I'm guessing that

Re: [GENERAL] solaris and ps

2004-10-14 Thread Michael Fuhr
On Thu, Oct 14, 2004 at 11:14:10AM +0100, Richard Huxton wrote: > Leonardo Francalanci wrote: > >I read "Chapter 23. Monitoring Database Activity" to monitor postgresql, > >but on Solaris it doesn't work. I tried "/usr/ucb/ps", but it doesn't > >work either (I only see the postmaster startup para

[GENERAL] sum 2 arrays of general int type

2004-10-14 Thread Leonardo Francalanci
I wrote a function to sum arrays. It works, but I had to cast the data pointer to int64 (because my arrays are 'int8[]'): int64* ptr1 = ARR_DATA_PTR(v1); What if I want to write a more general function that adds values of 2 arrays of every int type? How could I do it? Here is the function (if y

[GENERAL] IMPORT FROM CTREE to POSTGRESQL

2004-10-14 Thread Rodrigo Carvalhaes
Hi Guys! Anyone already made a importation from CTREE files ( files .dtc) to PostgreSQL ? I know that there is a "contrib" tool to import files from dbf to sql... Any tip ? -- Cheers , Rodrigo Miranda Carvalhaes ---(end of broadcast)--- TIP 6: Have

Re: [GENERAL] 'NOW' in UTC with no timezone

2004-10-14 Thread Tom Lane
Stuart Bishop <[EMAIL PROTECTED]> writes: > How much overhead is there in storing a timestamp with timezone as > opposed to one without? Exactly zero. You have a misconception about what the datatype really does --- see other responses in this thread. regards, tom lane -

Re: [GENERAL] any way to remove a password?

2004-10-14 Thread Tom Lane
Neil Berkman <[EMAIL PROTECTED]> writes: > Is there any way to remove a password, specifically from the postgres > user? You can set the field to NULL in pg_shadow, though I really wonder why you'd bother, if you're not using password authentication. regards, tom lane ---

Re: [GENERAL] beta3 winxp initdb problems

2004-10-14 Thread Piotr Filipczuk
Hi. I understand that you are using NOD32 software. To correct install postgres you must first uninstall IMON from NOD32. IMON is som how intgerete with windows socket and somehow brake communication with postgresql database. Piotr Filipczuk BARTKO, Zoltán wrote: Hello, folks, I am trying to ins

Re: [GENERAL] solaris and ps

2004-10-14 Thread Richard Huxton
Leonardo Francalanci wrote: I read "Chapter 23. Monitoring Database Activity" to monitor postgresql, but on Solaris it doesn't work. I tried "/usr/ucb/ps", but it doesn't work either (I only see the postmaster startup parameters). Isn't there any other solution to see what postgresql instances a

Re: [GENERAL] 'NOW' in UTC with no timezone

2004-10-14 Thread Stuart Bishop
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 Tom Lane wrote: | Stuart Bishop <[EMAIL PROTECTED]> writes: | |>I'm trying to determine the best way of saying 'The current time in UTC |>with no time zone information'. | | | Isn't that a contradiction in terms? Not at all - I want 'now' in UTC time wi

Re: [GENERAL] beta3 winxp initdb problems

2004-10-14 Thread BARTKO, Zoltán
Magnus, et al., This is, what initdb -d says: D:\tmp\data>initdb -d Running in debug mode. VERSION=8.0.0beta3 PGDATA=d:/tmp/data share_path=c:/msys/1.0/share/postgresql PGPATH=c:/msys/1.0/bin POSTGRES_SUPERUSERNAME=postgresql POSTGRES_BKI=c:/msys/1.0/share/postgresql/postgres.bki POSTGRES_DESC

Re: [GENERAL] psycopg help

2004-10-14 Thread Pierre-Frédéric Caillaud
interface to postgresql. A mailing list would be ideal. I've [EMAIL PROTECTED] ---(end of broadcast)--- TIP 3: if posting/reading through Usenet, please send an appropriate subscribe-nomail command to [EMAIL PROTECTED] so that your mes

[GENERAL] solaris and ps

2004-10-14 Thread Leonardo Francalanci
I read "Chapter 23. Monitoring Database Activity" to monitor postgresql, but on Solaris it doesn't work. I tried "/usr/ucb/ps", but it doesn't work either (I only see the postmaster startup parameters). Isn't there any other solution to see what postgresql instances are doing? -

Re: [GENERAL] Recovering data from corrupted table. Urgent Help!!

2004-10-14 Thread Gaetano Mendola
ruben wrote: > Hi Gaetano: > > This procedure to recover data from a corrupted table should be > documented somewhere... If it is, I could not find it! First of all the table was not corrupted, the glitch was in another subsystem. The procedure is documented in the archives :-( I agree with you but

Re: [GENERAL] Networking feature for postgresql...

2004-10-14 Thread Richard Huxton
Katsaros Kwn/nos wrote: Well, actually no :) ! Thanks for the hint! But just from curiosity, would the scenario I described work? I mean is it possible for an SPI process to run in the background while other SPI calls are made? I don't think so, you're running in a backend process, so you'd need to

Re: [GENERAL] Networking feature for postgresql...

2004-10-14 Thread Katsaros Kwn/nos
Well, actually no :) ! Thanks for the hint! But just from curiosity, would the scenario I described work? I mean is it possible for an SPI process to run in the background while other SPI calls are made? Ntinos Katsaros On Thu, 2004-10-14 at 11:15, Richard Huxton wrote: > Katsaros Kwn/nos wrote

Re: [GENERAL] Networking feature for postgresql...

2004-10-14 Thread Richard Huxton
Katsaros Kwn/nos wrote: Hi, I'm trying to add a -project specific- networking feature to my postgres build (or database as function). What I want to do is to send a Query instance (as a String-retrieved through an SPI function) to other machines and (after they have executed it) to receive result t

[GENERAL]

2004-10-14 Thread BARTKO, Zoltán
Magnus, et al, my server seems to play games with me, so here I am sending it again. Zoltan http://www.pobox.sk/ - spolahliva a bezpecna prevadzka RE_ [GENERAL] beta3 winxp initdb problems.msg.eml Description: Binary data ---(en

[GENERAL] Networking feature for postgresql...

2004-10-14 Thread Katsaros Kwn/nos
Hi, I'm trying to add a -project specific- networking feature to my postgres build (or database as function). What I want to do is to send a Query instance (as a String-retrieved through an SPI function) to other machines and (after they have executed it) to receive result tuples. It's about a med

Re: [GENERAL] beta3 winxp initdb problems

2004-10-14 Thread Magnus Hagander
> Hello, folks, > > I am trying to install pgsql8 on winxp. I tried first to install "as > is" with pginstaller beta2-dev3, no luck, it froze, switched off > Nod32, froze a little later, ran through the list of services, > switched off anything that seemed to be a firewall, no luck. > > So I comp

[GENERAL] beta3 winxp initdb problems

2004-10-14 Thread BARTKO, Zoltán
Hello, folks, I am trying to install pgsql8 on winxp. I tried first to install "as is" with pginstaller beta2-dev3, no luck, it froze, switched off Nod32, froze a little later, ran through the list of services, switched off anything that seemed to be a firewall, no luck. So I compiled beta3 with