pg.ddx.io  pgsql-interfaces@postgresql.org mailing list archive  
help / color / mirror / Atom feed
ESQL/C TRUNCATE TABLE results in DROP TABLE
2+ messages / 2 participants
[nested] [flat]

* ESQL/C TRUNCATE TABLE results in DROP TABLE
@ 2001-10-01 10:27 Lee Kindness <lkindness@csl.co.uk>
  2001-10-01 11:50 ` Re: ESQL/C TRUNCATE TABLE results in DROP TABLE Michael Meskes <meskes@postgresql.org>
  0 siblings, 1 reply; 2+ messages in thread

From: Lee Kindness @ 2001-10-01 10:27 UTC (permalink / raw)
  To: pgsql-bugs@postgresql.org; +Cc: lkindness@csl.co.uk; pgsql-interfaces

Your name		: Lee Kindness
Your email address	: lkindness@csl.co.uk

System Configuration
---------------------
  Architecture (example: Intel Pentium)  	: Intel Pentium
  Operating System (example: Linux 2.0.26 ELF) 	: Linux 2.2.16-22, RedHat 7.0
  PostgreSQL version (example: PostgreSQL-7.1.3): PostgreSQL-7.1.3
  Compiler used (example:  gcc 2.95.2)		: RPM

Please enter a FULL description of your problem:
------------------------------------------------

'TRUNCATE TABLE' in embedded SQL results in the table being dropped!


Please describe a way to repeat the problem.   Please try to provide a
concise reproducible example, if at all possible: 
----------------------------------------------------------------------

Execute the following commands:

 createdb copytest
 echo 'CREATE TABLE copytest (f1 INTEGER, f2 INTEGER);' psql copytest
 echo 'CREATE UNIQUE INDEX copytest_idx ON copytest USING BTREE (f1, f2);' psql copytest
 ecpg copy.pgc
 gcc copy.c -I /usr/include/pgsql -lecpg -lpq
 ./a.out

Which will result in the following output from 'a.out':

 Error -400: 'ERROR:  Relation 'copytest' does not exist' in line 17.

given the following source 'copytest.pgc':

 #include <stdlib.h>
 #include <time.h>
 #include <sys/time.h>
 #include <unistd.h>

 EXEC SQL INCLUDE sqlca;

 int main(int argc, char **argv)
 {
  EXEC SQL CONNECT TO copytest;
  if( sqlca.sqlcode != 0 )
    return( 1 );

  EXEC SQL TRUNCATE TABLE copytest;
  if( sqlca.sqlcode < 0 )
    return( 1 );

  EXEC SQL COPY copytest FROM '/tmp/copytest';
  if( sqlca.sqlcode < 0 )
    {
      printf("Error %ld: %s\n", sqlca.sqlcode, sqlca.sqlerrm.sqlerrmc);
      return( 1 );
    }

  EXEC SQL COMMIT;
  EXEC SQL DISCONNECT;

  return( 0 );
 }

and the following '/tmp/copytest' (not used):

 1	1
 2	2
 3	3
 4	4
 5	5
 6	6

If you add an 'EXEC SQL COMMIT' after the TRUNCATE and then do a '\d'
in psql the table is not shown - it has been dropped.

If you know how this problem might be fixed, list the solution below:
---------------------------------------------------------------------



^ permalink  raw  reply  [nested|flat] 2+ messages in thread

* Re: ESQL/C TRUNCATE TABLE results in DROP TABLE
  2001-10-01 10:27 ESQL/C TRUNCATE TABLE results in DROP TABLE Lee Kindness <lkindness@csl.co.uk>
@ 2001-10-01 11:50 ` Michael Meskes <meskes@postgresql.org>
  0 siblings, 0 replies; 2+ messages in thread

From: Michael Meskes @ 2001-10-01 11:50 UTC (permalink / raw)
  To: Lee Kindness <lkindness@csl.co.uk>; +Cc: pgsql-interfaces

On Mon, Oct 01, 2001 at 11:27:47AM +0100, Lee Kindness wrote:
> 'TRUNCATE TABLE' in embedded SQL results in the table being dropped!

Argh! This comes from using cut & paste and forgetting to edit. 

Fix will be uploaded in a few minutes.

Michael
-- 
Michael Meskes
Michael@Fam-Meskes.De
Go SF 49ers! Go Rhein Fire!
Use Debian GNU/Linux! Use PostgreSQL!



^ permalink  raw  reply  [nested|flat] 2+ messages in thread


end of thread, other threads:[~2001-10-01 11:50 UTC | newest]

Thread overview: 2+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2001-10-01 10:27 ESQL/C TRUNCATE TABLE results in DROP TABLE Lee Kindness <lkindness@csl.co.uk>
2001-10-01 11:50 ` Michael Meskes <meskes@postgresql.org>

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox