Skip site navigation (1) Skip section navigation (2)

Re: Version 1 Calling convention

From: "Jasbinder Bali" <jsbali(at)gmail(dot)com>
To: pgsql-general(at)postgresql(dot)org, pgsql-novice(at)postgresql(dot)org
Subject: Re: Version 1 Calling convention
Date: 2006-08-30 09:38:34
Message-ID: a47902760608300238o6f6415b6wce64b472c7acd068@mail.gmail.com (view raw or flat)
Thread:
Lists: pgsql-generalpgsql-novice
PG_FUNCTION_INFO_V1 (test);

Datum
test (PG_FUNCTION_ARGS)
{
           int id = PG_GETARG_INT(0);
           char *raw_rawemail1 = PG_GETARG_CHAR_P(1); //line 6 (warning
thrown for this line)
           char *rawemail1 = (char *)  palloc (VARSIZE(rawemail1));
           VARATT_SIZEP ( rawemail1 ) = VARSIZE (raw_rawemail1); //LINE 140
(thats where i get syntax error)
           memcpy( (void *) (VARDATA) (rawemail1), (void *) (VARDATA)
(raw_rawemail1) , (VARSIZE) (raw_rawemail1) - VARHDRSZ );

}

Was trying to test the code given in the postgres manual.
The only diff being that i changed the data type from text* to char* and it
gives me a warning like:

"initialization makes pointer from integer without a cast" at line 6 as
commented above.

Can any1 point why?

~Jas
Compiling this code gives me the follwoing error:


Compiling this code throws the follwoing error
On 8/30/06, Jasbinder Bali <jsbali(at)gmail(dot)com> wrote:
>
> I have a .pgc file and i have the following code snippet in it:
>
> PG_FUNCTION_INFO_V1 (test);
>
> Datum
> test (PG_FUNCTION_ARGS)
> {
>   EXEC SQL BEGIN DECLARE SECTION;
>            int id = PG_GETARG_INT(0);
>            char *raw_rawemail1 = PG_GETARG_CHAR_P(1);
>            char *rawemail1 = (char *)  palloc (VARSIZE(rawemail1));
>            VARATT_SIZEP ( rawemail1 ) = VARSIZE (raw_rawemail1); //LINE
> 140 (thats where i get syntax error)
>            memcpy( (void *) (VARDATA) (rawemail1), (void *) (VARDATA)
> (raw_rawemail1) , (VARSIZE) (raw_rawemail1) - VARHDRSZ );
>   EXEC SQL END DECLARE SECTION;
>
>   EXEC SQL CONNECT TO dbxyz;
> }
>
> When I compile this using
> ECPG parser.pgc
>
> I get the follwing error
>
> Syntax error at or near 'rawemail1' (LINE 140 marked above)
>
> Don't know what this error is all about.
> Don't know if my declaration in BEGIN END block is correct in the pgc file
> for version 1 calling convention
>
> Thanks
> ~Jas
>

In response to

Responses

pgsql-novice by date

Next:From: Martijn van OosterhoutDate: 2006-08-30 10:00:03
Subject: Re: Version 1 Calling convention
Previous:From: Martijn van OosterhoutDate: 2006-08-30 08:37:53
Subject: Re: Version 1 Calling convention

pgsql-general by date

Next:From: Post GresDate: 2006-08-30 09:50:38
Subject: Query for order of tables
Previous:From: Devrim GUNDUZDate: 2006-08-30 09:12:30
Subject: Status on Fedora Core Extras packaging

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group