~psycopg/psycopg/2.0.x

« back to all changes in this revision

Viewing changes to psycopg/pqpath.c

  • Committer: Federico Di Gregorio
  • Date: 2005-01-20 05:49:40 UTC
  • Revision ID: fog-7e871bddd10637cd35a35849556d0b49b4be53b4
License changes. Fixes. Added register_adapter().

Show diffs side-by-side

added added

removed removed

Lines of Context:
538
538
        /* 4,5/ scale and precision */
539
539
        if (ftype == NUMERICOID) {
540
540
            PyTuple_SET_ITEM(dtitem, 4, PyInt_FromLong((fmod >> 16) & 0xFFFF));
541
 
            PyTuple_SET_ITEM(dtitem, 5, PyInt_FromLong(fmod & 0xFFFF));
 
541
            PyTuple_SET_ITEM(dtitem, 5, PyInt_FromLong(fmod & 0xFFFF) - 4);
542
542
        }
543
543
        else {
544
544
            Py_INCREF(Py_None);
557
557
 
558
558
#ifdef HAVE_PQPROTOCOL3
559
559
static int
560
 
_pq_copy_in(cursorObject *curs)
 
560
_pq_copy_in_v3(cursorObject *curs)
561
561
{
562
562
    /* COPY FROM implementation when protocol 3 is available: this function
563
563
       uses the new PQputCopyData() and can detect errors and set the correct
565
565
    
566
566
    return -1;
567
567
}
568
 
#else
 
568
#endif
569
569
static int
570
570
_pq_copy_in(cursorObject *curs)
571
571
{
589
589
 
590
590
    return 1;
591
591
}
592
 
#endif
593
592
 
594
593
#ifdef HAVE_PQPROTOCOL3
595
594
static int
596
 
_pq_copy_out(cursorObject *curs)
 
595
_pq_copy_out_v3(cursorObject *curs)
597
596
{
598
597
    char *buffer;
599
598
    int len;
620
619
 
621
620
    return 1;
622
621
}
623
 
#else
 
622
#endif
 
623
 
624
624
static int
625
625
_pq_copy_out(cursorObject *curs)
626
626
{
655
655
    
656
656
    return 1;
657
657
}
658
 
#endif
 
658
 
659
659
 
660
660
int
661
661
pq_fetch(cursorObject *curs)
747
747
    case PGRES_COPY_OUT:
748
748
        Dprintf("pq_fetch: data from a COPY TO (no tuples)");
749
749
        curs->rowcount = 0;
750
 
        ex = _pq_copy_out(curs);
 
750
#ifdef HAVE_PQPROTOCOL3
 
751
        if (curs->conn->protocol == 3)
 
752
            ex = _pq_copy_out_3(curs);
 
753
        else
 
754
#endif
 
755
            ex = _pq_copy_out(curs);
751
756
        /* error caught by out glorious notice handler */
752
757
        if (PyErr_Occurred()) ex = -1;
753
758
        IFCLEARPGRES(curs->pgres);
756
761
    case PGRES_COPY_IN:
757
762
        Dprintf("pq_fetch: data from a COPY FROM (no tuples)");
758
763
        curs->rowcount = 0;
759
 
        ex = _pq_copy_in(curs);
 
764
#ifdef HAVE_PQPROTOCOL3
 
765
        if (curs->conn->protocol == 3)        
 
766
            ex = _pq_copy_in_v3(curs);
 
767
        else
 
768
#endif
 
769
            ex = _pq_copy_in(curs);
760
770
        /* error caught by out glorious notice handler */
761
771
        if (PyErr_Occurred()) ex = -1;
762
772
        IFCLEARPGRES(curs->pgres);