[GENERAL] Complete row is fetched ?

2010-04-15 Thread Satish Burnwal (sburnwal)
I have a ques - say I have a table that has 10 columns. But in a simple
select query from that table, I use just 3 columns. I want to know
whether even for fetching 3 columns, read happens for all the 10 columns
and out of that the required 3 columns are returned ? ie Does the
complete row with all the 10 columns are fetched even though I need just
3 columns ? OR only 3 columns are fetched ?

Satish

-- 
Sent via pgsql-general mailing list (pgsql-general@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-general


Re: [GENERAL] Complete row is fetched ?

2010-04-15 Thread John R Pierce

Satish Burnwal (sburnwal) wrote:

I have a ques - say I have a table that has 10 columns. But in a simple
select query from that table, I use just 3 columns. I want to know
whether even for fetching 3 columns, read happens for all the 10 columns
and out of that the required 3 columns are returned ? ie Does the
complete row with all the 10 columns are fetched even though I need just
3 columns ? OR only 3 columns are fetched ?
  


yes and no.

a row can consist of both a proper tuple in an 8K block, and toast data 
stored in toast tables.the whole block that the tuple is in will be 
read into the shared_buffers space, however, toast data thats not 
referenced will not be fetched.   toast is used for larger fields that 
won't fit in a single block.


for more info on toast, see 
http://www.postgresql.org/docs/current/static/storage-toast.html






--
Sent via pgsql-general mailing list (pgsql-general@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-general


Re: [GENERAL] Complete row is fetched ?

2010-04-15 Thread A. Kretschmer
In response to Satish Burnwal (sburnwal) :
> I have a ques - say I have a table that has 10 columns. But in a simple
> select query from that table, I use just 3 columns. I want to know
> whether even for fetching 3 columns, read happens for all the 10 columns
> and out of that the required 3 columns are returned ? ie Does the
> complete row with all the 10 columns are fetched even though I need just
> 3 columns ? OR only 3 columns are fetched ?

Depends, large columns (TEXT, BYTA) are TOASTed¹, that means, the content
of this columns stored in a other table. So it is always a good idea to
specify all rows you needed and don't use select *.

¹ http://www.postgresql.org/docs/8.4/interactive/storage-toast.html


Regards, Andreas
-- 
Andreas Kretschmer
Kontakt:  Heynitz: 035242/47150,   D1: 0160/7141639 (mehr: -> Header)
GnuPG: 0x31720C99, 1006 CCB4 A326 1D42 6431  2EB0 389D 1DC2 3172 0C99

-- 
Sent via pgsql-general mailing list (pgsql-general@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-general


[GENERAL] modification time & transaction synchronisation problem

2010-04-15 Thread Ostrovsky Eugene


Hi.
I need to export data from the database to external file. The difficulty is
that only data modified or added since previous export should be written to the
file.
I consider adding "modification_time" timestamp field to all the
tables that should be exported. Then I can set this field to now() within ON
UPDATE OR INSERT trigger.
During export I can select modified data with 'WHERE modification_time >
last_export_time' clause.

It seems to be the solution but...
What if the concurrent (and not yet committed) transaction modified some data
before export transaction begins? These modifications would not be visible to
export transaction and modified data would not be included to export file. Also
it won't be included to the next export because it's modification time is less
than current export start time (the new value of last_export_time).

Thus some data could be lost from export files sequence. And that is not good
at all.

I will appreciate any suggestions on how to solve this problem. I.e. how can I
(within the export transaction) select all the data that was updated since the
last export?

Thanks.
Eugene.



Re: [GENERAL] optimalisation with EXCEPT clause

2010-04-15 Thread Kincel, Martin
Thank you for the answer Grzegorz.

> if you have a primary key on the table, and you should, you might get better 
> performance using LEFT JOIN.

Well as far as I know, the result of such JOIN is a cartezian product, which is 
not exactly what I need. I need the same structure as table 'data' has. Or am I 
missing a trick how LEFT OUTER JOIN can be used instead of EXCEPT? :)

> EXCEPT will compare all columns, which might not be that fast, especially if 
> those are text. (hence why I always tell others to use int as key in a table, 
> but that's a different story). 

There is no good int to start using as a key in my 'data'. I would have to 
create one (out of some hash function, diggesting the whole row probably), but 
there is a strong possibility of adding colums into 'data' latter on, which 
would require recalculation of such 'hash' column over and over again for 
millions of rows. While not impossible, cerainly something I would like to 
avoid. 
Moreover, if one creates and maintains such hash column by hand and on his own, 
it is very likely, that he will forgot something, or even mess it up 
completely. However, if there is a tool (something like an index on all colums) 
available in the database itself, I would be eager to use it.

Thanks again,
Winco


> -- 
> GJ



* From: "Kincel, Martin" 
* To: 
* Subject: optimalisation with EXCEPT clause
* Date: Tue, 13 Apr 2010 17:01:18 +0200
* Message-id: 

Hello,


everyday I collect a couple of thousands rows of unique data from our
systems and I INSERT them into the table. Since I need no duplicate
data, I use EXCEPT clause when INSERTing, like this:

===
INSERT INTO data SELECT * FROM new_collected_data() EXCEPT SELECT * FROM
data;
===

It works exactly as I need, but there is a small issue I am thinking
about how to improve. Yes it's performance, what else? :)

Since I am INSERTing new_collected_data() in 1-rows chunks into a
table already containing millions of rows, it takes a few minutes
(literally), which is something I understand and accept. 
However, I am wondering whether there is any way how to improve the
performance, either via indices, or ALTERing TABLE with UNIQUE
constraint or something else I might have completely forgot about.

Does anyone have any recommended approach how to speed up queries
containing EXCEPT clause? 


Thanks a lot,
Winco


-- 
Sent via pgsql-general mailing list (pgsql-general@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-general


Re: [GENERAL] readline library not found

2010-04-15 Thread Greg Smith

zhong ming wu wrote:

After explicitly specfying these paths with --with-libs and
with-includes postgres configure is still choking
on readline.
  


Doing this is painful, but one hack you can try is pointing:

export LD_LIBRARY_PATH=/home/me/local/lib

I've used that combined with setting --with-libs and --with-includes 
before to get a PostgreSQL build with libedit working in a non-root 
account, and that library is similar to readline.


If that doesn't work you might have to adjust LDFLAGS instead, and 
that's no fun at all.  This is not a simple thing to pull off.


--
Greg Smith  2ndQuadrant US  Baltimore, MD
PostgreSQL Training, Services and Support
g...@2ndquadrant.com   www.2ndQuadrant.us


--
Sent via pgsql-general mailing list (pgsql-general@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-general


Re: [GENERAL] [SOLVED] Error in Trigger function. How to correct?

2010-04-15 Thread Dave Page
On Thu, Apr 15, 2010 at 4:10 AM, Bruce Momjian  wrote:
>> > PPAS 8.1 = PostgreSQL 8.1
>> > PPAS 8.3x = PostgreSQL 8.2 base (plus HOT and wal_writer)
>> > PPAS 8.4 = PostgreSQL 8.4 (plus compatibility)
>> > PPAS 9 [is planned to] = PostgreSQL 9.0
>>
>> So there was no actual 8.3 base release of PPAS?
>
> No, and I assume the version numbers will all match for future releases.

That's the plan.

-- 
Dave Page
EnterpriseDB UK: http://www.enterprisedb.com
The Enterprise Postgres Company

-- 
Sent via pgsql-general mailing list (pgsql-general@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-general


[GENERAL] How to get whether user has ALL permissions on table?

2010-04-15 Thread dipti shah
Hi, I have granted ALL permissions on 'techtable' to 'user1'.

 techdb=# select pc.relname, pc.relacl from pg_class pc, pg_namespace pn
where pc.relnamespace=pn.oid and pn.nspname='techdb' and
pc.relname='techtable';
 relname   |  relacl
---+---
 techtable | {postgres=arwdDxt/postgres,=ar/postgres,user1=arwdDxt/postgres}
(1 row)

Could anyone please tell me if there is any function or command in
PostGreSql which returns True if given user has ALL permissions on given
table? Is there any alternative way to do this. I have table and user names
and want to know whether user has ALL permissions on table or not.

Thanks,
Ditpi


Re: [GENERAL] How to get whether user has ALL permissions on table?

2010-04-15 Thread A. Kretschmer
In response to dipti shah :
> 
> Hi, I have granted ALL permissions on 'techtable' to 'user1'.
>  
>  techdb=# select pc.relname, pc.relacl from pg_class pc, pg_namespace pn where
> pc.relnamespace=pn.oid and pn.nspname='techdb' and pc.relname='techtable';
>  relname   |  relacl
> ---+---
>  techtable | {postgres=arwdDxt/postgres,=ar/postgres,user1=arwdDxt/postgres}
> (1 row)
>  
> Could anyone please tell me if there is any function or command in PostGreSql
> which returns True if given user has ALL permissions on given table? Is there

Sure, read
http://www.postgresql.org/docs/8.4/interactive/functions-info.html


Andreas
-- 
Andreas Kretschmer
Kontakt:  Heynitz: 035242/47150,   D1: 0160/7141639 (mehr: -> Header)
GnuPG: 0x31720C99, 1006 CCB4 A326 1D42 6431  2EB0 389D 1DC2 3172 0C99

-- 
Sent via pgsql-general mailing list (pgsql-general@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-general


Re: [GENERAL] How to get whether user has ALL permissions on table?

2010-04-15 Thread dipti shah
Thanks Kretschmer but I have seen those function. The below query returns
error but you could see that 'user1' has ALL permissions on table
'techtable'.

techdb=# SELECT has_table_privilege('user1', 'techtable', 'ALL');
ERROR:  unrecognized privilege type: "ALL"

techdb=# select pc.relname, pc.relacl from pg_class pc, pg_namespace pn
where pc.relnamespace=pn.oid and pn.nspname='techdb' and
pc.relname='techtable';
 relname   |  relacl
---+---
 techtable | {postgres=arwdDxt/postgres,=ar/postgres,user1=arwdDxt/postgres}
(1 row)

Do I have to run this command as below which includes all permissions
explicitly? Did I miss anything?

techdb=# SELECT has_table_privilege('user1', 'techtable', 'SELECT, INSERT,
UPDATE, DELETE, TRUNCATE, REFERENCES, TRIGGER');
 has_table_privilege
-
 t
(1 row)
Thanks,
Dipti

On Thu, Apr 15, 2010 at 1:27 PM, A. Kretschmer <
andreas.kretsch...@schollglas.com> wrote:

> In response to dipti shah :
> >
> > Hi, I have granted ALL permissions on 'techtable' to 'user1'.
> >
> >  techdb=# select pc.relname, pc.relacl from pg_class pc, pg_namespace pn
> where
> > pc.relnamespace=pn.oid and pn.nspname='techdb' and
> pc.relname='techtable';
> >  relname   |  relacl
> >
> ---+---
> >  techtable |
> {postgres=arwdDxt/postgres,=ar/postgres,user1=arwdDxt/postgres}
> > (1 row)
> >
> > Could anyone please tell me if there is any function or command in
> PostGreSql
> > which returns True if given user has ALL permissions on given table? Is
> there
>
> Sure, read
> http://www.postgresql.org/docs/8.4/interactive/functions-info.html
>
>
> Andreas
> --
> Andreas Kretschmer
> Kontakt:  Heynitz: 035242/47150,   D1: 0160/7141639 (mehr: -> Header)
> GnuPG: 0x31720C99, 1006 CCB4 A326 1D42 6431  2EB0 389D 1DC2 3172 0C99
>
> --
> Sent via pgsql-general mailing list (pgsql-general@postgresql.org)
> To make changes to your subscription:
> http://www.postgresql.org/mailpref/pgsql-general
>


Re: [GENERAL] Inconsistent SQL errors

2010-04-15 Thread Boszormenyi Zoltan
gvim írta:
> I'm running PostgreSQL 8.4.3 on OS X Snow Leopard via MacPorts and I'm
> getting strange inconsistent errors such as:
>
> dbuser-# select * from log_form;

The error is here above. You had a "-#" prompt, saying
that you already started another statement in a previous line
but you haven't finished it with a ";"

> ERROR:  syntax error at or near "select"
> LINE 2: select * from log_form;
> ^

Also, the "LINE 2" message tells that you had something in
the first line which was not shown by you.

>
> Then later the same query will run fine, as it should.

I bet that you had a "=#" prompt when it ran fine, not "-#".

Best regards,
Zoltán Böszörményi


-- 
Bible has answers for everything. Proof:
"But let your communication be, Yea, yea; Nay, nay: for whatsoever is more
than these cometh of evil." (Matthew 5:37) - basics of digital technology.
"May your kingdom come" - superficial description of plate tectonics

--
Zoltán Böszörményi
Cybertec Schönig & Schönig GmbH
http://www.postgresql.at/


-- 
Sent via pgsql-general mailing list (pgsql-general@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-general


Re: [GENERAL] How to get whether user has ALL permissions on table?

2010-04-15 Thread A. Kretschmer
In response to dipti shah :
> Thanks Kretschmer but I have seen those function. The below query returns 
> error
> but you could see that 'user1' has ALL permissions on table 'techtable'.
>  
> techdb=# SELECT has_table_privilege('user1', 'techtable', 'ALL');
> ERROR:  unrecognized privilege type: "ALL"
>  
> Do I have to run this command as below which includes all permissions
> explicitly? Did I miss anything?

Right, you have to name all privileges.

The desired access privilege type is specified by a text string, which
must evaluate to one of the values SELECT, INSERT, UPDATE, DELETE,
TRUNCATE, REFERENCES, or TRIGGER.

Andreas
-- 
Andreas Kretschmer
Kontakt:  Heynitz: 035242/47150,   D1: 0160/7141639 (mehr: -> Header)
GnuPG: 0x31720C99, 1006 CCB4 A326 1D42 6431  2EB0 389D 1DC2 3172 0C99

-- 
Sent via pgsql-general mailing list (pgsql-general@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-general


Re: [GENERAL] How to get whether user has ALL permissions on table?

2010-04-15 Thread dipti shah
Okay. Thanks.

Dipti.

On Thu, Apr 15, 2010 at 3:20 PM, A. Kretschmer <
andreas.kretsch...@schollglas.com> wrote:

> In response to dipti shah :
> > Thanks Kretschmer but I have seen those function. The below query returns
> error
> > but you could see that 'user1' has ALL permissions on table 'techtable'.
> >
> > techdb=# SELECT has_table_privilege('user1', 'techtable', 'ALL');
> > ERROR:  unrecognized privilege type: "ALL"
> >
> > Do I have to run this command as below which includes all permissions
> > explicitly? Did I miss anything?
>
> Right, you have to name all privileges.
>
> The desired access privilege type is specified by a text string, which
> must evaluate to one of the values SELECT, INSERT, UPDATE, DELETE,
> TRUNCATE, REFERENCES, or TRIGGER.
>
> Andreas
> --
> Andreas Kretschmer
> Kontakt:  Heynitz: 035242/47150,   D1: 0160/7141639 (mehr: -> Header)
> GnuPG: 0x31720C99, 1006 CCB4 A326 1D42 6431  2EB0 389D 1DC2 3172 0C99
>
> --
> Sent via pgsql-general mailing list (pgsql-general@postgresql.org)
> To make changes to your subscription:
> http://www.postgresql.org/mailpref/pgsql-general
>


Re: [GENERAL] Query is stuck

2010-04-15 Thread Satish Burnwal (sburnwal)
Great!! Your help is very valuable!!

-Original Message-
From: Justin Graf [mailto:jus...@magwerks.com] 
Sent: Wednesday, April 14, 2010 7:35 PM
To: Bill Moran
Cc: Satish Burnwal (sburnwal); pgsql-general@postgresql.org
Subject: Re: [GENERAL] Query is stuck

I suggest writting something like this.

select report_id, dm_ip, dm_mac, dm_user,
dm_os, report_time, sys_name,
sys_user, sys_user_domain, ss_key,
login_time, role_id, new_vlan_id
   from repcopy as a
(select max(report_time) as rtime,  
dm_user, dm_ip
from repcopy
group by dm_user, dm_ip
where ss_key != '') as materialized
   where report_time = materialized.rtime
and materialized.dm_user = a.dm_user
and materialized.dm__ip = a_ip
and report_status = 0
and dm_user = 'u3';




All legitimate Magwerks Corporation quotations are sent in a .PDF file 
attachment with a unique ID number generated by our proprietary quotation 
system. Quotations received via any other form of communication will not be 
honored.

CONFIDENTIALITY NOTICE: This e-mail, including attachments, may contain legally 
privileged, confidential or other information proprietary to Magwerks 
Corporation and is intended solely for the use of the individual to whom it 
addresses. If the reader of this e-mail is not the intended recipient or 
authorized agent, the reader is hereby notified that any unauthorized viewing, 
dissemination, distribution or copying of this e-mail is strictly prohibited. 
If you have received this e-mail in error, please notify the sender by replying 
to this message and destroy all occurrences of this e-mail immediately.
Thank you.


-- 
Sent via pgsql-general mailing list (pgsql-general@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-general


Re: [GENERAL] How to insert Ecoded values into postrgresql

2010-04-15 Thread Merlin Moncure
On Thu, Apr 15, 2010 at 12:29 AM, Tom Lane  wrote:
> Bruce Momjian  writes:
>> Merlin Moncure wrote:
>>> aside: anyone know if postgres properly handles csv according to rfc4180?
>
>> Wow, I had no idea there was an RFC for CSV.
>
> Me either.  I'd bet the percentage of "CSV"-using programs that actually
> conform to the RFC is very small anyway; so while it might be smart to
> make sure that what we *emit* follows the RFC, it's probably useless as
> a guide to what we need to *accept*.

Well, we would have to accept it if we emit it, but you're right.
Kinda like how with base64 encoding there are two competing
incompatible (both RFC) standards of doing it.  We accept both but
only emit one.  I'll look at how we handle csv.  I've always been
curious about that actually.   If a standard exists and it isn't
completely insane maybe we should document and encourage it.

merlin

-- 
Sent via pgsql-general mailing list (pgsql-general@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-general


Re: [GENERAL] VACUUM process running for a long time

2010-04-15 Thread Jan Krcmar
hi

2010/4/14 Adrian von Bidder :
>  -> vacuum can run concurrently to other stuff, so it's not necessary to
> wait before it finishes.
>  -> in most cases, autovacuum should do the Right Thing(tm) atomatically, so
> you should not need to call vacuum manually.
>
> This is with a recent pg version.  Do you use a (very) old version with
> autovacuum?  Is your db server running hot and can't really keep up with
> inserting data as soon as vacuum starts running?
>
> Note that the pg documentation contains lots of useful information about
> tuning autovacuum.  Without knowing how your table looks and how your data
> entry happens (in peaks?  or always at about the same rate?) we probably
> can't help you much more.
>
> cheers
> -- vbi
>

i'm doing one big insert per day, and one big delete per day

anyway, i've found, this article
http://www.postgresql.org/docs/8.4/interactive/ddl-partitioning.html

could the partitioning be helpfull for this situation?
i guess, that it does the same as the others advised. inserts are
stored into specific table and obsolete table is deleted and allocated
space is freed. am i right?

f.

-- 
Sent via pgsql-general mailing list (pgsql-general@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-general


Re: [GENERAL] When is an explicit cast necessary?

2010-04-15 Thread Alvaro Herrera
Alan Millington wrote:

> If you think that smallints are more bother than they are worth, perhaps you 
> should remove support for smallints completely. Then people would know where 
> they stood. (Or you could make smallint a synonym for int.)

smallint can be used usefully -- you just need to know how and when.

-- 
Alvaro Herrerahttp://www.CommandPrompt.com/
PostgreSQL Replication, Consulting, Custom Development, 24x7 support

-- 
Sent via pgsql-general mailing list (pgsql-general@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-general


Re: [GENERAL] pl/java status

2010-04-15 Thread Joshua D. Drake
On Wed, 2010-04-14 at 22:53 -0400, Bruce Momjian wrote:
> Damian Carey wrote:
> > On Thu, Apr 15, 2010 at 6:18 AM, John R Pierce  wrote:
> > > Joshua D. Drake wrote:
> > >>
> > >> Mostly, I think you will find that the back end developers aren't fond
> > >> of Java and thus, it doesn't get much love.
> > >>
> > >> There is a reason that plPerl is king in this community (and I don't
> > >> even like Perl).
> > >>
> > >
> > 
> > Java2perl anyone ?
> > http://search.cpan.org/~philcrow/Java-Javap-0.04/bin/java2perl6
> > (99% joking)
> > 
> > And if you think positively a 14hour TZ difference is really only 10
> > if you go the other way.
> 
> Is PL/J still being developed?  I can't find it myself, but was curious.

Not as far as I know.

> 
> -- 
>   Bruce Momjian  http://momjian.us
>   EnterpriseDB http://enterprisedb.com
> 


-- 
PostgreSQL.org Major Contributor
Command Prompt, Inc: http://www.commandprompt.com/ - 503.667.4564
Consulting, Training, Support, Custom Development, Engineering



-- 
Sent via pgsql-general mailing list (pgsql-general@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-general


[GENERAL] solaris tarballs and pl/java

2010-04-15 Thread John R Pierce
The tarball for 64bit 8.4.3 on Solaris Sparc is missing some ./pgxs/... 
files I seem to need to build pl/java.  they exist in the 32bit version 
but at least of them, Makefile.global, appears quite build specific.



$ ls -l 8.4-community/lib/pgxs/src/
total 91
-r--r--r--   1 postgres postgres   19618 Mar 12 07:56 Makefile.global
-r--r--r--   1 postgres postgres 434 Mar 12 07:56 Makefile.port
-r--r--r--   1 postgres postgres   15738 Mar 12 07:56 Makefile.shlib
drwxr-xr-x   2 postgres postgres   3 Mar 12 07:56 makefiles
-r--r--r--   1 postgres postgres4734 Mar 12 07:56 nls-global.mk
drwxr-xr-x   3 postgres postgres   3 Mar 12 04:59 test

$ ls -l 8.4-community/lib/64/pgxs/src/
total 6
drwxr-xr-x   2 postgres postgres   3 Mar 12 08:11 makefiles
drwxr-xr-x   3 postgres postgres   3 Mar 12 04:59 test

now, I suppose I could try to hack up the 32bit one and copy it to the 
64bit dir myself, but there's a lot of complex stuff in that file and 
way too much room for error for my tastes.




--
Sent via pgsql-general mailing list (pgsql-general@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-general


Re: [GENERAL] solaris tarballs and pl/java

2010-04-15 Thread Greg Smith

John R Pierce wrote:
The tarball for 64bit 8.4.3 on Solaris Sparc is missing some 
./pgxs/... files I seem to need to build pl/java.  they exist in the 
32bit version but at least of them, Makefile.global, appears quite 
build specific.


Yeah, it seemed pretty obvious from the error you were running into in 
your last message that you'll need to do your own PostgreSQL build here 
first, then add pl/java on top of that.  Binary packages aren't 
necessarily good at giving you everything needed to build your 
extensions, and even if it did build I'd be suspicious of it until it 
passed testing.


You can see more about how the OpenSolaris packages are built at 
http://src.opensolaris.org/source/xref/sfw/usr/src/cmd/postgres/ ; 
Makefile.sfw in particular might have clues as to what's going wrong 
here.  There are separate code paths in several places there for 32 vs. 
64 bit builds, and you seem to have run into a divergence between the two.


As for mailing lists, you can try 
http://lists.pgfoundry.org/pipermail/pljava-dev/ for things specific to 
building it.


--
Greg Smith  2ndQuadrant US  Baltimore, MD
PostgreSQL Training, Services and Support
g...@2ndquadrant.com   www.2ndQuadrant.us


--
Sent via pgsql-general mailing list (pgsql-general@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-general


[GENERAL] Byte Escape Syntax

2010-04-15 Thread Howard Yeh
Hi,

Is Postgres's byte escape syntax something that could be set by the client?

I am running into a strange problem when I access postgres try two
different Ruby ORM's. I am guessing that one of them is doing
something funny to the client connections.

Looking at the Ruby C-driver, it's calling PQescapeBytea rather then
PQescapeByteaConn. And tracing PQescapeBytea, sometimes it escapes '\'
as '\\', as describe in the manual, sometimes it doesn't do that
escape. But it always escape the single quote character ' . All the
connections are using UTF-8 encoding.

I wrote my own byte escaping function in Ruby, which does escaping
according to the 8.4 manual, but again it works for some connections,
but not others.

Howard

-- 
Sent via pgsql-general mailing list (pgsql-general@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-general


Re: [GENERAL] Byte Escape Syntax

2010-04-15 Thread Tom Lane
Howard Yeh  writes:
> Is Postgres's byte escape syntax something that could be set by the client?

Well, indirectly --- it's affected by the standard_conforming_strings
setting.

> I am running into a strange problem when I access postgres try two
> different Ruby ORM's. I am guessing that one of them is doing
> something funny to the client connections.

> Looking at the Ruby C-driver, it's calling PQescapeBytea rather then
> PQescapeByteaConn. And tracing PQescapeBytea, sometimes it escapes '\'
> as '\\', as describe in the manual, sometimes it doesn't do that
> escape. But it always escape the single quote character ' . All the
> connections are using UTF-8 encoding.

It would be a real good idea to fix that driver to use PQescapeByteaConn.
There are no supported releases of Postgres that don't have that
function.

regards, tom lane

-- 
Sent via pgsql-general mailing list (pgsql-general@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-general


Re: [GENERAL] solaris tarballs and pl/java

2010-04-15 Thread John R Pierce

Greg Smith wrote:

John R Pierce wrote:
The tarball for 64bit 8.4.3 on Solaris Sparc is missing some 
./pgxs/... files I seem to need to build pl/java.  they exist in the 
32bit version but at least of them, Makefile.global, appears quite 
build specific.


Yeah, it seemed pretty obvious from the error you were running into in 
your last message that you'll need to do your own PostgreSQL build 
here first, then add pl/java on top of that.  Binary packages aren't 
necessarily good at giving you everything needed to build your 
extensions, and even if it did build I'd be suspicious of it until it 
passed testing.


You can see more about how the OpenSolaris packages are built at 
http://src.opensolaris.org/source/xref/sfw/usr/src/cmd/postgres/ ; 
Makefile.sfw in particular might have clues as to what's going wrong 
here.  There are separate code paths in several places there for 32 
vs. 64 bit builds, and you seem to have run into a divergence between 
the two.


As for mailing lists, you can try 
http://lists.pgfoundry.org/pipermail/pljava-dev/ for things specific 
to building it.




having not gone down the path of building my own language extensions 
before, how portable are they between postgres builds?What I build 
needs to eventually be installable on a 8.4-community 64bit install as 
they want to add pl/java support to a running production database.   I 
can specify they use the same JDK etc.


Last night, I started trying to piece together the environment for 
./configure for postgres based on what pg_config gives me, but it 
aborted pretty early with missing stuffs...  by then it was 1am and I 
was fried so I am taking a fresh look this morning...   k, I'm already 
farther along and moving forward... (had to add /usr/sbin to the path to 
find dtrace, now I'm sorting out readline vs libedit...)... and stopped 
on a 'cannot compute size(off_t)' but I'm sure I'll figure that out...






--
Sent via pgsql-general mailing list (pgsql-general@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-general


Re: [GENERAL] Showing debug messages in my C function

2010-04-15 Thread Jorge Arevalo
On Tue, Apr 13, 2010 at 10:04 PM, Tom Lane  wrote:
> Jorge Arevalo  writes:
>> I'm sorry, because this may be a simple question: I'm programming a C
>> function that returns a set (PostgreSQL 8.4). The function crash, and
>> I'm trying to
>> debug it. I've read:
>
>> http://www.postgresql.org/docs/8.4/interactive/xfunc-c.html
>> http://www.postgresql.org/docs/8.4/interactive/error-message-reporting.html
>> http://www.postgresql.org/docs/current/static/runtime-config-logging.html
>
>> but I can't see any of my log messages.
>
> Seems likely to me that the function is crashing before it gets to any
> of the elog calls; which would most likely be a problem in linking or in
> declaring the function.  Did you remember to use the
> PG_FUNCTION_INFO_V1() macro?  Try writing a trivial function that only
> does an elog and see what it takes to get that to work.
>
>                        regards, tom lane
>

Yes, I put the PG_FUNCTION_INFO_V1(myFunction) macro.

I solved some small bugs, and I checked the function is called, but I
get a segmentation fault when try to call SRF_IS_FIRSTCALL. I think
this has no much sense, and the problem keeps hidden for another
reason.

I'm going to continue debugging, but if helps, I provide the
interesting part of log file.

Thanks!

Best regards,
Jorge


postgresql-2010-04-15_195917.log
Description: Binary data

-- 
Sent via pgsql-general mailing list (pgsql-general@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-general


Re: [GENERAL] solaris tarballs and pl/java

2010-04-15 Thread John R Pierce

John R Pierce wrote:
Last night, I started trying to piece together the environment for 
./configure for postgres based on what pg_config gives me, but it 
aborted pretty early with missing stuffs...  by then it was 1am and I 
was fried so I am taking a fresh look this morning...   k, I'm already 
farther along and moving forward... (had to add /usr/sbin to the path 
to find dtrace, now I'm sorting out readline vs libedit...)... and 
stopped on a 'cannot compute size(off_t)' but I'm sure I'll figure 
that out...


so, i'm stuck here.

getting this error from thte ./configure:

   configure:16808: error: cannot compute sizeof (off_t)

I'm trying to mimic this pg_config...

$ pg_config
BINDIR = /usr/postgres/8.4-community/bin/64
DOCDIR = /usr/postgres/8.4-community/share/doc
HTMLDIR = /usr/postgres/8.4-community/share/doc
INCLUDEDIR = /usr/postgres/8.4-community/include
PKGINCLUDEDIR = /usr/postgres/8.4-community/include
INCLUDEDIR-SERVER = /usr/postgres/8.4-community/include/server
LIBDIR = /usr/postgres/8.4-community/lib/64
PKGLIBDIR = /usr/postgres/8.4-community/lib/64
LOCALEDIR = /usr/postgres/8.4-community/share/locale
MANDIR = /usr/postgres/8.4-community/man
SHAREDIR = /usr/postgres/8.4-community/share
SYSCONFDIR = /usr/postgres/8.4-community/etc
PGXS = /usr/postgres/8.4-community/lib/64/pgxs/src/makefiles/pgxs.mk
CONFIGURE = '--prefix=/usr/postgres/8.4-community' 
'--exec-prefix=/usr/postgres/8.4-community' 
'--bindir=/usr/postgres/8.4-community/bin/64' 
'--libexecdir=/usr/postgres/8.4-community/bin/64' 
'--sbindir=/usr/postgres/8.4-community/bin/64' 
'--datadir=/usr/postgres/8.4-community/share' 
'--sysconfdir=/usr/postgres/8.4-community/etc' 
'--mandir=/usr/postgres/8.4-community/man' 
'--libdir=/usr/postgres/8.4-community/lib/64' 
'--includedir=/usr/postgres/8.4-community/include' 
'--sharedstatedir=/var/postgres/8.4-community' 
'--localstatedir=/var/postgres/8.4-community' 
'--with-system-tzdata=/usr/share/lib/zoneinfo' '--enable-nls' 
'--with-docdir=/usr/postgres/8.4-community/doc' '--with-python' 
'--with-pam' '--with-openssl' '--with-libedit-preferred' '--with-libxml' 
'--with-libxslt' '--with-gssapi' '--enable-thread-safety' 
'--enable-dtrace' 'DTRACEFLAGS=-64' 
'--with-includes=/zstore/pgsql/pg84b1/proto/root_sparc/usr/include:/zstore/pgsql/pg84b1/proto/root_sparc/usr/sfw/include:/usr/sfw/include' 
'--with-tclconfig=/usr/sfw/lib' 
'--with-libs=/zstore/pgsql/pg84b1/proto/root_sparc/usr/lib/64:/zstore/pgsql/pg84b1/proto/root_sparc/usr/sfw/lib/64:/usr/lib/64:/usr/sfw/lib/64' 
'CC=/opt/SUNWspro/SS11/bin/cc' 'CFLAGS=-xO3 -xarch=v9 -dalign   
-Wc,-Qiselect-regsym=0 -xspace -W0,-Lt -W2,-Rcond_elim -Xa  -xildoff ' 
'LDFLAGS=-L/zstore/pgsql/pg84b1/proto/root_sparc/usr/lib/64 
-L/zstore/pgsql/pg84b1/proto/root_sparc/usr/sfw/lib/64 
-L/usr/sfw/lib/64' 
'CPPFLAGS=-I/zstore/pgsql/pg84b1/proto/root_sparc/usr/include 
-I/zstore/pgsql/pg84b1/proto/root_sparc/usr/sfw/include -I/usr/sfw/include'

CC = /opt/SUNWspro/SS11/bin/cc
CPPFLAGS = -I/zstore/pgsql/pg84b1/proto/root_sparc/usr/include 
-I/zstore/pgsql/pg84b1/proto/root_sparc/usr/sfw/include 
-I/usr/sfw/include -I/usr/include/libxml2 
-I/zstore/pgsql/pg84b1/proto/root_sparc/usr/include 
-I/zstore/pgsql/pg84b1/proto/root_sparc/usr/sfw/include -I/usr/sfw/include
CFLAGS = -xO3 -xarch=v9 -dalign   -Wc,-Qiselect-regsym=0 -xspace -W0,-Lt 
-W2,-Rcond_elim -Xa  -xildoff

CFLAGS_SL = -KPIC
LDFLAGS = -L/zstore/pgsql/pg84b1/proto/root_sparc/usr/lib/64 
-L/zstore/pgsql/pg84b1/proto/root_sparc/usr/sfw/lib/64 -L/usr/sfw/lib/64 
-L/usr/lib -L/zstore/pgsql/pg84b1/proto/root_sparc/usr/lib/64 
-L/usr/lib/64 -L/usr/sfw/lib/64 -Wl,-R'/usr/postgres/8.4-community/lib/64'

LDFLAGS_SL =
LIBS = -lpgport -lxslt -lxml2 -lpam -lssl -lcrypto -lgss -lz -ledit 
-ltermcap -lnsl -lrt -lsocket -lm

VERSION = PostgreSQL 8.4.3


and I'm using this configure script...

$ more configit
export JAVA_HOME=/usr/jdk/jdk1.5.0_23
export 
PATH=/usr/jdk/jdk1.5.0_23/bin/sparcv9:/opt/SUNWspro/bin:/usr/postgres/8.4-community/bin/64:/usr/bin:/usr/sbin:/opt/sfw/bin:/usr/sfw/bin:/usr/local/bin:/usr/ccs/bin


export CC=/opt/SUNWspro/bin/cc
export CFLAGS='-xO3 -xarch=v9 -dalign -Wc,-Qiselect-regsym=0 -xspace 
-W0,-Lt -W2,-Rcond_elim -Xa  -xildoff'

export CFLAGS_SL=-KPIC
export LDFLAGS="-L/usr/lib/64 -L/usr/sfw/lib/64 -L/usr/sfw/lib/64 
-L/usr/lib -L/usr/lib/64 -L/usr/lib/64 -L/usr/sfw/lib/64 
-Wl,-R'/usr/postgres/8.4-community/lib/64'"
export CPPFLAGS='-I/usr/include -I/usr/sfw/include -I/usr/sfw/include 
-I/usr/include/libxml2 -I/usr/include -I/usr/sfw/include -I/usr/sfw/include'


export CONFSTUFF='--prefix=/usr/postgres/8.4-community 
--exec-prefix=/usr/postgres/8.4-community --bindir=/usr/postgres
/8.4-community/bin/64 --libexecdir=/usr/postgres/8.4-community/bin/64 
--sbindir=/usr/postgres/8.4-community/bin/64 --da
tadir=/usr/postgres/8.4-community/share 
--sysconfdir=/usr/postgres/8.4-community/etc 
--mandir=/usr/postgres/8.4-communi
ty/man --libdir=/usr/postgres/8.4-community/lib/64 
--includedir=/usr/

Re: [GENERAL] solaris tarballs and pl/java

2010-04-15 Thread Tom Lane
John R Pierce  writes:
> getting this error from thte ./configure:
> configure:16808: error: cannot compute sizeof (off_t)

That's pretty weird.  Look into the config.log output to see why that
particular test program is failing.  (The relevant bit will probably be
a few hundred lines before the end of config.log --- the last section
of the log is a dump of the current values of all of configure's
variables, and there are a lot...)

BTW, which 8.4.x PG release is this exactly?

regards, tom lane

-- 
Sent via pgsql-general mailing list (pgsql-general@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-general


Re: [GENERAL] solaris tarballs and pl/java

2010-04-15 Thread Ozz Nixon

Would this syntax work in PostgreSQL?

|INSERT INTO MyTable (FirstCol, SecondCol)
VALUES ('First',1),
|| ('||Second||',2),|
| ('||Third||',3),|
| ('||Fourth||',4),|
| ('||Fifth||',5)||
|
Inserting 5 rows in a single Insert? (I am trying to implement this 
solution across many different backends) works on SQL Server 2008, need 
to make sure it will work on many others.


[GENERAL] General Question about database -- redirection

2010-04-15 Thread akp geek
dear all -

 I am not supposed to ask this. But, the question is I have 2
databases DB_1 and DB_2. I have a script that loads few tables in DB_1. The
2 databases are identical. In case , if database DB_1 is dropped, Is there
any  command that I can issue to use the DB_2?


Regards


Inserting multiple values, was Re: [GENERAL] solaris tarballs and pl/java

2010-04-15 Thread Raymond O'Donnell
On 15/04/2010 20:44, Ozz Nixon wrote:
> Would this syntax work in PostgreSQL?
> 
> |INSERT INTO MyTable (FirstCol, SecondCol)
> VALUES ('First',1),
> || ('||Second||',2),|
> | ('||Third||',3),|
> | ('||Fourth||',4),|
> | ('||Fifth||',5)||
> |
> Inserting 5 rows in a single Insert? (I am trying to implement this
> solution across many different backends) works on SQL Server 2008, need
> to make sure it will work on many others.

http://www.postgresql.org/docs/8.4/static/sql-insert.html


-- 
Raymond O'Donnell :: Galway :: Ireland
r...@iol.ie

-- 
Sent via pgsql-general mailing list (pgsql-general@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-general


Re: [GENERAL] solaris tarballs and pl/java

2010-04-15 Thread Alvaro Herrera
Ozz Nixon escribió:
> Would this syntax work in PostgreSQL?
> 
> |INSERT INTO MyTable (FirstCol, SecondCol)
> VALUES ('First',1),
> || ('||Second||',2),|
> | ('||Third||',3),|
> | ('||Fourth||',4),|
> | ('||Fifth||',5)||

Yes, it works (without all those funny || though)

-- 
Alvaro Herrerahttp://www.CommandPrompt.com/
The PostgreSQL Company - Command Prompt, Inc.

-- 
Sent via pgsql-general mailing list (pgsql-general@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-general


Re: [GENERAL] solaris tarballs and pl/java

2010-04-15 Thread John R Pierce

Tom Lane wrote:

John R Pierce  writes:
  

getting this error from thte ./configure:
configure:16808: error: cannot compute sizeof (off_t)



That's pretty weird.  Look into the config.log output to see why that
particular test program is failing.  (The relevant bit will probably be
a few hundred lines before the end of config.log --- the last section
of the log is a dump of the current values of all of configure's
variables, and there are a lot...)

BTW, which 8.4.x PG release is this exactly?
  



its 8.4.3 ...   I'm jumping sideways and trying a different attack on my 
actual problem, which is building pl/java HEAD for 64bit solaris sparc 
w/ 8.4.3 and JDK 1.5.0_23...   rather than building the entire postgres 
tree, I replicated the couple missing files from the 32bit version and 
am 'fixing' their paths.


I'm hitting another problem with that,  but I think I'll take it to the 
pl/java list.




--
Sent via pgsql-general mailing list (pgsql-general@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-general


Re: [GENERAL] solaris tarballs and pl/java

2010-04-15 Thread Alvaro Herrera
John R Pierce wrote:
> Tom Lane wrote:
> >John R Pierce  writes:
> >>getting this error from thte ./configure:
> >>configure:16808: error: cannot compute sizeof (off_t)
> >
> >That's pretty weird.  Look into the config.log output to see why that
> >particular test program is failing.  (The relevant bit will probably be
> >a few hundred lines before the end of config.log --- the last section
> >of the log is a dump of the current values of all of configure's
> >variables, and there are a lot...)
> >
> >BTW, which 8.4.x PG release is this exactly?
> 
> its 8.4.3 ...   I'm jumping sideways and trying a different attack
> on my actual problem, which is building pl/java HEAD for 64bit
> solaris sparc w/ 8.4.3 and JDK 1.5.0_23...   rather than building
> the entire postgres tree, I replicated the couple missing files from
> the 32bit version and am 'fixing' their paths.

Even if you are able to get that to compile, it's likely to fall over at
run time.  Why not just build the complete tree?

-- 
Alvaro Herrerahttp://www.CommandPrompt.com/
PostgreSQL Replication, Consulting, Custom Development, 24x7 support

-- 
Sent via pgsql-general mailing list (pgsql-general@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-general


Re: [GENERAL] solaris tarballs and pl/java

2010-04-15 Thread Andy Colson

On 4/15/2010 11:59 AM, John R Pierce wrote:

The tarball for 64bit 8.4.3 on Solaris Sparc is missing some ./pgxs/...
files I seem to need to build pl/java. they exist in the 32bit version
but at least of them, Makefile.global, appears quite build specific.



So, it seem to be painful to compile the java stuff... and upthread you 
said someone "was more comfortable with java" and they were doing "some 
sorta-statistical calculations"... is it really worth all that?


They could do it in perl and it would probably be just as fast.  I mean, 
they arent gonna write _that_ much stored procedure code, are they?


If they had questions there are several on this list that could help 
them convert java to perl.


I'm just wondering... which is more expensive?

1) painful install pl/java, develop SP
2) install pl/perl, painful develop SP

-Andy

--
Sent via pgsql-general mailing list (pgsql-general@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-general


Re: [GENERAL] Byte Escape Syntax

2010-04-15 Thread Howard Yeh
On Thu, Apr 15, 2010 at 10:45 AM, Tom Lane  wrote:
> Howard Yeh  writes:
>> Is Postgres's byte escape syntax something that could be set by the client?
>
> Well, indirectly --- it's affected by the standard_conforming_strings
> setting.

is this something that could be set at runtime? Does it apply to the
whole database server?

Thanks!

>
>> I am running into a strange problem when I access postgres try two
>> different Ruby ORM's. I am guessing that one of them is doing
>> something funny to the client connections.
>
>> Looking at the Ruby C-driver, it's calling PQescapeBytea rather then
>> PQescapeByteaConn. And tracing PQescapeBytea, sometimes it escapes '\'
>> as '\\', as describe in the manual, sometimes it doesn't do that
>> escape. But it always escape the single quote character ' . All the
>> connections are using UTF-8 encoding.
>
> It would be a real good idea to fix that driver to use PQescapeByteaConn.
> There are no supported releases of Postgres that don't have that
> function.
>
>                        regards, tom lane
>

-- 
Sent via pgsql-general mailing list (pgsql-general@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-general


Re: [GENERAL] solaris tarballs and pl/java

2010-04-15 Thread John R Pierce

Alvaro Herrera wrote:

... 8.4.3 ...   I'm jumping sideways and trying a different attack
on my actual problem, which is building pl/java HEAD for 64bit
solaris sparc w/ 8.4.3 and JDK 1.5.0_23...   rather than building
the entire postgres tree, I replicated the couple missing files from
the 32bit version and am 'fixing' their paths.



Even if you are able to get that to compile, it's likely to fall over at
run time.  Why not just build the complete tree?
  


because, to make a long story short, the 'operations' people want to 
eventually install this onto a running production postgres server.




--
Sent via pgsql-general mailing list (pgsql-general@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-general


Re: [GENERAL] solaris tarballs and pl/java

2010-04-15 Thread John R Pierce

Andy Colson wrote:

On 4/15/2010 11:59 AM, John R Pierce wrote:

The tarball for 64bit 8.4.3 on Solaris Sparc is missing some ./pgxs/...
files I seem to need to build pl/java. they exist in the 32bit version
but at least of them, Makefile.global, appears quite build specific.



So, it seem to be painful to compile the java stuff... and upthread 
you said someone "was more comfortable with java" and they were doing 
"some sorta-statistical calculations"... is it really worth all that?


They could do it in perl and it would probably be just as fast.  I 
mean, they arent gonna write _that_ much stored procedure code, are they?


If they had questions there are several on this list that could help 
them convert java to perl.


I'm just wondering... which is more expensive?

1) painful install pl/java, develop SP
2) install pl/perl, painful develop SP


They have their code running now in pl/java on a Windows dev platform.   
but the production database this is targeted at is Solaris/Sparc


in fact, the *original* SP was in plsql on an Oracle database, but it 
made use of some oracle features which are not in Postgres, something 
called "Oracle Pipelined Table" (I don't even know what this is).


if it was me writing the code, I'd be doing it in perl, no problem.   
Their attitude is, pljava and SQLJ are a standard, plperl isn't.


anyways, I've got it all built now, and am just sorting out loading 
problems, I've moved over to the pljava-dev list for assistance on my 
current problems as this list is failrly java-hostile.




--
Sent via pgsql-general mailing list (pgsql-general@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-general


[GENERAL] Limit postgres user logins

2010-04-15 Thread gvim

My hba file has:

local   all postgresmd5
hostall admin 127.0.0.1/32  md5
hostall dbuser127.0.0.1/32  md5

But that still allows users other than postgres to attempt to login as 
postgres. Is there any way I can limit access to the postgres user specified as 
being logged in as postgres?

gvim



--
Sent via pgsql-general mailing list (pgsql-general@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-general


Re: [GENERAL] Limit postgres user logins

2010-04-15 Thread John R Pierce

gvim wrote:

My hba file has:

local   all postgresmd5
hostall admin 127.0.0.1/32  md5
hostall dbuser127.0.0.1/32  md5

But that still allows users other than postgres to attempt to login as 
postgres. Is there any way I can limit access to the postgres user 
specified as being logged in as postgres?



on the first line (and only the first line), change md5 to ident 
sameuser[leave sameuser off on 8.4]


then the postgres user can only log on as himself and noone else can.  


--
Sent via pgsql-general mailing list (pgsql-general@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-general


Re: [GENERAL] General Question about database -- redirection

2010-04-15 Thread Jorge Godoy
create database db_1 template db_2;

This will create a new DB_1 using DB_2 as template.  Otherwise, you'll
change your code to connect to DB_2 instead of connecting to DB_1.

--
Jorge Godoy 


On Thu, Apr 15, 2010 at 14:49, akp geek  wrote:

> dear all -
>
>  I am not supposed to ask this. But, the question is I have 2
> databases DB_1 and DB_2. I have a script that loads few tables in DB_1. The
> 2 databases are identical. In case , if database DB_1 is dropped, Is there
> any  command that I can issue to use the DB_2?
>
>
> Regards
>
>


Re: Inserting multiple values, was Re: [GENERAL] solaris tarballs and pl/java

2010-04-15 Thread Scott Marlowe
On Thu, Apr 15, 2010 at 1:49 PM, Raymond O'Donnell  wrote:
> On 15/04/2010 20:44, Ozz Nixon wrote:
>> Would this syntax work in PostgreSQL?
>>
>> |INSERT INTO MyTable (FirstCol, SecondCol)
>> VALUES ('First',1),
>> || ('||Second||',2),|
>> | ('||Third||',3),|
>> | ('||Fourth||',4),|
>> | ('||Fifth||',5)||
>> |
>> Inserting 5 rows in a single Insert? (I am trying to implement this
>> solution across many different backends) works on SQL Server 2008, need
>> to make sure it will work on many others.
>
> http://www.postgresql.org/docs/8.4/static/sql-insert.html

Remove the | symbols and it should

-- 
Sent via pgsql-general mailing list (pgsql-general@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-general


Re: [GENERAL] General Question about database -- redirection

2010-04-15 Thread akp geek
Thank you

On Thu, Apr 15, 2010 at 8:49 PM, Jorge Godoy  wrote:

> create database db_1 template db_2;
>
> This will create a new DB_1 using DB_2 as template.  Otherwise, you'll
> change your code to connect to DB_2 instead of connecting to DB_1.
>
> --
> Jorge Godoy 
>
>
>
> On Thu, Apr 15, 2010 at 14:49, akp geek  wrote:
>
>> dear all -
>>
>>  I am not supposed to ask this. But, the question is I have 2
>> databases DB_1 and DB_2. I have a script that loads few tables in DB_1. The
>> 2 databases are identical. In case , if database DB_1 is dropped, Is there
>> any  command that I can issue to use the DB_2?
>>
>>
>> Regards
>>
>>
>


[GENERAL] readline library not found

2010-04-15 Thread zhong ming wu
Dear List

I need to build a postgres on a linux machine that I don't have root access.

I built readline from source and installed it with prefix of /home/me/local

readline library are in /home/me/local/lib and headers files are in
/home/me/local/include/readline

After explicitly specfying these paths with --with-libs and
with-includes postgres configure is still choking
on readline.

To check that this should work, I disabled readline with
--without-readline and configure chokes at zlib not found.
So I install zlib from source at the same prefix.  This time postgres
configure finishes and then successfully built.

reading config.log is not helpful

Now if this solution works for zlib why is it not working for readline?

thanks

-- 
Sent via pgsql-general mailing list (pgsql-general@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-general


[GENERAL] Int64GetDatum

2010-04-15 Thread John R Pierce
I have compiled some C (pljava.c) for solaris sparc 64 bit, setup the 
LD_LIBRARY_PATH so postgres can find it, and try and load it.


me=# CREATE FUNCTION sqlj.java_call_handler()   RETURNS language_handler 
AS 'pljava'LANGUAGE C;
ERROR:  could not load library "/opt/mystuff/pljava/pljava.so": ld.so.1: 
postgres: fatal: relocation error: file /opt/mystuff/pljava/pljava.so: 
symbol Int64GetDatum: referenced symbol not found


oops. 

anyways, some digging (thank you kris jurka!) has shown that my 64bit 
solaris tarball (from the postgres website) is missing the 64 bit 
includes and lib/64/pgxs/src stuff.  for various reasons (many 
political) I'd like to get my module working with this version, hence 
would like to find the includes and stuff that were built with it. the 
website says Bjorn Munch of Sun built them.Does he monitor this list? 








--
Sent via pgsql-general mailing list (pgsql-general@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-general


Re: [GENERAL] Int64GetDatum

2010-04-15 Thread Tom Lane
John R Pierce  writes:
> I have compiled some C (pljava.c) for solaris sparc 64 bit, setup the 
> LD_LIBRARY_PATH so postgres can find it, and try and load it.

> me=# CREATE FUNCTION sqlj.java_call_handler()   RETURNS language_handler 
> AS 'pljava'LANGUAGE C;
> ERROR:  could not load library "/opt/mystuff/pljava/pljava.so": ld.so.1: 
> postgres: fatal: relocation error: file /opt/mystuff/pljava/pljava.so: 
> symbol Int64GetDatum: referenced symbol not found

This appears to be a consequence of 32-vs-64-bit confusion, ie, your
pljava.so was built assuming !USE_FLOAT8_BYVAL but the backend was
built with that symbol defined.  Are you still trying to hack your
way to a solution without making configure run properly?  Because
this is just about the sort of pain I'd expect from that "shortcut".

regards, tom lane

-- 
Sent via pgsql-general mailing list (pgsql-general@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-general


Re: [GENERAL] readline library not found

2010-04-15 Thread Tom Lane
zhong ming wu  writes:
> I need to build a postgres on a linux machine that I don't have root access.
> I built readline from source and installed it with prefix of /home/me/local

If you don't have root you're going to be in for a lot of pain here.
Linux is not designed to be friendly to libraries that aren't installed
in the path defined by /etc/ld.so.conf.  Can't you just install readline
as prepackaged by your distro?

> Now if this solution works for zlib why is it not working for readline?

It isn't working for zlib either ... if you look closely, I'll bet lunch
you find you're linking to the standard copy of zlib.

regards, tom lane

-- 
Sent via pgsql-general mailing list (pgsql-general@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-general


Re: [GENERAL] Int64GetDatum

2010-04-15 Thread John R Pierce

Tom Lane wrote:

John R Pierce  writes:
  
I have compiled some C (pljava.c) for solaris sparc 64 bit, setup the 
LD_LIBRARY_PATH so postgres can find it, and try and load it.



  
me=# CREATE FUNCTION sqlj.java_call_handler()   RETURNS language_handler 
AS 'pljava'LANGUAGE C;
ERROR:  could not load library "/opt/mystuff/pljava/pljava.so": ld.so.1: 
postgres: fatal: relocation error: file /opt/mystuff/pljava/pljava.so: 
symbol Int64GetDatum: referenced symbol not found



This appears to be a consequence of 32-vs-64-bit confusion, ie, your
pljava.so was built assuming !USE_FLOAT8_BYVAL but the backend was
built with that symbol defined.  Are you still trying to hack your
way to a solution without making configure run properly?  Because
this is just about the sort of pain I'd expect from that "shortcut".
  


Using the include files provided with the 64bit version is giving me the 
wrong Float8 type, yes, as they are the 32bit include files.


I need to build pl/java to run against the binary release of Postgres 
for largely political/corporate reasons.  this is to be installable as 
an addon to an existing large/complex database deployment.


If I build my own ./configure and compile my own postgres binary and use 
that to build this, what are the odds the module I compile will work 
with the released binary?


If I had the correct include files for the binary release, I would not 
be having this problem.


--
Sent via pgsql-general mailing list (pgsql-general@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-general