Menu

#29 varchar column > 255 characters truncated

open
nobody
None
5
2016-11-03
2009-06-19
nobdy
No

0.39/svn, on Linux against Sybase 12.5

If a varchar column is longer than (and filled with more than) 255 bytes, then the select statement returns the content of that column truncated to 255 bytes.

Setting in sybasect.c the version

int version = CS_VERSION_125;

however will change the behaviour and the full content is returned. We have tried to change only Sybase.py from
if _ctx.ct_init() != CS_SUCCEED:
to
if _ctx.ct_init(12500) != CS_SUCCEED:

as it had been suggested to us, but this did not bring the hoped result neither in 0.39 nor in the svn tree.

Related

Bugs: #29

Discussion

  • Igor Shurshin

    Igor Shurshin - 2015-11-27

    Just came across the same issue.
    Here's how I fixed it locally. Instead of hardcoding a specific version I just put the current one. Definition found in $SYBASE/$SYBASE_OCS/include/cspublic.h
    So this line works for me [v0.40, file: sybasect.c, function: sybasect_cs_ctx_alloc]:

    173: int version = CS_CURRENT_VERSION;
    
     

    Last edit: Igor Shurshin 2015-11-27
  • Gregory Bond

    Gregory Bond - 2016-10-18

    This has an easy fix in Python-level code (assuming you use at least version 12.5 of ctlib):

    Index: Sybase.py

    --- Sybase.py (revision 6648)
    +++ Sybase.py (working copy)
    @@ -298,7 +298,7 @@

    # Setup global library context
    -status, _ctx = cs_ctx_alloc()
    +status, _ctx = cs_ctx_alloc(CS_VERSION_125)
    if status != CS_SUCCEED:
    raise InternalError('cs_ctx_alloc failed')
    #_ctx.debug = 0

     
  • Gregory Bond

    Gregory Bond - 2016-11-03

    Above patch to Sybase.py works for reading long data from the DB but not uploading long data. See patch #13 for a more complete solution.

     
  • Robert Boehne

    Robert Boehne - 2016-11-03

    I maintained Python Sybase while at a previous employer, but I no longer have access to a Sybase server. If someone would like to take over I would be happy to give someone the permissions.

    Thanks
    Robert Boehne

    On Nov 3, 2016 1:49 AM, Gregory Bond gnbond@users.sf.net wrote:

    Above patch to Sybase.py works for reading long data from the DB but not uploading long data. See patch #13 for a more complete solution.


    [bugs:#29]https://sourceforge.net/p/python-sybase/bugs/29/ varchar column > 255 characters truncated

    Status: open
    Group:
    Created: Fri Jun 19, 2009 01:43 PM UTC by nobdy
    Last Updated: Tue Oct 18, 2016 11:37 PM UTC
    Owner: nobody

    0.39/svn, on Linux against Sybase 12.5

    If a varchar column is longer than (and filled with more than) 255 bytes, then the select statement returns the content of that column truncated to 255 bytes.

    Setting in sybasect.c the version

    int version = CS_VERSION_125;

    however will change the behaviour and the full content is returned. We have tried to change only Sybase.py from
    if _ctx.ct_init() != CS_SUCCEED:
    to
    if _ctx.ct_init(12500) != CS_SUCCEED:

    as it had been suggested to us, but this did not bring the hoped result neither in 0.39 nor in the svn tree.


    Sent from sourceforge.net because you indicated interest in https://sourceforge.net/p/python-sybase/bugs/29/

    To unsubscribe from further messages, please visit https://sourceforge.net/auth/subscriptions/

     

    Related

    Bugs: #29


Log in to post a comment.