ESQL-C INSERT Problem

From: pgsql-bugs(at)postgresql(dot)org
To: pgsql-bugs(at)postgresql(dot)org
Subject: ESQL-C INSERT Problem
Date: 2000-10-20 17:53:09
Message-ID: 200010201753.e9KHr9e63799@hub.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

Sascha Demetrio (sd(at)b-comp(dot)de) reports a bug with a severity of 2
The lower the number the more severe it is.

Short Description
ESQL-C INSERT Problem

Long Description
An embedded SQL/C program INSERT operation fails, if a string value
submitted through a host variable ends with a backslash character.
This bug is not triggered if the offending variable is the last
variable in the INSERT statement.

Running the test program (below) results in the following output:

internal error: SQL error: Too many arguments in line 18.

The program works if you remove the trailing backslash from `f1'.

Version Info:
OS: Linux / glibc-2.1.3
PostgreSQL 7.0.2 on i586-pc-linux-gnu, compiled by gcc 2.95.2

Sample Code
Table:

CREATE TABLE t1 ( f1 CHAR(10), f2 CHAR(10) );

ESQL/C Code:

--BEGIN-FILE--
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

EXEC SQL INCLUDE sqlca;

int main(void)
{
EXEC SQL BEGIN DECLARE SECTION;
char f1[11];
char f2[11];
EXEC SQL END DECLARE SECTION;

EXEC SQL WHENEVER SQLERROR GOTO sql_error;
EXEC SQL CONNECT TO testdb;
strcpy(f1, "something\\");
strcpy(f2, "FOO");
EXEC SQL INSERT INTO t1 ( f1, f2 )
VALUES ( :f1, :f2 );
EXEC SQL COMMIT WORK;
EXEC SQL DISCONNECT;
return 0;
sql_error:
EXEC SQL WHENEVER SQLERROR STOP;
fprintf(stderr, "internal error: SQL error: %s",
sqlca.sqlerrm.sqlerrml
? sqlca.sqlerrm.sqlerrmc : "unknown error");
EXEC SQL ROLLBACK;
EXEC SQL DISCONNECT;
return -1;
}
--END-FILE--

No file was uploaded with this report

Browse pgsql-bugs by date

  From Date Subject
Next Message Sam Hokin 2000-10-21 05:33:16 bug in to_char(timestamp, text) for times between 12:00 and 14:00
Previous Message Pam Withnall 2000-10-20 00:31:00 largeobject.write(byte[] buf)