Received: from mail.csl.co.uk (internet.csl.co.uk [194.130.52.3]) by postgresql.org (8.11.3/8.11.4) with ESMTP id f91ARq327955; Mon, 1 Oct 2001 06:27:52 -0400 (EDT) (envelope-from lkind@csl.co.uk) Received: from euphrates.csl.co.uk by mail.csl.co.uk (8.11.1/ConceptO 2.3) id f91ARoS18380; Mon, 1 Oct 2001 11:27:50 +0100 Received: from elsick.csl.co.uk by euphrates.csl.co.uk (8.9.3/ConceptI 2.4) id LAA12703; Mon, 1 Oct 2001 11:27:48 +0100 (BST) Received: by elsick.csl.co.uk (8.11.0) id f91ARl813500; Mon, 1 Oct 2001 11:27:47 +0100 From: Lee Kindness MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Message-ID: <15288.17699.564891.383422@elsick.csl.co.uk> Date: Mon, 1 Oct 2001 11:27:47 +0100 (BST) To: pgsql-bugs@postgresql.org Subject: ESQL/C TRUNCATE TABLE results in DROP TABLE X-Mailer: VM 6.75 under 21.1 (patch 14) "Cuyahoga Valley" XEmacs Lucid Cc: lkindness@csl.co.uk, pgsql-interfaces@postgresql.org X-Archive-Number: 200110/1 X-Sequence-Number: 2373 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 #include #include #include 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: ---------------------------------------------------------------------