Re: [GENERAL] spi/timetravel: unique constraint violation on UPDATE

2017-07-15 Thread Tom Lane
postgre...@get-experience.com writes: > Den 15. juli 2017 23:15, skrev Tom Lane: >> Perhaps you could make your PK be on (id, valid_from, valid_to). > Doesn't really work because valid_to would change on UPDATE. I'd need to > update foreign relations with another trigger which would be very ugly.

Re: [GENERAL] spi/timetravel: unique constraint violation on UPDATE

2017-07-15 Thread postgresql
Den 15. juli 2017 23:15, skrev Tom Lane: > postgre...@get-experience.com writes: >> I'm having a problem with the timetravel extension. Following simple schema: >> ... >> What am I doing wrong here? According to the function comment in >> timetravel.c it should: >> a) set last-version row to NEW d

Re: [GENERAL] spi/timetravel: unique constraint violation on UPDATE

2017-07-15 Thread Tom Lane
postgre...@get-experience.com writes: > I'm having a problem with the timetravel extension. Following simple schema: > ... > What am I doing wrong here? According to the function comment in > timetravel.c it should: > a) set last-version row to NEW data; valid_from=now() > b) insert a new row with

[GENERAL] spi/timetravel: unique constraint violation on UPDATE

2017-07-15 Thread postgresql
Hey, I'm having a problem with the timetravel extension. Following simple schema: CREATE EXTENSION timetravel; CREATE TABLE entries ( id SERIAL NOT NULL, value INT NOT NULL, valid_from ABSTIME NOT NULL, valid_to ABSTIME NOT NULL, PRIMARY KEY (id, valid_f

Re: [GENERAL] SPI returns error for SAVEPOINT

2016-05-24 Thread dandl
> >>SPI_exec("BEGIN",...) returns error SPI_ERROR_TRANSACTION. As expected. > >>SPI_exec("SAVEPOINT xyz",...) returns error SPI_ERROR_TRANSACTION. Not > > expected. > > The docs say that this is expected: > https://www.postgresql.org/docs/devel/static/spi-spi-execute.html > SPI_ERROR_TRANSACTION >

Re: [GENERAL] SPI returns error for SAVEPOINT

2016-05-24 Thread Michael Paquier
On Tue, May 24, 2016 at 9:55 PM, dandl wrote: > A plandl (language handler for Andl) function is called as follows: > > BEGIN; > SELECT plandl_compile($1); // argument is Andl code > COMMIT; > > Inside: > >>SPI_exec("BEGIN",...) returns error SPI_ERROR_TRANSACTION. As expected. >

[GENERAL] SPI returns error for SAVEPOINT

2016-05-24 Thread dandl
A plandl (language handler for Andl) function is called as follows: BEGIN; SELECT plandl_compile($1); // argument is Andl code COMMIT; Inside: >SPI_exec("BEGIN",...) returns error SPI_ERROR_TRANSACTION. As expected. >SPI_exec("SAVEPOINT xyz",...) returns error SPI_ERROR_TRANSAC

Re: [GENERAL] spi in bgworker

2014-03-22 Thread James Harper
> > James Harper wrote: > > The docs say I'm supposed to call BackgroundWorkerInitializeConnection in > a bgworker and then I can start using spi functions, but they aren't clear on > if > I should call SPI_connect too. > > > > If I call BackgroundWorkerInitializeConnection and then SPI_execute I

Re: [GENERAL] spi in bgworker

2014-03-22 Thread Alvaro Herrera
James Harper wrote: > The docs say I'm supposed to call BackgroundWorkerInitializeConnection in a > bgworker and then I can start using spi functions, but they aren't clear on > if I should call SPI_connect too. > > If I call BackgroundWorkerInitializeConnection and then SPI_execute I get a > r

[GENERAL] spi in bgworker

2014-03-22 Thread James Harper
The docs say I'm supposed to call BackgroundWorkerInitializeConnection in a bgworker and then I can start using spi functions, but they aren't clear on if I should call SPI_connect too. If I call BackgroundWorkerInitializeConnection and then SPI_execute I get a return code of SPI_ERROR_UNCONNEC

[GENERAL] SPI function varchar difference between 9.0 and 9.2

