Re: [HACKERS] Best practices: MERGE

2005-03-08 Thread Simon Riggs
On Mon, 2005-03-07 at 19:34 -0800, David Fetter wrote: Although the SQL:2003 command MERGE has not yet been implemented in PostgreSQL, I'm guessing that there are best practices for how to implement the MERGE functionality. To recap, MERGE means (roughly) INSERT the tuple if no tuple

Re: [HACKERS] Best practices: MERGE

2005-03-08 Thread David Fetter
On Tue, Mar 08, 2005 at 12:27:21PM +0800, Christopher Kings-Lynne wrote: Luckily, PG 8 is available for this. Do you have a short example? No, and I think it should be in the manual as an example. You will need to enter a loop that uses exception handling to detect unique_violation.

Re: [HACKERS] Cost of XLogInsert CRC calculations

2005-03-08 Thread Simon Riggs
On Mon, 2005-03-07 at 20:50 -0500, Tom Lane wrote: Simon Riggs [EMAIL PROTECTED] writes: Well, we're using the CRC in 3 separate places... (1) for xlog records (2) for complete blocks copied to xlog (3) for control files For (1), records are so short that probably CRC16 would be

Re: [HACKERS] Best practices: MERGE

2005-03-08 Thread Christopher Kings-Lynne
You can create a procedure to do that, but MERGE would work better. ISTM that would require writing some new code that was a mix of heap_update and heap_insert logic for the low level stuff would be required. The existing heap_update code is most similar, since the logic is roughly UPDATE

[HACKERS] ERROR: unrecognized node type in PostgresMain( )

2005-03-08 Thread mchron
Perhaps you should rebuild the backend with -g (see --enable-debug) so that gdb can actually be somewhat helpful. It's usually a good idea to have --enable-cassert turned on when hacking C code, too. When I rebuilded the backend with --enable-debug and --enable-cassert the database stops and

Re: [HACKERS] About b-tree usage

2005-03-08 Thread Ioannis Theoharis
let me, i have turned enable_seqscan to off, in order to discourage optimizer to choose seq_scan whenever an idex_scan can be used. But in this case, why optimizer don't chooses seq_scan (discourage is different than prevent) ? At many cases i need only a small fragment of raws to be

Re: [HACKERS] About b-tree usage

2005-03-08 Thread Michael Paesold
Ioannis Theoharis wrote: let me, i have turned enable_seqscan to off, in order to discourage optimizer to choose seq_scan whenever an idex_scan can be used. But in this case, why optimizer don't chooses seq_scan (discourage is different than prevent) ? You probably know that PostgreSQL uses a

Re: [HACKERS] About b-tree usage

2005-03-08 Thread Klaus Naumann
Hi, if you're using a pg version prio to 8.0 your pitfall might also be a conversion between int and bigint datatypes. So if you're doing somthing like SELECT a.x, b.y, c.y FROM a, b WHERE a.x = b.x; and a.x is INT4 and b.x is INT8 (or BIGINT) the planner counts this as a data conversion and uses

Re: [HACKERS] ERROR: unrecognized node type in PostgresMain( )

2005-03-08 Thread Tom Lane
[EMAIL PROTECTED] writes: Perhaps you should rebuild the backend with -g (see --enable-debug) so that gdb can actually be somewhat helpful. It's usually a good idea to have --enable-cassert turned on when hacking C code, too. When I rebuilded the backend with --enable-debug and

[HACKERS] How to cast VARCHAR to BYTEA and vice-versa?

2005-03-08 Thread Moran.Michael
Hello all, I have a table with a VARCHAR column that I need to convert to a BYTEA. How do I cast VARCHAR to BYTEA? The following doesn't seem to work as it yields the 'cannot cast varchar to bytea' error message: varchar_data::bytea On the same topic, how do I do the reverse, that

Re: [HACKERS] How to cast VARCHAR to BYTEA and vice-versa?

