[GENERAL] SPI-functions and transaction control

2008-02-17 Thread Mikko Partio
Hello list I am trying to write a function in c that would 'merge' two tables together. The idea is that we insert rows from one table to another, and if there is a constraint violation, update the old row with the new row. I have done this succesfully with plpgsql, but alas, the tables are so b

Re: [GENERAL] Question about the enum type

2008-02-17 Thread Tim Hart
On Feb 18, 2008, at 12:10 AM, Tom Lane wrote: Would it have been reasonable to expect some kind of notice or warning message stating that 'position' was special, and position would be used instead? The way you phrase that makes me think you misunderstand what's happening here. The name of th

Re: [GENERAL] DB design: How to store object properties?

2008-02-17 Thread Oleg Bartunov
Max, we use contrib/hstore specially designed for such kind of problem. It's a sort of perl's hash, where you can store all specific properties. In that way, your table will looks like create table objects ( id integer, x real, y real, , props hstore) Here '...' designates other mandator

Re: [GENERAL] Question about the enum type

2008-02-17 Thread Tom Lane
Tim Hart <[EMAIL PROTECTED]> writes: > At the time I executed the statement > create type position as enum('pitcher', 'catcher', 'first base', > 'second base', 'third base', 'short stop', 'left field', 'center > field', 'right field', 'designated hitter', 'pinch hitter'); > Would it have been r

Re: [GENERAL] Question about the enum type

2008-02-17 Thread Tim Hart
On Feb 17, 2008, at 11:21 PM, Tom Lane wrote: The reason "position" is special is that the SQL spec calls out weird specialized syntax for it: Given the spec, I completely understand. Given the roundabout way I discovered the nature of the problem, I'm curious: At the time I executed the

Re: [GENERAL] Why isn't an index being used when selecting a distinct value?

2008-02-17 Thread Keaton Adams
The GROUP BY was the fastest method. Thanks for the suggestions, Keaton On 2/15/08 3:12 PM, "Gregory Stark" <[EMAIL PROTECTED]> wrote: > "Keaton Adams" <[EMAIL PROTECTED]> writes: > >> Version: Postgres 8.1.4 >> Platform: RHEL >> >> Given this scenario with the indexes in place, when I ask

Re: [GENERAL] Question about the enum type

2008-02-17 Thread Tom Lane
Tim Hart <[EMAIL PROTECTED]> writes: > On Feb 17, 2008, at 10:41 PM, Chris wrote: > It's a string manipulation function: > http://www.postgresql.org/docs/8.3/interactive/functions-string.html > If the issue were simply that it were a function name, than I would > have expected that attempting to

Re: [GENERAL] Question about the enum type

2008-02-17 Thread Tim Hart
On Feb 17, 2008, at 10:41 PM, Chris wrote: Chris wrote: I'm just toying around, so this isn't high priority. I'll probably change the name of the enum to fielding_position for clarity's sake anyway. But for my own education - what's so unique about the name 'position'? It's a string mani

Re: [GENERAL] Question about the enum type

2008-02-17 Thread Michael Glaesemann
On Feb 17, 2008, at 21:24 , Tim Hart wrote: But for my own education - what's so unique about the name 'position'? It's an SQL keyword: http://www.postgresql.org/docs/8.3/interactive/sql-keywords- appendix.html Michael Glaesemann grzm seespotcode net ---(end of

Re: [GENERAL] Question about the enum type

2008-02-17 Thread Chris
Chris wrote: I'm just toying around, so this isn't high priority. I'll probably change the name of the enum to fielding_position for clarity's sake anyway. But for my own education - what's so unique about the name 'position'? It's a string manipulation function: http://www.postgresql.org/

Re: [GENERAL] Question about the enum type

2008-02-17 Thread Chris
I'm just toying around, so this isn't high priority. I'll probably change the name of the enum to fielding_position for clarity's sake anyway. But for my own education - what's so unique about the name 'position'? It's a string manipulation function: http://www.postgresql.org/docs/8.3/inter

[GENERAL] Fwd: Question about the enum type

2008-02-17 Thread Tim Hart
I answered my own question. Should have waited another 5 minutes before composing the e-mail. This page: http://www.postgresql.org/docs/8.3/interactive/sql-keywords- appendix.html States that 'POSITION' is non-reserved, but cannot be a function or type. Slightly confusing as stated - I ap

[GENERAL] Question about the enum type

2008-02-17 Thread Tim Hart
I was playing around with the enum type today. I was toying around with a schema to model information about baseball, and decided to create an enum named position: tjhart=# create type position as enum('pitcher', 'catcher', 'first base', 'second base', 'third base', 'short stop', 'left field',

[GENERAL] Returning large bytea chunk

