ERROR: cache lookup failed for type 0

Ask a Question related to PostgreSQL / PGSQL, Design and Development.

  1. #1

    Default Re: ERROR: cache lookup failed for type 0

    Tzahi Fadida <tzahi_ml@myrealbox.com> writes:
    > It still doesn't work. btw, I am using 8rc2.
    Um. The "clean" way to do this is to use BlessTupleDesc and then
    heap_formtuple. That requires you to break down the original tuple
    into fields (see heap_deformtuple). Alternatively you could poke
    the datatype ID fields directly into the copied tuple.

    regards, tom lane

    ---------------------------(end of broadcast)---------------------------
    TIP 9: the planner will ignore your desire to choose an index scan if your
    joining column's datatypes do not match

    Tom Lane Guest

  2. Similar Questions and Discussions

    1. cfquery cache stores failed queries
      cfquery cache still stores failed queries. This was reported years ago...
    2. FreeDB lookup error with Audio::CD
      When I do a $cddb->lookup() twice in a row for the same disk, the second lookup fails. Short demo: #!/usr/bin/perl -w use strict; use...
    3. returning a setof tuples like a subquery was(ERROR:cache lookup failed for type 0 )
      yes you were right it works now. 10x, sorry for the rookie mistake I jumped the gun on the last one. If you will i have another question on the...
    4. ERROR: cache lookup failed for type 0
      Hi, I am learning how to use the c functions and my function below works when I do: select testgetrows(); but when I do select * from...
    5. midl\oleaut32.dll : error MIDL2020 : error generating type library : LayOut failed : IXMLDOMNode
      Hi there Im new to C++ and have inherited a C++ dll that wont compile. Its coplaing about the following midl\oleaut32.dll : error MIDL2020 :...
  3. #2

    Default Re: ERROR: cache lookup failed for type 0

    well, I tried the heap_deformtuple and I am getting now:
    select testgetrows();
    server closed the connection unexpectedly
    This probably means the server terminated abnormally
    before or while processing the request.
    The connection to the server was lost. Attempting reset: Failed.
    !>

    btw, as can be seen below I tried two kinds of tupledesc just in case
    with the same results.
    /*funcctx->tuple_desc= BlessTupleDesc(fctx->lRel->rd_att);*/
    funcctx->tuple_desc=BlessTupleDesc(RelationNameGetTupleDes c("my_first_ta
    ble"));

    #include "postgres.h"
    #include <string.h>
    #include <array.h>
    #include "fmgr.h"
    #include "funcapi.h"
    #include "access/heapam.h"

    typedef struct
    {
    HeapScanDesc scan;
    Relation lRel;
    } testgetrows_fctx;

    PG_FUNCTION_INFO_V1(testgetrows);

    Datum
    testgetrows(PG_FUNCTION_ARGS)
    {
    FuncCallContext *funcctx;
    testgetrows_fctx *fctx;
    if (SRF_IS_FIRSTCALL())
    {
    MemoryContext oldcontext;
    funcctx = SRF_FIRSTCALL_INIT();

    oldcontext =
    MemoryContextSwitchTo(funcctx->multi_call_memory_ctx);
    fctx = (testgetrows_fctx *) palloc(sizeof(testgetrows_fctx));
    fctx->lRel = heap_open(17236, AccessShareLock);
    fctx->scan = heap_beginscan(fctx->lRel, SnapshotNow, 0, NULL);

    /*funcctx->tuple_desc= BlessTupleDesc(fctx->lRel->rd_att);*/

    funcctx->tuple_desc=BlessTupleDesc(RelationNameGetTupleDes c("my_first_ta
    ble"));

    funcctx->user_fctx = fctx;
    MemoryContextSwitchTo(oldcontext);
    }

    funcctx = SRF_PERCALL_SETUP();
    fctx = funcctx->user_fctx;

    HeapTuple tuple;
    tuple = heap_getnext(fctx->scan, ForwardScanDirection);
    if (HeapTupleIsValid(tuple))
    {

    Datum result;
    Datum *values;
    HeapTuple tupleCopy;
    HeapTuple tupleCopy2;
    char *nulls = (char *)palloc(funcctx->tuple_desc->natts *
    sizeof(char));

    tupleCopy = heap_copytuple(tuple);
    heap_deformtuple(tuple,funcctx->tuple_desc,values,nulls);
    tupleCopy2 = heap_formtuple(funcctx->tuple_desc,values,nulls);
    result = HeapTupleGetDatum(tupleCopy2);

    SRF_RETURN_NEXT(funcctx, result);

    }
    else /* do when there is no more left */
    {
    heap_endscan(fctx->scan);
    heap_close(fctx->lRel, AccessShareLock);

    SRF_RETURN_DONE(funcctx);
    }
    }
    Regards,
    tzahi.
    > -----Original Message-----
    > From: Tom Lane [mailto:tgl@sss.pgh.pa.us]
    > Sent: Friday, January 07, 2005 10:31 PM
    > To: Tzahi Fadida
    > Cc: [email]pgsql-general@postgresql.org[/email]
    > Subject: Re: [GENERAL] ERROR: cache lookup failed for type 0
    >
    >
    > Tzahi Fadida <tzahi_ml@myrealbox.com> writes:
    > > It still doesn't work. btw, I am using 8rc2.
    >
    > Um. The "clean" way to do this is to use BlessTupleDesc and
    > then heap_formtuple. That requires you to break down the
    > original tuple into fields (see heap_deformtuple).
    > Alternatively you could poke the datatype ID fields directly
    > into the copied tuple.
    >
    > regards, tom lane
    >
    >


    ---------------------------(end of broadcast)---------------------------
    TIP 3: if posting/reading through Usenet, please send an appropriate
    subscribe-nomail command to [email]majordomo@postgresql.org[/email] so that your
    message can get through to the mailing list cleanly

    Tzahi Fadida Guest

  4. #3

    Default Re: ERROR: cache lookup failed for type 0

    Tzahi Fadida <tzahi_ml@myrealbox.com> writes:
    > well, I tried the heap_deformtuple and I am getting now:
    > select testgetrows();
    > server closed the connection unexpectedly
    You didn't palloc the values array. Any reasonable compiler would have
    warned you about that BTW. If you don't have compiler warnings enabled,
    learn to use them.

    Also, I'd recommend using the tupledesc from the just-opened lRel;
    fetching it via an independent path is just asking for trouble.

    regards, tom lane

    ---------------------------(end of broadcast)---------------------------
    TIP 7: don't forget to increase your free space map settings

    Tom Lane Guest

  5. #4

    Default Re: ERROR: cache lookup failed for type 0

    Tom Lane <tgl@sss.pgh.pa.us> writes:
    > Tzahi Fadida <tzahi_ml@myrealbox.com> writes:
    > > well, I tried the heap_deformtuple and I am getting now:
    > > select testgetrows();
    > > server closed the connection unexpectedly
    >
    > You didn't palloc the values array. Any reasonable compiler would have
    > warned you about that BTW. If you don't have compiler warnings enabled,
    > learn to use them.
    I think with gcc this type of warning is only enabled when you're compiling
    with optimizations. Most people don't compile with optimizations enabled when
    developing.

    --
    greg


    ---------------------------(end of broadcast)---------------------------
    TIP 1: subscribe and unsubscribe commands go to [email]majordomo@postgresql.org[/email]

    Greg Stark Guest

  6. #5

    Default Re: ERROR: cache lookup failed for type 0

    Greg Stark <gsstark@mit.edu> writes:
    > Tom Lane <tgl@sss.pgh.pa.us> writes:
    >> You didn't palloc the values array. Any reasonable compiler would have
    >> warned you about that BTW. If you don't have compiler warnings enabled,
    >> learn to use them.
    > I think with gcc this type of warning is only enabled when you're compiling
    > with optimizations. Most people don't compile with optimizations enabled when
    > developing.
    Pretty much the first thing you learn when developing with gcc is to use
    -O1 -Wall for compiling devel code. Gets all the warnings and doesn't
    confuse gdb too badly. Once in a long while I'll recompile an
    individual file with -O0 so that I can single-step through it more
    easily, but 99.44% of the time I'd rather have the
    uninitialized-variable warning.

    regards, tom lane

    ---------------------------(end of broadcast)---------------------------
    TIP 1: subscribe and unsubscribe commands go to [email]majordomo@postgresql.org[/email]

    Tom Lane Guest

Posting Permissions

  • You may not post new threads
  • You may post replies
  • You may not post attachments
  • You may not edit your posts

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139