Nous utilisons des cookies pour vous garantir la meilleure expérience sur notre site. Si vous continuez à utiliser ce dernier, nous considèrerons que vous acceptez l'utilisation des cookies. J'ai compris ! ou En savoir plus !.
banniere

Le portail francophone de la géomatique


Toujours pas inscrit ? Mot de passe oublié ?
Nom d'utilisateur    Mot de passe              Toujours pas inscrit ?   Mot de passe oublié ?

Annonce

Printemps des cartes 2024

#1 Thu 15 April 2010 23:45

ahmedamin
Juste Inscrit !
Date d'inscription: 15 Apr 2010
Messages: 2

Postgresql new base type

Hi
I'm writing new basic type written with C with postgresql, this is a geospatial type which contains timestamp,char * and spatial(point,linestring) attributes.
I tried the complex example and it works well on postgresql server 8.3 but when I made my type I have problems with input and output functions,
The type should be like that

typedef struct mytype
{
    char *        type;
    timestamp*         te;
    timestamp*         ts;
    geometry *       l;
}    Mytype;

I don't what libraries should be included to get timestamp type

Datum
mytype_in(PG_FUNCTION_ARGS)
{
    char       *str = PG_GETARG_CSTRING(0);
    char        *l1,*te1,*ts1;
    char        *type1 ;
    Mytype*result;
   

    if (sscanf(str, "( %s )", type1, te1,ts1,l1) != 4)
        ereport(ERROR,
                (errcode(ERRCODE_INVALID_TEXT_REPRESENTATION),
                 errmsg("invalid input syntax for mytype: \"%s\"",
                        str)));

    result = (Mytype*) palloc(sizeof(Mytype));
   
    result->te = te1;
    result->ts = ts1;
    result->type = type1;
    PG_RETURN_POINTER(result);
}

PG_FUNCTION_INFO_V1(mytype_out);

Datum
mytype_out(PG_FUNCTION_ARGS)
{
    Mytype *mytype= (Mytype*) PG_GETARG_POINTER(0);
    char       *result;

    result = (char *) palloc(1000);
    snprintf(result, 100, "( %s , %s , %s , %s )",mytype ->type, mytype->te,mytype->ts,mytype->l);
    PG_RETURN_CSTRING(result);
}

Please tell me what's wrong with this definition, there is no compilation problem, I created a table with mytype attribute insert works well but when I select data from this table postgresql server goes down and restart

Thank you in advance


Best Regards
SETHOM Ahmed Amin
Mobile: + 216 40 175 841 begin_of_the_skype_highlighting              + 216 40 175 841      end_of_the_skype_highlighting

Hors ligne

 

#2 Fri 16 April 2010 01:40

ThomasG
Membre
Lieu: Nantes
Date d'inscription: 9 Sep 2005
Messages: 943
Site web

Re: Postgresql new base type

Hello,

I'm  not sure it's the best place for asking this kind of things : you are on a francophone forum.
Moreover, most people on this forum are gis proficient but don't really do programmation.
Someone can answer you, maybe...

Have a look on the Postgis-users mailinglist ( http://postgis.refractions.net/mailman/ … tgis-users ) or on the postgresql mailinglists ( http://archives.postgresql.org/) and post your question. You will get further answers from PostgreSQL experts compare to here.

Regards


ThomasG

PS: You're always welcome but in french, please wink

Hors ligne

 

#3 Fri 16 April 2010 09:01

ahmedamin
Juste Inscrit !
Date d'inscription: 15 Apr 2010
Messages: 2

Re: Postgresql new base type

Merci Thomas

J'ai bien postulé un message dabns la liste mailing de postgresql et je suis en attente d'une réponse. smile

Hors ligne

 

Pied de page des forums

Powered by FluxBB