2012-11-06 Thread Achilleas Mantzios
(pls, include me in the reply, i am resending this from here since the one sent from achill(at)matrix(dot)gatewaynet(dot)com didn't make it for some reason) Hello, we are using and still maintaining a heavily modified version of DBMirror in our infrastructure, involving one master and 80 (and

[GENERAL] SPI functions to work with the Execution Plan

2012-02-15 Thread Osmel Barreras Piñera
Thanks for answering: I am a member of the PostgreSQL development community here in Cuba. My proposal is to develop an extension to PostgreSQL that allows query execution using multiple threads. The central idea is to get the execution plan ready to run, but send him to run with the same postgr

Re: [GENERAL] SPI functions to work with the Execution Plan

2012-02-05 Thread Tom Lane
Osmel Barreras =?utf-8?Q?Pi=C3=B1era?= writes: > I need to develop for my diploma thesis an extension that allows me to travel > the implementation plan once you pass through the phase of planning and > optimization. SPI functions that could be used to obtain and work with the > plan? SPI is n

[GENERAL] SPI functions to work with the Execution Plan

2012-02-05 Thread Osmel Barreras Piñera
I need to develop for my diploma thesis an extension that allows me to travel the implementation plan once you pass through the phase of planning and optimization. SPI functions that could be used to obtain and work with the plan? Fin a la injusticia, LIBERTAD AHORA A NUESTROS CINCO COMPATRIOT

[GENERAL] SPI high level abstraction?

2010-10-04 Thread Jacqui Caren-home
Is there any C libs out there that will abstract the SPI interface? I have a number of functions that do input process output and they are all almost identical (tablename fields, change) I could abstract the code but would prefer to re-use an exissting abstraction layer as the less code I write

Re: [GENERAL] SPI-functions and transaction control

2008-02-20 Thread Mikko Partio
On Feb 19, 2008 12:12 AM, Alvaro Herrera <[EMAIL PROTECTED]> wrote: > Mikko Partio escribió: > > > Now, I was wondering if a c function would be faster, and with the help > of > > the manual I have written a function that can insert tuples from one > table > > to another. As the manual states ( >

Re: [GENERAL] SPI-functions and transaction control

2008-02-18 Thread Alvaro Herrera
Mikko Partio escribió: > Now, I was wondering if a c function would be faster, and with the help of > the manual I have written a function that can insert tuples from one table > to another. As the manual states ( > http://www.postgresql.org/docs/8.3/interactive/spi.html), there is no way to > cat

[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] SPI dumping core on large palloc

2007-10-08 Thread Tom Lane
"Merlin Moncure" <[EMAIL PROTECTED]> writes: > Am I doing anything wrong here? Returning an already-pfree'd hunk of memory. I gather you are not testing your code in an enable-cassert build (tut tut), else you'd not think this worked for small allocations either. See http://developer.postgresql.

[GENERAL] SPI dumping core on large palloc

2007-10-08 Thread Merlin Moncure
I'm having an issue inside a SPI routine that is giving me crashes. I'm curious if this is a backend problem or something that I am doing improperly. The following SPI routine dumps core for large, but reasonable allocations: /* testing function. just makes bytea a of input len */ Datum _genbytes

Re: [GENERAL] SPI shared memory ?

2007-09-21 Thread Tom Lane
Alex Vinogradovs <[EMAIL PROTECTED]> writes: > Yes, I'd like to get some memory of my own, so that it can > be shared between functions executing in different connections. > Is there an existent API, or should I just straight use Unix IPC ? As of (I think) 8.2, there's RequestAddinShmemSpace and R

Re: [GENERAL] SPI shared memory ?

2007-09-21 Thread Alex Vinogradovs
Yes, I'd like to get some memory of my own, so that it can be shared between functions executing in different connections. Is there an existent API, or should I just straight use Unix IPC ? Thanks! Alex. On Fri, 2007-09-21 at 16:33 -0700, Jeff Davis wrote: > On Fri, 2007-09-21 at 12:50 -0700, Al

Re: [GENERAL] SPI shared memory ?

2007-09-21 Thread Jeff Davis
On Fri, 2007-09-21 at 12:50 -0700, Alex Vinogradovs wrote: > Guys, > > > Is there any exposed PG-specific API to utilize shared memory while > working with SPI ? Thanks! > What are you trying to do? The available SPI functions don't include any shared memory access, do you actually want access

[GENERAL] SPI shared memory ?

2007-09-21 Thread Alex Vinogradovs
Guys, Is there any exposed PG-specific API to utilize shared memory while working with SPI ? Thanks! Best regards, Alex Vinogradovs ---(end of broadcast)--- TIP 9: In versions below 8.0, the planner will ignore your desire to choose an in

Re: [GENERAL] SPI using perl

2007-06-22 Thread Joshua D. Drake
Jasbinder Singh Bali wrote: my $query = "SELECT sp_insert(" . $a . "," . $b . "," . $c . ")"; my $exec_query = spi_exec_query($query); here i'm calling a function sp_insert and passing parameters a,b,c to it. Is this the right usage to spi_exec_query? http://www.postgresql.org/docs/8.2/static

Re: [GENERAL] SPI using perl

2007-06-22 Thread Jasbinder Singh Bali
my $query = "SELECT sp_insert(" . $a . "," . $b . "," . $c . ")"; my $exec_query = spi_exec_query($query); here i'm calling a function sp_insert and passing parameters a,b,c to it. Is this the right usage to spi_exec_query? Thanks, ~Jas On 6/22/07, Joshua D. Drake <[EMAIL PROTECTED]> wrote:

Re: [GENERAL] SPI using perl

2007-06-22 Thread Joshua D. Drake
Jasbinder Singh Bali wrote: Hi I was wondering if its necessary to download DBI::PgSPI package from CPAN to use spi_exec_query in perl No. Using plperl is the way to go. See the docs there are examples under plperl. Joshua D. Drake or it can be used without downloading the above mentioned

[GENERAL] SPI using perl

2007-06-22 Thread Jasbinder Singh Bali
Hi I was wondering if its necessary to download DBI::PgSPI package from CPAN to use spi_exec_query in perl or it can be used without downloading the above mentioned package. I've tried using spi_exec_query without that package but doesn't work. Thanks, Jas

Re: [GENERAL] SPI

2006-11-17 Thread Tomas Vondra
> Hi all, > > I have some doubts about SPI (Server Programming Interface). In > fact, I must create Stored Procedures in Postgres (8.0). The problem is: > all stored procedures and, may be, some triggers must be compiled 'cause > the clients can't access the source code of them. > To solve

[GENERAL] SPI

2006-11-16 Thread Danilo Freitas da Costa
Hi all,     I have some doubts about SPI (Server Programming Interface). In fact, I must create Stored Procedures in Postgres (8.0). The problem is: all stored procedures and, may be, some triggers must be compiled 'cause the clients can't access the source code of them.     To solve this prob

[GENERAL] SPI based table locks.

2006-07-13 Thread Chris Bowlby
Hi All, I've been working on a small module that I will be pluging into my local PostreSQL 8.x database and am in need of doing some table locking. At this time, I've used various other examples to no avail and was wondering what the proper method for aquiring a table lock within the module w

[GENERAL] SPI cursors pinned buffer and moving to the first tuple.

2005-04-27 Thread Tzahi Fadida
Hi, I need to verify something. I use spi cursors in a C function (which return a SETOF). I am using the spi cursors to run the following query: "SELECT DISTINCT * FROM mytable". Each time the system gets back to the function spi cursor can give me the next tuple which I can return. Q1:My question

[GENERAL] SPI vs low level functions.

2005-02-25 Thread Tzahi Fadida
Hi, I am trying to determine if there is a difference in I/O cost between SPI functions and low level functions like heap_fetch, heap_getnext, etc... I want to decide if there is any merit for using the low level functions instead of the easier SPI. My guess is that they both use the same underlyin

Re: [GENERAL] SPI memory overrun details

2004-11-25 Thread Tom Lane
"Katsaros Kwn/nos" <[EMAIL PROTECTED]> writes: > I read in the documentation of SPI functions that an SPI_cursor is used > to avoid memory overrun in cases where a query returns many rows. I'd > like to learn more about this. Is their any place that I could find more > detailed information (e.g. ma

[GENERAL] SPI memory overrun details

2004-11-25 Thread Katsaros Kwn/nos
Hi, I read in the documentation of SPI functions that an SPI_cursor is used to avoid memory overrun in cases where a query returns many rows. I'd like to learn more about this. Is their any place that I could find more detailed information (e.g. max size of results, threshold - available memory et

Réf. : Re: [GENERAL] SPI memory managment issue

2004-03-04 Thread bsimon
     [EMAIL PROTECTED]         Objet :        Re: [GENERAL] SPI memory managment issue [EMAIL PROTECTED] writes: > The thing is that I do another spi_connect inside all subqueries (query1 > ... query10) and the memory allocated inside all "subcontext"  doesn't > seems  to be free

Re: [GENERAL] SPI question (or not): trying to read from Large Objects from within a function

2004-01-06 Thread Tom Lane
David Helgason <[EMAIL PROTECTED]> writes: > These internal functions (loread/lowrite) have quite different > signatures from their C equivalents (as opposed to lo_lseek). Found out > from the sources that I was using it very incorrectly. I had just realized from reading your last message that y

Re: [GENERAL] SPI question (or not): trying to read from Large Objects from within a function

2004-01-06 Thread David Helgason
Sorry for spamming I'm getting the hang of this, and figured this one out myself :) These internal functions (loread/lowrite) have quite different signatures from their C equivalents (as opposed to lo_lseek). Found out from the sources that I was using it very incorrectly. But discovered l

Re: [GENERAL] SPI question (or not): trying to read from Large Objects from within a function

2004-01-06 Thread David Helgason
Thank you very much, I figured I needed to open my own using SPI_connect(). I had assumed that there was sth like a the-connection-this-functions-is-begin-run-through. Now I'm having problems with size_t inBufSize = 8192; char* inBuffer = (char*)palloc(inBufSize); int bytes_read = DatumGetInt3

Re: [GENERAL] SPI question (or not): trying to read from Large Objects from within a function

2004-01-06 Thread Tom Lane
David Helgason <[EMAIL PROTECTED]> writes: > I'm having trouble finding out how to find the current PGconn > connection inside a C function. What makes you think that "*the* current PGconn" is a valid concept? libpq has always supported multiple active connections. regard

[GENERAL] SPI question (or not): trying to read from Large Objects from within a function

2004-01-06 Thread David Helgason
What: I'm having trouble finding out how to find the current PGconn connection inside a C function. Looking through the documentation didn't give this up. Could anyone suggest where to look? I didn't even see anything similar to this in the SPI_* documentation. Perhaps I am totally mislead here

[GENERAL] SPI portals and memory usage

2003-07-07 Thread strk
Do I save memory using a cursor from a SPI-connected procedure ? I'm working on a table containing geometric objects and I'd like to keep a geometry in memory just for the time it is needed, and one at time, otherwise my machine is in permanent swapping. --strk; ---(end o

Re: [GENERAL] SPI & file locations

2000-05-26 Thread Tom Lane
Lamar Owen <[EMAIL PROTECTED]> writes: > /lib/cpp -M -I. -I../backend executor/spi.h |xargs -n 1|grep \\W|grep -v ^/|grep -v >spi.h | sort |cpio -pdu $RPM_BUILD_ROOT/usr/include/pgsql > This could easily enough be included in the make install, couldn't it? > (Tom? Anyone?) I realize that GNU g

Re: [GENERAL] SPI & file locations

2000-05-26 Thread Lamar Owen
On Fri, 26 May 2000, Tom Lane wrote: > Ron Peterson <[EMAIL PROTECTED]> writes: > > After installation, shouldn't everything you need be in > > /usr/local/pgsql? > Yeah, it should really. We've had this discussion before. The real > problem is that no one wants to install the entire pgsql incl

Re: [GENERAL] SPI & file locations

2000-05-26 Thread Lamar Owen
On Fri, 26 May 2000, Mike Mascari wrote: > Ron Peterson wrote: > > After installation, shouldn't everything you need be in > > /usr/local/pgsql? Too many assumptions are in the source that the source will always be there. Not necessarily true! > I too have run into this dependency problem. The

[GENERAL] SPI

1999-01-06 Thread Anand Surelia
I'm installing v6.4.2 on Solaris 2.5.1. Everything goes well until I run the regression test. Some of the test fails with an error message like: + ERROR: Load of file /bytek/postgres/postgresql-6.4.2/src/test/regress/input/. ./regress.so failed: ld.so.1: /bytek/postgres/bin/postmaster: fatal: rel

Re: [GENERAL] SPI and Libpq

1998-09-22 Thread David Hartwig
SPI - Server Programming Interface is for coding C functions in the backend. Thus triggers can reference functions created using SPI.. Libpq is a front-end (or client side) API. Anand Surelia wrote: > Hi, > Can anyone tell me what is the difference between the SPI and the Libpq > interfaces

[GENERAL] SPI and Libpq

1998-09-22 Thread Anand Surelia
Hi, Can anyone tell me what is the difference between the SPI and the Libpq interfaces and when to use what? I am writing some functions that will be used by triggers. What interface should I use to implement those functions? Thanks, Anand