2005-03-08 Thread Moran.Michael
Thank you, Tom. Yes, the exact bytes in the varchar datum (without encoding) is what I would like to become the bytes in the BYTEA. So, how do I create a cast WITHOUT FUNCTION as you mention below? I assume plpgsql is required, right? Is there anyway this can be done in a VIEW without having

[HACKERS] fool-toleranced optimizer

2005-03-08 Thread Oleg Bartunov
Hi there, I just noticed a little optimizer problem - in second query there is unused 'tycho t2' table alias which gets backend buried. This is artificial query, I just tried to check if optimizier could recognize this. tycho=# explain analyze select t.pm_ra,t.pm_dec from tycho t where t.pm_ra

Re: [HACKERS] fool-toleranced optimizer

2005-03-08 Thread Neil Conway
Oleg Bartunov wrote: I just noticed a little optimizer problem - in second query there is unused 'tycho t2' table alias which gets backend buried. It's not an unused table alias, it is specifying the cartesian product of `tycho' with itself. I don't see how this is an optimizer problem: it's a

Re: [HACKERS] How to cast VARCHAR to BYTEA and vice-versa?

2005-03-08 Thread Alvaro Herrera
On Tue, Mar 08, 2005 at 02:16:52PM -0800, Moran.Michael wrote: Yes, the exact bytes in the varchar datum (without encoding) is what I would like to become the bytes in the BYTEA. So, how do I create a cast WITHOUT FUNCTION as you mention below? I assume plpgsql is required, right? Did you

Re: [HACKERS] How to cast VARCHAR to BYTEA and vice-versa?

2005-03-08 Thread Christopher Kings-Lynne
How do I cast VARCHAR to BYTEA? I think it would work to create a cast WITHOUT FUNCTION, assuming that the semantics you want is that the exact bytes in the varchar datum become the bytes in the bytea (no encoding or backslashing conversions). Are pg_escape_bytea and pg_unescape_bytea available