2008-02-17 Thread H . Harada
I would like to store very large data into one column, which contains my own data structure and memory layout. The data will be more than 500M bytes. I just wrote like: Datum myfunc(PG_FUNCTION_ARGS){ /* here get my data, allocated ~ 500M data */ ... /* allocate more than 500M */ bytea *

Re: [GENERAL] character conversion problem about UTF-8-->SHIFT_JIS_2004

2008-02-17 Thread Tatsuo Ishii
> Thanks for your reply. > I think ther are no error in 7.4.3 but warning. That means the character in question was ignored in 7.4, i.e. the character was skipped. I'm not sure that's actually what you want. > I used the old version 7.4.3 postgresql for 3 years with > UTF-8 encoding web base fron

Re: [GENERAL] DB design: How to store object properties?

2008-02-17 Thread Alexander Staubo
On 2/17/08, Maxim Khitrov <[EMAIL PROTECTED]> wrote: > So the scenario is this. We have two projects starting that will deal > heavily with mapping spatial regions. One of the reasons I'm looking > at PostgreSQL is the PostGIS extension that may help us in dealing > with all the geometry. >From yo

Re: [GENERAL] DB design: How to store object properties?

2008-02-17 Thread Douglas McNaught
On 2/17/08, Maxim Khitrov <[EMAIL PROTECTED]> wrote: > The simplest design would be to create two tables, one for nodes > another for edges, and create a column for every possible property. > This, however, is huge waste of space, since there will not be a > single node or edge that will make use o

Re: [GENERAL] using DROP in a transaction

2008-02-17 Thread Chris
Willy-Bas Loos wrote: ah, of course. the exclusive lock was preventing tty1 to read "test", and when the lock was gone, so was the table. I get it. Thanks a lot. But, what about the "ERROR: tuple concurrently updated" ? (in TTY3) Same thing - tty1 was locking that entry and when it was relea

[GENERAL] DB design: How to store object properties?

2008-02-17 Thread Maxim Khitrov
Greetings everyone, I'm fairly new to PostgreSQL, but I'm currently doing some research on tools to be used for an upcoming project and could really use your help with a possible database design. So the scenario is this. We have two projects starting that will deal heavily with mapping spatial re

[GENERAL] function or temporary table or what?

2008-02-17 Thread Ivan Sergio Borgonovo
I've such beast: select sm.ShipMethodID as _ShipMethodID, sm.Name as _Name, sm.Description as _Description from ( select sum(bi.qty) as N, sum(i.peso) as W, sum(i.price*bi.qty) as _price from shop_commerce_baskets b join shop_commerce_basket_items bi on bi.basketid=b.basketid joi

Re: [GENERAL] How to return a large String with C

2008-02-17 Thread Tom Lane
Stefan Niantschur <[EMAIL PROTECTED]> writes: > Am Sun, 17 Feb 2008 09:17:08 -0500 > schrieb Tom Lane <[EMAIL PROTECTED]>: >> Hardly surprising when you're printing the string into a fixed-size >> 8K buffer. The buffer overflow is smashing the stack, in particular >> the function's return address.

Re: [GENERAL] How to return a large String with C

2008-02-17 Thread Vyacheslav Kalinin
Yes, I know, but the backend does not allow for a bigger buffer. Trying > to use a 80K (char[81920])buffer did not work and returns: > INFO: string-size : 48015 > INFO: +++ > server closed the connection unexpectedly >This probably means the server terminated abnor

Re: [GENERAL] How to return a large String with C

2008-02-17 Thread Stefan Niantschur
Am Sun, 17 Feb 2008 09:17:08 -0500 schrieb Tom Lane <[EMAIL PROTECTED]>: > Stefan Niantschur <[EMAIL PROTECTED]> writes: > > So far I have been successfully doing calls to SPI, select the data > > from the table and return it. However, this works only with string > > not larger than page size of c

Re: [GENERAL] How to return a large String with C

2008-02-17 Thread Colin Wetherbee
Tom Lane wrote: Stefan Niantschur <[EMAIL PROTECTED]> writes: So far I have been successfully doing calls to SPI, select the data from the table and return it. However, this works only with string not larger than page size of char[8192]. The strings I expect are much longer and this causes the

Re: [GENERAL] How to return a large String with C

2008-02-17 Thread Tom Lane
Stefan Niantschur <[EMAIL PROTECTED]> writes: > So far I have been successfully doing calls to SPI, select the data from the > table and return it. However, this works only with string not larger than > page size of char[8192]. > The strings I expect are much longer and this causes the backend to

Re: [GENERAL] the feasibility of sending email from stored procedure in Postgres

2008-02-17 Thread Jorge Godoy
Em Friday 15 February 2008 12:36:37 Adam Rich escreveu: > > I would instead queue messages (or suitable information about them) in > > a table, and have a process outside PostgreSQL periodically poll for them > > Why poll when you can wait? > > http://www.postgresql.org/docs/8.2/interactive/sql-not

[GENERAL] How to return a large String with C

2008-02-17 Thread Stefan Niantschur
Hi all, I want to write a function in C which retrieves a large string from a table, does some work on it and returns the result to the surrounding SELECT. (e.g. SELECT my_c_func(text);) So far I have been successfully doing calls to SPI, select the data from the table and return it. However,