dbTalk Databases Forums  

PQcmdTuples and partitioned tables

comp.databases.postgresql comp.databases.postgresql


Discuss PQcmdTuples and partitioned tables in the comp.databases.postgresql forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
Graham Murray
 
Posts: n/a

Default PQcmdTuples and partitioned tables - 08-04-2010 , 02:51 AM






When using the partitioning scheme using triggers as suggested in the
postgresql 8.4 documentation section 5.9.2, after inserting a record
into the 'parent' table PQcmdTuples() returns 0 rows
inserted. Presumably this is because the trigger function redirects the
insert to the appropriate child table. I see this with both 8.4.4 and
9.0beta3.

Using libpq, is there any way following an 'insert into partitioned_table' to
determine whether any rows were inserted?

Reply With Quote
  #2  
Old   
Mladen Gogala
 
Posts: n/a

Default Re: PQcmdTuples and partitioned tables - 08-04-2010 , 11:21 AM






On Wed, 04 Aug 2010 08:51:30 +0100, Graham Murray wrote:


Quote:
Using libpq, is there any way following an 'insert into
partitioned_table' to determine whether any rows were inserted?
It is a relational database, if there is no error, you have to assume
that rows were inserted .... somewhere?



--
http://mgogala.byethost5.com

Reply With Quote
  #3  
Old   
Jasen Betts
 
Posts: n/a

Default Re: PQcmdTuples and partitioned tables - 08-05-2010 , 06:06 AM



On 2010-08-04, Graham Murray <newspost (AT) gmurray (DOT) org.uk> wrote:
Quote:
When using the partitioning scheme using triggers as suggested in the
postgresql 8.4 documentation section 5.9.2, after inserting a record
into the 'parent' table PQcmdTuples() returns 0 rows
inserted. Presumably this is because the trigger function redirects the
insert to the appropriate child table. I see this with both 8.4.4 and
9.0beta3.

Using libpq, is there any way following an 'insert into partitioned_table' to
determine whether any rows were inserted?
have the last trigger raise a notice or deug message when it sees an
insertion, and look for that.

unless you have triggers that drop inserts silently you could just
check the return code is not an error code.


--- news://freenews.netfront.net/ - complaints: news (AT) netfront (DOT) net ---

Reply With Quote
  #4  
Old   
Robert Klemme
 
Posts: n/a

Default Re: PQcmdTuples and partitioned tables - 08-20-2010 , 04:03 AM



On 4 Aug., 18:21, Mladen Gogala <n... (AT) email (DOT) here.invalid> wrote:
Quote:
On Wed, 04 Aug 2010 08:51:30 +0100, Graham Murray wrote:
Using libpq, is there any way following an 'insert into
partitioned_table' to determine whether any rows were inserted?

It is a relational database, if there is no error, you have to assume
that rows were inserted .... somewhere?
That's true, but the OP might be interested in the number of rows
inserted (e.g. in case of an INSERT combined with SELECT). Executing
the SELECT twice has a performance penalty and might lead incorrect
results (if other INSERTS occur between the SELECT and INSERT).

Kind regards

robert

Reply With Quote
  #5  
Old   
Mladen Gogala
 
Posts: n/a

Default Re: PQcmdTuples and partitioned tables - 08-20-2010 , 08:24 PM



On Fri, 20 Aug 2010 02:03:42 -0700, Robert Klemme wrote:

Quote:
That's true, but the OP might be interested in the number of rows
inserted (e.g. in case of an INSERT combined with SELECT). Executing
the SELECT twice has a performance penalty and might lead incorrect
results (if other INSERTS occur between the SELECT and INSERT).

Kind regards
GET_DIAGNOSTICS trick described here might help with plpgsql:

http://www.postgresql.org/docs/8.4/s....html#PLPGSQL-
STATEMENTS-SQL-ONEROW




--
http://mgogala.byethost5.com

Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.3
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.