ESQL/C TRUNCATE TABLE results in DROP TABLE
ESQL/C TRUNCATE TABLE results in DROP TABLE
От:
Lee Kindness <lkindness@csl.co.uk>
Дата:
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 copytestecho 'CREATE TABLE copytest (f1 INTEGER, f2 INTEGER);' psql copytestecho 'CREATE UNIQUE INDEX copytest_idx ON copytest USING BTREE (f1, f2);' psql copytestecpg copy.pgcgcc 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 12 23 34 45 56 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:
---------------------------------------------------------------------
Re: ESQL/C TRUNCATE TABLE results in DROP TABLE
От:
Michael Meskes <meskes@postgresql.org>
Дата:
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!