Re: [GENERAL] newbie question... how do I get table structure?

2004-02-06 Thread Aaron Bratcher
Is there no way I can do it with a standard select command in a different client? I don't need the indexes, just the column names/types. -- Aaron Bratcher ab DataTools http://www.abDataTools.com On Feb 6, 2004, at 8:12 AM, Harald Fuchs wrote: In article <[EMAIL PROTECTED]>, "Joshua D. Drake" <[

Re: [GENERAL] newbie question... how do I get table structure?

2004-02-06 Thread Mark Gibson
Aaron Bratcher wrote: Is there no way I can do it with a standard select command in a different client? I don't need the indexes, just the column names/types. For PostgreSQL 7.3 and above: SELECT a.attname, format_type(a.atttypid, a.atttypmod) FROM pg_catalog.pg_class c INNER JOIN p

[GENERAL] Run 2 versions of Postgresql on one machine?

2004-02-06 Thread Wei Wang
hi, I just took over a project done by somebody else of some C extension of Postgresql 7.1.3. And now I have to port it to pl/pgsql. The guy who developed it said he didn't get it running under 7.2 for some reason. And I suspect it might not run properly under 7.4.1. Since I only have one machine

Re: [GENERAL] newbie question... how do I get table structure?

2004-02-06 Thread Franco Bruno Borghesi
this should work (don't forget to replace !!!): SELECT A.attname, pg_catalog.format_type(a.atttypid, a.atttypmod) AS typeName FROM pg_class C, pg_attribute A, pg_type T WHERE C.relname ILIKE '' AND (C.oid=A.attrelid) AND (T.oid=A.atttypid) AND (A.attnum>0) AND (NOT A.attisd

Re: [GENERAL] newbie question... how do I get table structure?

2004-02-06 Thread Henrik Steffen
try something like this: select attname from pg_class, pg_attribute where relname='your_tablename' and attrelid=relfilenode; -- Mit freundlichem Gruß Henrik Steffen Geschäftsführer top concepts Internetmarketing GmbH Am Steinkamp 7 - D-21684 Stade - Germany -

Re: [GENERAL] Run 2 versions of Postgresql on one machine?

2004-02-06 Thread Peter Alberer
Hi wei, it is quite easy to have two different version of postgres running on one machine. You need 2 different directories for the data files and 2 different ports for the 2 postmasters to listen. -first you prepare the data directories with initdb, you can use the -D parameter to give the loca

[GENERAL] how can I select into an array?

2004-02-06 Thread Andy Kriger
Title: how can I select into an array? I would like to select strings from a table and return them as an array For example, select new_array(name) from my_tbl would return String[] { name1, name2, name3, etc } Is this possible with built-in SQL/psql functions? If not, how hard would it

Re: [GENERAL] Run 2 versions of Postgresql on one machine?

2004-02-06 Thread Richard Huxton
On Friday 06 February 2004 15:01, Wei Wang wrote: > hi, > > I just took over a project done by somebody else of some C extension of > Postgresql 7.1.3. And now I have to port it to pl/pgsql. The guy who > developed it said he didn't get it running under 7.2 for some reason. And I > suspect it might

Re: [GENERAL] how can I select into an array?

2004-02-06 Thread Pavel Stehule
hello, try: CREATE OR REPLACE FUNCTION aggregate_array(ANYARRAY,ANYELEMENT) RETURNS ANYARRAY AS ' SELECT CASE WHEN $1 IS NULL THEN ARRAY[$2] WHEN $2 IS NULL THEN $1 ELSE array_append($1,$2) END; ' LANGUAGE 'SQL'; CREATE AGGREGATE aggarray (BASETYPE = ANYELEMENT,

Re: [GENERAL] newbie question... how do I get table structure?

2004-02-06 Thread Richard Huxton
On Friday 06 February 2004 15:00, Franco Bruno Borghesi wrote: > > Does anyone know if the ansi sql standard defines any way to do this? > I've seen the DESCRIBE TABLE/INDEX/... or SHOW TABLE/INDEX/... commands > in other databases, but I don't really know if they are extensions or > not. There's

Re: [GENERAL] how can I select into an array?

2004-02-06 Thread Andy Kriger
Thank you for your response - I should have mention I'm using Postgres 7.2.x ANYARRAY does not appear to exist in that version Is there a workaround? -Original Message- From: Pavel Stehule [mailto:[EMAIL PROTECTED] Sent: Friday, February 06, 2004 10:49 AM To: Andy Kriger Cc: Pgsql-General

Re: [GENERAL] newbie question... how do I get table structure?

2004-02-06 Thread Tom Lane
Franco Bruno Borghesi <[EMAIL PROTECTED]> writes: > Does anyone know if the ansi sql standard defines any way to do this? > I've seen the DESCRIBE TABLE/INDEX/... or SHOW TABLE/INDEX/... commands > in other databases, but I don't really know if they are extensions or > not. They are extensions (an

[GENERAL] PL/Ruby

2004-02-06 Thread Anton Nikiforov
Dear sirs, Does someone made PL/Ruby working on 4.7.1? I tried alot of things. Manual install, port install and nothing happend. Please give me the idea how to fix the problem with plruby.c: In function `pl_tuple_put': plruby.c:498: error: too few arguments to function `tuplestore_begin_heap' plrub

Re: [GENERAL] how can I select into an array?

2004-02-06 Thread Pavel Stehule
if you can in plpgsql 7.2.x return array of known type, you can replace anyarray and anyelement like varchar[], varchar. But I don't know if it 7.2 supported. Pavel On Fri, 6 Feb 2004, Andy Kriger wrote: > Thank you for your response - I should have mention I'm using Postgres 7.2.x > ANYARRAY

[GENERAL] Getting table attributes

2004-02-06 Thread C G
Dear All, I'm trying to get a table containing all the user created tables, which contains the column name and their types. Basically, I want to be able to do "\d all_user_tables" - but I can't use the \d notation. I tried to combine the pg_ tables, but I couldn't get what I wanted (due to my

Re: [GENERAL] how can I select into an array?

2004-02-06 Thread Tom Lane
"Andy Kriger" <[EMAIL PROTECTED]> writes: > I would like to select strings from a table and return them as an array You can do that beginning in 7.4 with the ARRAY(sub-select) construct. regression=# select f1 from text_tbl; f1 --- doh! hi de ho neighbor (2 rows) regres

[GENERAL] retrieving parts of a resultset

2004-02-06 Thread Christoffer Gurell
I want to create a program which displays large tables and makes this possible over a slow connection. The problem is that when i do a PQexec the entire retultset is transfered. I would like to make pqsql process the query but only tranfer the the rows i ask for when i ask for them. This way i c

Re: [GENERAL] Casting 'record' to a composite type.

2004-02-06 Thread Joe Conway
Mark Gibson wrote: I'd like to do something like this: CREATE TYPE my_type AS (id integer, title text); SELECT * FROM fn_returning_setof_record( ... ) AS t my_type; or SELECT * FROM fn_returning_setof_record( ... )::my_type AS t; I've not been able to find anything like this in

Re: [GENERAL] Getting table attributes

2004-02-06 Thread Franco Bruno Borghesi
this query will list every table (with its attributes) in the "public" schema. You could alter the where clause to add more schemas (maybe using IN): SELECT N.nspname, C.relname, A.attname, pg_catalog.format_type(a.atttypid, a.atttypmod) AS typeName FROM pg_class C, pg_namespace N, pg_attribut

Re: [GENERAL] Getting table attributes

2004-02-06 Thread Steve Atkins
On Fri, Feb 06, 2004 at 04:53:47PM +, C G wrote: > > I'm trying to get a table containing all the user created tables, which > contains the column name and their types. Basically, I want to be able to > do "\d all_user_tables" - but I can't use the \d notation. > > I tried to combine the p

Re: [GENERAL] Run 2 versions of Postgresql on one machine?

2004-02-06 Thread Tom Lane
"Peter Alberer" <[EMAIL PROTECTED]> writes: > it is quite easy to have two different version of postgres running on > one machine. You need 2 different directories for the data files and 2 > different ports for the 2 postmasters to listen. > -first you prepare the data directories with initdb, yo

Re: [GENERAL] newbie question... how do I get table structure?

2004-02-06 Thread Franco Bruno Borghesi
that's great, I didn't know about the information schema... guess I never read the 'what's new' document On Fri, 2004-02-06 at 13:15, Tom Lane wrote: Franco Bruno Borghesi <[EMAIL PROTECTED]> writes: > Does anyone know if the ansi sql standard defines any way to do this? > I've seen the DESC

Re: [GENERAL] retrieving parts of a resultset

2004-02-06 Thread Franco Bruno Borghesi
I think you should use a cursor; you declare it, and then you fetch the rows as you need them. On Fri, 2004-02-06 at 14:04, Christoffer Gurell wrote: I want to create a program which displays large tables and makes this possible over a slow connection. The problem is that when i do a PQexec t

Re: [GENERAL] how can I select into an array?

2004-02-06 Thread Joe Conway
Pavel Stehule wrote: CREATE AGGREGATE aggarray (BASETYPE = ANYELEMENT, SFUNC = aggregate_array, STYPE = ANYARRAY); Or, from the docs, see: http://www.postgresql.org/docs/current/static/xaggr.html CREATE AGGREGATE array_accum ( sfunc = array_append, basetype = anyelement, stype = any

[GENERAL] Indexes and sorting

2004-02-06 Thread John Siracusa
Are indexes useful for speeding up ORDER BY clauses? Example: CREATE TABLE t ( a INT, b INT, c INT, d INT ); SELECT * FROM t WHERE a = 1 AND b = 2 AND c = 3 ORDER BY b; Let's say the table just has one index: CREATE INDEX b_idx ON t (b); In this cas

Re: [GENERAL] pgsql 7.4.1 copy - end-of-copy marker corrupt

2004-02-06 Thread Jenny Zhang
On Thu, 2004-02-05 at 22:52, Martijn van Oosterhout wrote: > On Fri, Feb 06, 2004 at 01:11:24AM -0500, Tom Lane wrote: > > Jenny Zhang <[EMAIL PROTECTED]> writes: > > > ERROR: end-of-copy marker corrupt > > > CONTEXT: COPY author, line 49: "49\aoD{\BABABABABARENG > > > \t5p.\19840426" > >

Re: [GENERAL] Run 2 versions of Postgresql on one machine?

2004-02-06 Thread Wei Wang
Thank you all for your kind help. I have set up 7.4.1 and it's up and running perfectly. One small question that might not belong in this mailing list: Since all the binary commands share the same name, e.g. initdb, createdb, psql, etc, and the default path is already the 7.1.3 version. How do I co

Re: [GENERAL] Indexes and sorting

2004-02-06 Thread Stephan Szabo
On Fri, 6 Feb 2004, John Siracusa wrote: > Are indexes useful for speeding up ORDER BY clauses? Example: > > CREATE TABLE t > ( > a INT, > b INT, > c INT, > d INT > ); > > SELECT * FROM t WHERE a = 1 AND b = 2 AND c = 3 ORDER BY b; > > Let's say the table j

Re: [GENERAL] how can I select into an array?

2004-02-06 Thread Joe Conway
Pavel Stehule wrote: if you can in plpgsql 7.2.x return array of known type, you can replace anyarray and anyelement like varchar[], varchar. But I don't know if it 7.2 supported. PL/pgSQL array support in anything earlier than 7.4 is pretty weak. I would strongly recommend upgrading to 7.4 if a

Re: [GENERAL] PL/Ruby

2004-02-06 Thread David Garamond
Anton Nikiforov wrote: Dear sirs, Does someone made PL/Ruby working on 4.7.1? I tried alot of things. Manual install, port install and nothing happend. Please give me the idea how to fix the problem with plruby.c: In function `pl_tuple_put': plruby.c:498: error: too few arguments to function `tuple

Re: [GENERAL] Indexes and sorting

2004-02-06 Thread David Garamond
John Siracusa wrote: SELECT * FROM t WHERE a = 1 AND b = 2 AND c = 3 ORDER BY b; Let's say the table just has one index: CREATE INDEX b_idx ON t (b); In this case, obviously the b_idx will be used and no sorting after the fact will be required. Now let's add an index: CREATE INDEX k

Re: [GENERAL] Run 2 versions of Postgresql on one machine?

2004-02-06 Thread Joshua D. Drake
Wei Wang wrote: > Thank you all for your kind help. I have set up 7.4.1 and it's up and > running perfectly. > One small question that might not belong in this mailing list: > Since all the binary commands share the same name, e.g. initdb, createdb, > psql, etc, and the > default path is already th