Re: [HACKERS] Where to see the patch queue (was Re: [PATCHES] Patch

2005-03-08 Thread Bruce Momjian
Robert Treat wrote: On Thursday 03 March 2005 19:08, Neil Conway wrote: Thomas F.O'Connell wrote: committers, myself included, deserve some blame for not making more rapid progress on the queue of unapplied patches for 8.1. In the meanwhile, the queue should be easier for folks to find

Re: [HACKERS] postgreSQL-8.0.1 compilation with icc-8.1 on Itanium-2

2005-03-08 Thread Bruce Momjian
Does the Intel compiler not support inline assembler? _InterlockedExchange() is a function call and we prefer to have asm() code if we can get it. --- Vikram Kalsi wrote: Just an update, the __INTEL_COMPILER is true on

Re: [HACKERS] postgreSQL-8.0.1 compilation with icc-8.1 on Itanium-2

2005-03-08 Thread Bruce Momjian
Vikram Kalsi wrote: The _InterlockedExchange() function is defined in ia64intrin.h header file int _InterlockedExchange(volatile int *Target, long value) Do an exchange operation atomically. Maps to the xchg4 instruction. More information is available at

Re: [HACKERS] postgreSQL-8.0.1 configure --enable-thread-safety with

2005-03-08 Thread Bruce Momjian
The Intel compiler complains about global variables that are not marked either static or extern. They are remarks so I think you are OK with that. The attached patch should remove the warnings but I am not applying it because a non-static/extern global variable should be fine in C code. The

[HACKERS] two questions related to tablespace in PG8.0.1

2005-03-08 Thread Qingqing Zhou
Here are two questions related to PG8.0.1: 1. durability of create tablespace - what happens if several checkpoints done after create tablespace then system crashes - without redo, will the PG_VERSION file and symlinks survive in win32? Seems checkpoint didn't sync the content of PG_VERSION file.

Re: [HACKERS] two questions related to tablespace in PG8.0.1

2005-03-08 Thread Tom Lane
Qingqing Zhou [EMAIL PROTECTED] writes: Here are two questions related to PG8.0.1: 1. durability of create tablespace - what happens if several checkpoints done after create tablespace then system crashes - without redo, will the PG_VERSION file and symlinks survive in win32? Seems checkpoint

Re: [HACKERS] postgreSQL-8.0.1 configure --enable-thread-safety with

2005-03-08 Thread Neil Conway
Bruce Momjian wrote: The attached patch should remove the warnings but I am not applying it because a non-static/extern global variable should be fine in C code. What's the harm in applying it? Variables and functions not used outside the compilation unit in which they are defined _should_ be

Re: [HACKERS] postgreSQL-8.0.1 configure --enable-thread-safety with icc-8.1 on RHEL-AS3 Itanium-2 gives error

2005-03-08 Thread Vikram Kalsi
I was ignoring the warnings anyway. I didn't look into that much but after upgrading to RHEL AS4, I am able to compile successfully with --enable-thread-safety Thanks, On Tue, 8 Mar 2005 23:28:20 -0500 (EST), Bruce Momjian pgman@candle.pha.pa.us wrote: The Intel compiler complains about

[HACKERS] Current CVS parallel test lock

2005-03-08 Thread Christopher Kings-Lynne
Running latest cvs on freebsd gives me errors in test strings and test errors, and completely hangs at this point: parallel group (14 tests): limit prepare sequence copy2 truncate rowtypes polymorphism temp domain conversion rangefuncs without_oid alter_table Chris parallel group (13 tests):

Re: [HACKERS] two questions related to tablespace in PG8.0.1

2005-03-08 Thread Qingqing Zhou
There is no such thing as crash without redo: that is what WAL is all about. The creation of the tablespace will be correctly replayed from WAL. (Of course, this claim depends on various assumptions about whether fsync behaves per spec ... but if it does not, tablespace creation is hardly

Re: [HACKERS] Current CVS parallel test lock

2005-03-08 Thread Tom Lane
Christopher Kings-Lynne [EMAIL PROTECTED] writes: Running latest cvs on freebsd gives me errors in test strings and test errors, and completely hangs at this point: Time for a clean rebuild? I've not seen any failures, neither has the build farm ... regards, tom lane

Re: [HACKERS] Current CVS parallel test lock

2005-03-08 Thread Qingqing Zhou
Christopher Kings-Lynne [EMAIL PROTECTED] Running latest cvs on freebsd gives me errors in test strings and test errors, and completely hangs at this point: I got a similar problem and system hangs randomly(esp. in test strings) in win32-mingw. The problem I found is in pgunlink(). There is a

Re: [HACKERS] Current CVS parallel test lock

2005-03-08 Thread Christopher Kings-Lynne
Time for a clean rebuild? I've not seen any failures, neither has the build farm ... cvs up gmake clean ./configure --prefix=/home/chriskl/local --enable-depend --enable-debug --enable-cassert --with-perl --with-pam --with-openssl gmake check Still hangs. Gets new failure in create function

Re: [HACKERS] Current CVS parallel test lock

2005-03-08 Thread Michael Fuhr
On Wed, Mar 09, 2005 at 03:24:20PM +0800, Christopher Kings-Lynne wrote: gmake clean Have you tried gmake distclean? I just built the latest HEAD on FreeBSD 4.11-STABLE and all tests passed. Configure options were: ./configure --prefix=/usr/local/pgsql81 \ --with-pgport=5481 \

Re: [HACKERS] Current CVS parallel test lock

2005-03-08 Thread Christopher Kings-Lynne
Have you tried gmake distclean? I just built the latest HEAD on FreeBSD 4.11-STABLE and all tests passed. Configure options were: Hrm, I just did a gmake install; gmake installcheck - that worked fine. Then I did gmake check again and now that works fine... It must have been picking up