Обсуждение: BUG #3943: ecpg doesn't like "inet" operator

Поиск
Список
Период
Сортировка

BUG #3943: ecpg doesn't like "inet" operator

От
"Arnaud"
Дата:
The following bug has been logged online:

Bug reference:      3943
Logged by:          Arnaud
Email address:      arnaud.desmier@free.fr
PostgreSQL version: 8.3.0
Operating system:   linux debian etch
Description:        ecpg doesn't like "inet" operator
Details:

This is a sample of my C programm resuming the problem :

***************************************************
#include <stdio.h>
#include <stdlib.h>

int main()
{
  EXEC SQL BEGIN DECLARE SECTION;

  char *ip_address = "192.168.1.2";
  char ip_result[20];

  EXEC SQL END DECLARE SECTION;

  EXEC SQL WHENEVER SQLWARNING SQLPRINT;

  EXEC SQL CONNECT TO synch@localhost USER synch IDENTIFIED BY  synch;

  EXEC SQL SELECT text(inet :ip_address) INTO :ip_result;

  EXEC SQL DISCONNECT;

  printf("ip_result: %s\n", ip_result);

  return EXIT_SUCCESS;
}

***************************************************

And ecpg returns :
  test_sql.pgc:17: ERROR: syntax error at or near ":ip_address"

This error correpond with "EXEC SQL SELECT inet :ip_address;". If I remove
inet operator it works well. Of course text() does nothing when I remove
inet as postgres doesn't now it is an IP address.

Re: BUG #3943: ecpg doesn't like "inet" operator

От
Tom Lane
Дата:
"Arnaud" <arnaud.desmier@free.fr> writes:
>   EXEC SQL SELECT text(inet :ip_address) INTO :ip_result;

This is incorrect, and always has been, but 8.3 is more picky about it.
Use a cast instead, eg

>   EXEC SQL SELECT text(:ip_address :: inet) INTO :ip_result;

            regards, tom lane