Thread: Application crash after error

Application crash after error

From
"Andrus"
Date:
I'm using 8.1.1 Unicode driver with Microsoft Visual FoxPro 9

1. I try to insert a row containing duplicate key
2. ODBC driver returns error message
3. After that FoxPro crashes with access violation error

If error is not returned from ODBC driver to FoxPro, all is OK.
This problem is reproducible always.

How to fix this ?

Andrus.



Re: Application crash after error

From
Ludek Finstrle
Date:
> I'm using 8.1.1 Unicode driver with Microsoft Visual FoxPro 9

What is FoxPro doing againist another SQL Server?
Has ANSI driver same behaviour?

> 1. I try to insert a row containing duplicate key
> 2. ODBC driver returns error message
> 3. After that FoxPro crashes with access violation error
>
> If error is not returned from ODBC driver to FoxPro, all is OK.
> This problem is reproducible always.

I don't understand well. Do you make changes in psqlodbc source code?
Or what exactly do you mean with "If error is not returned from ODBC
driver to FoxPro, all is OK."

> How to fix this ?

Good first step is posting mylog output form psqlodbc driver.
Don't you have some bad code after failing insert?

Luf

Re: Application crash after error

From
"Andrus"
Date:
Luf,

> What is FoxPro doing againist another SQL Server?

I do'nt have MS SQL server installed. However, a lot of people are using
FoxPro with MS SQL server through ODBC without problems.

> Has ANSI driver same behaviour?

Yes.  When using ANSI driver, I got an error

Connectivity error: Error while executing the query;
ERROR:  invalid UTF-8 byte sequence detected near byte 0xdc

and after selecting Ignore my appl crashes with access violation (C0000005)
error

>> 1. I try to insert a row containing duplicate key
>> 2. ODBC driver returns error message
>> 3. After that FoxPro crashes with access violation error
>>
>> If error is not returned from ODBC driver to FoxPro, all is OK.
>> This problem is reproducible always.
>
> I don't understand well. Do you make changes in psqlodbc source code?

No. I use pre-compiled binary.

> Or what exactly do you mean with "If error is not returned from ODBC
> driver to FoxPro, all is OK."

If the row to be added has customer name which does not exist in table, this
customer is added without any problems.
if customer exists, postgres returns  duplicate index error and my appl
crashes after some commands.

> Good first step is posting mylog output form psqlodbc driver.

log file starts with lines:

[2388]globals.extra_systable_prefixes = 'dd_;'
[2388][[SQLAllocHandle]][2388]**** in PGAPI_AllocEnv **
[2388]** exit PGAPI_AllocEnv: phenv = 45299288 **
[2388][[SQLSetEnvAttr]] att=200,2
[2388][[SQLAllocHandle]][2388]PGAPI_AllocConnect: entering...
[2388]**** PGAPI_AllocConnect: henv = 45299288, conn = 45299344
[2388]EN_add_connection: self = 45299288, conn = 45299344
[2388]       added at i =0, conn->henv = 45299288, conns[i]->henv = 45299288
[2388][SQLGetInfo(30)][2388]PGAPI_GetInfo: entering...fInfoType=77
[2388]PGAPI_GetInfo: p='03.00', len=5, value=0, cbMax=12
[2388][[SQLSetConnectAttr]] 102
[2388]PGAPI_SetConnectAttr 102
[2388]PGAPI_SetConnectOption: entering fOption = 102 vParam = 1
[2388][[SQLSetConnectAttr]] 103
[2388]PGAPI_SetConnectAttr 103
[2388]PGAPI_SetConnectOption: entering fOption = 103 vParam = 15
[2388][[SQLSetConnectAttr]] 112
[2388]PGAPI_SetConnectAttr 112
[2388]PGAPI_SetConnectOption: entering fOption = 112 vParam = 4096
[2388][SQLDriverConnect][2388]PGAPI_DriverConnect: entering...
[2388]**** PGAPI_DriverConnect: fDriverCompletion=1,
connStrIn='DRIVER={PostgreSQL
ANSI};UID=postgres;PWD=xxxx;DATABASE=eeva;SERVER=localhost;PORT=5432;B9=0;'
[2388]our_connect_string = 'DRIVER={PostgreSQL
ANSI};UID=postgres;PWD=xxxx;DATABASE=eeva;SERVER=localhost;PORT=5432;B9=0;'
[2388]attribute = 'DRIVER', value = '{PostgreSQL ANSI}'
[2388]copyAttributes:

DSN='',server='',dbase='',user='',passwd='xxxxx',port='',sslmode='',onlyread='',protocol='',conn_settings='',disallow_premature=-1)
[2388]attribute = 'UID', value = 'postgres'
[2388]copyAttributes:

DSN='',server='',dbase='',user='postgres',passwd='xxxxx',port='',sslmode='',onlyread='',protocol='',conn_settings='',disallow_premature=-1)
[2388]attribute = 'PWD', value = 'xxxxx'
[2388]copyAttributes:

DSN='',server='',dbase='',user='postgres',passwd='xxxxx',port='',sslmode='',onlyread='',protocol='',conn_settings='',disallow_premature=-1)
[2388]attribute = 'DATABASE', value = 'eeva'
[2388]copyAttributes:

DSN='',server='',dbase='eeva',user='postgres',passwd='xxxxx',port='',sslmode='',onlyread='',protocol='',conn_settings='',disallow_premature=-1)
[2388]attribute = 'SERVER', value = 'localhost'
[2388]copyAttributes:

DSN='',server='localhost',dbase='eeva',user='postgres',passwd='xxxxx',port='',sslmode='',onlyread='',protocol='',conn_settings='',disallow_premature=-1)
[2388]attribute = 'PORT', value = '5432'
[2388]copyAttributes:

DSN='',server='localhost',dbase='eeva',user='postgres',passwd='xxxxx',port='5432',sslmode='',onlyread='',protocol='',conn_settings='',disallow_premature=-1)
[2388]attribute = 'B9', value = '0'
[2388]copyAttributes:

DSN='',server='localhost',dbase='eeva',user='postgres',passwd='xxxxx',port='5432',sslmode='',onlyread='',protocol='',conn_settings='',disallow_premature=-1)
[2388]our_connect_string = 'DRIVER={PostgreSQL
ANSI};UID=postgres;PWD=xxxx;DATABASE=eeva;SERVER=localhost;PORT=5432;B9=0;'
[2388]attribute = 'DRIVER', value = '{PostgreSQL ANSI}'
[2388]CopyCommonAttributes:
A7=100;A8=8192;A9=0;B0=254;B1=8190;B2=1;B3=0;B4=1;B5=1;B6=0;B7=1;B8=0;B9=1;C0=0;C1=0;C2=dd_;[2388]attribute
= 'UID', value = 'postgres'
[2388]CopyCommonAttributes:
A7=100;A8=8192;A9=0;B0=254;B1=8190;B2=1;B3=0;B4=1;B5=1;B6=0;B7=1;B8=0;B9=1;C0=0;C1=0;C2=dd_;[2388]attribute
= 'PWD', value = 'xxxxx'
[2388]CopyCommonAttributes:
A7=100;A8=8192;A9=0;B0=254;B1=8190;B2=1;B3=0;B4=1;B5=1;B6=0;B7=1;B8=0;B9=1;C0=0;C1=0;C2=dd_;[2388]attribute
= 'DATABASE', value = 'eeva'
[2388]CopyCommonAttributes:
A7=100;A8=8192;A9=0;B0=254;B1=8190;B2=1;B3=0;B4=1;B5=1;B6=0;B7=1;B8=0;B9=1;C0=0;C1=0;C2=dd_;[2388]attribute
= 'SERVER', value = 'localhost'
[2388]CopyCommonAttributes:
A7=100;A8=8192;A9=0;B0=254;B1=8190;B2=1;B3=0;B4=1;B5=1;B6=0;B7=1;B8=0;B9=1;C0=0;C1=0;C2=dd_;[2388]attribute
= 'PORT', value = '5432'
[2388]CopyCommonAttributes:
A7=100;A8=8192;A9=0;B0=254;B1=8190;B2=1;B3=0;B4=1;B5=1;B6=0;B7=1;B8=0;B9=1;C0=0;C1=0;C2=dd_;[2388]attribute
= 'B9', value = '0'
[2388]CopyCommonAttributes:
A7=100;A8=8192;A9=0;B0=254;B1=8190;B2=1;B3=0;B4=1;B5=1;B6=0;B7=1;B8=0;B9=0;C0=0;C1=0;C2=dd_;[2388]CC_connect:
entering...
[2388]CC_connect(): DSN = '', server = 'localhost', port = '5432', sslmode =
'prefer', database = 'eeva', username = 'postgres', password='xxxxx'
[2388]connecting to the server
[2388]connecting to the database  using localhost as the server
[2388]the size is 15
[2388]connection to the database succeeded.
[2388]connection to the database succeeded.
[2388]CC_lookup_pg_version: entering...
[2388]PGAPI_AllocStmt: entering...
[2388]**** PGAPI_AllocStmt: hdbc = 45299344, stmt = 45311192
[2388]CC_add_statement: self=45299344, stmt=45311192
[2388]PGAPI_ExecDirect: entering...
[2388]recycle statement: self= 45311192
[2388]PDATA_free_params:  ENTER, self=45311624
[2388]**** PGAPI_ExecDirect: hstmt=45311192, statement='select version()'
[2388]PGAPI_ExecDirect: calling PGAPI_Execute...
[2388]PGAPI_Execute: entering...
[2388]PGAPI_Execute: clear errors...
[2388]recycle statement: self= 45311192
[2388]PDATA_free_params:  ENTER, self=45311624
[2388]Exec_with_parameters_resolved: copying statement params:
trans_status=1, len=16, stmt='select version()'
[2388]   stmt_with_params = 'select version()'
[2388]       Sending SELECT statement on stmt=45311192,
cursor_name='SQL_CUR02B364D8'
[2388]send_query(): conn=45299344, query='select version()'
[2388]in QR_Constructor
[2388]exit QR_Constructor
[2388]in TL_Constructor
[2388]exit TL_Constructor
[2388]send_query: done sending query
[2388]QR_fetch_tuples: cursor = '', self->cursor=0
[2388]QR_fetch_tuples: past CI_read_fields: num_fields = 1
[2388]MALLOC: tuple_size = 100, size = 800
[2388]     done sending the query:
[2388]extend_column_bindings: entering ... self=45311328,
bindings_allocated=0, num_columns=1
[2388]exit extend_column_bindings
[2388]PGAPI_ExecDirect: returned 0 from PGAPI_Execute
[2388]PGAPI_Fetch: stmt = 45311192, stmt->result= 45315960
[2388]manual_result = 1, use_declarefetch = 0
[2388]**** SC_fetch: manual_result
[2388]extend_getdata_info: entering ... self=45311548, gdata_allocated=0,
num_columns=1
[2388]exit extend_gdata_info
[2388]fetch: cols=1, lf=0, opts = 45311328, opts->bindings = 45317208,
buffer[] = 0
[2388]PGAPI_GetData: enter, stmt=45311192
[2388]     value = 'PostgreSQL 8.1.0 on i686-pc-mingw32, compiled by GCC
gcc.exe (GCC) 3.4.2 (mingw-special)'
[2388]**** PGAPI_GetData: icol = 0, fCType = 1, field_type = 25, value =
'PostgreSQL 8.1.0 on i686-pc-mingw32, compiled by GCC gcc.exe (GCC) 3.4.2
(mingw-special)'
[2388]copy_and_convert: field_type = 25, fctype = 1, value = 'PostgreSQL
8.1.0 on i686-pc-mingw32, compiled by GCC gcc.exe (GCC) 3.4.2
(mingw-special)', cbValueMax=128
[2388]DEFAULT: len = 88, ptr = 'PostgreSQL 8.1.0 on i686-pc-mingw32,
compiled by GCC gcc.exe (GCC) 3.4.2 (mingw-special)'
[2388]    SQL_C_CHAR, default: len = 88, cbValueMax = 128, rgbValueBindRow =
'PostgreSQL 8.1.0 on i686-pc-mingw32, compiled by GCC gcc.exe (GCC) 3.4.2
(mingw-special)'
[2388]Got the PostgreSQL version string: 'PostgreSQL 8.1.0 on
i686-pc-mingw32, compiled by GCC gcc.exe (GCC) 3.4.2 (mingw-special)'
[2388]Extracted PostgreSQL version number: '8.1'
[2388]PGAPI_FreeStmt: entering...hstmt=45311192, fOption=1
[2388]QResult: in DESTRUCTOR
[2388]TupleList: in DESTRUCTOR
[2388]TupleList: exit DESTRUCTOR
[2388]QResult: free memory in, fcount=101
[2388]QResult: free memory out
[2388]QResult: exit DESTRUCTOR
[2388]SC_Destructor: self=45311192, self->result=0, self->hdbc=45299344
[2388]APD_free_params:  ENTER, self=45311444
[2388]IPD_free_params:  ENTER, self=45311508
[2388]PDATA_free_params:  ENTER, self=45311624
[2388]ARDFields_free 2b36560 bookmark=2b36720[2388]ARD_unbind_cols freeall=1
allocated=1 bindings=2b37c58
[2388]reset_a_column_binding: entering ... self=45311328,
bindings_allocated=1, icol=1
[2388]APD_free_params:  ENTER, self=45311444
[2388]IPD_free_params:  ENTER, self=45311508
[2388]GDATA_unbind_cols freeall=1 allocated=1 gdata=2b37c80
[2388]SC_Destructor: EXIT
[2388]CC_send_settings: entering...
[2388]PGAPI_AllocStmt: entering...
[2388]**** PGAPI_AllocStmt: hdbc = 45299344, stmt = 45311192
[2388]CC_add_statement: self=45299344, stmt=45311192
[2388]PGAPI_ExecDirect: entering...
[2388]recycle statement: self= 45311192
[2388]PDATA_free_params:  ENTER, self=45311624
[2388]**** PGAPI_ExecDirect: hstmt=45311192, statement='set DateStyle to
'ISO''
[2388]PGAPI_ExecDirect: calling PGAPI_Execute...
[2388]PGAPI_Execute: entering...
[2388]PGAPI_Execute: clear errors...
[2388]recycle statement: self= 45311192
[2388]PDATA_free_params:  ENTER, self=45311624
[2388]Exec_with_parameters_resolved: copying statement params:
trans_status=1, len=22, stmt='set DateStyle to 'ISO''
[2388]   stmt_with_params = 'set DateStyle to 'ISO''
[2388]      it's NOT a select statement: stmt=45311192
[2388]send_query(): conn=45299344, query='set DateStyle to 'ISO''
[2388]in QR_Constructor
[2388]exit QR_Constructor
[2388]The query was executed successfully and the query did not return any
result
[2388]send_query: done sending query
[2388]QR_fetch_tuples: cursor = '', self->cursor=0
[2388]QR_fetch_tuples: past CI_read_fields: num_fields = 0
[2388]MALLOC: tuple_size = 100, size = 0
[2388]PGAPI_ExecDirect: returned 0 from PGAPI_Execute
[2388]CC_send_settings: result 0, status 1 from set DateStyle
[2388]PGAPI_ExecDirect: entering...
[2388]recycle statement: self= 45311192
[2388]QResult: in DESTRUCTOR
[2388]QResult: free memory in, fcount=101
[2388]QResult: free memory out
[2388]QResult: exit DESTRUCTOR
[2388]PDATA_free_params:  ENTER, self=45311624
[2388]**** PGAPI_ExecDirect: hstmt=45311192, statement='set geqo to 'OFF''
[2388]PGAPI_ExecDirect: calling PGAPI_Execute...
[2388]PGAPI_Execute: entering...
[2388]PGAPI_Execute: clear errors...
[2388]recycle statement: self= 45311192
[2388]PDATA_free_params:  ENTER, self=45311624
[2388]Exec_with_parameters_resolved: copying statement params:
trans_status=1, len=17, stmt='set geqo to 'OFF''
[2388]   stmt_with_params = 'set geqo to 'OFF''
[2388]      it's NOT a select statement: stmt=45311192
[2388]send_query(): conn=45299344, query='set geqo to 'OFF''
[2388]in QR_Constructor
[2388]exit QR_Constructor
[2388]The query was executed successfully and the query did not return any
result
[2388]send_query: done sending query
[2388]QR_fetch_tuples: cursor = '', self->cursor=0
[2388]QR_fetch_tuples: past CI_read_fields: num_fields = 0
[2388]MALLOC: tuple_size = 100, size = 0
[2388]PGAPI_ExecDirect: returned 0 from PGAPI_Execute
[2388]CC_send_settings: result 0, status 1 from set geqo

Last lines in log file (before crash) are:

[2388]PGAPI_BindParamater: ipar=43, paramType=1, fCType=1, fSqlType=1,
cbColDef=10, ibScale=0, rgbValue=21729736, *pcbValue = 10, data_at_exec = 0
[2388][SQLBindParameter][2388]PGAPI_BindParameter: entering...
[2388]extend_parameter_bindings: entering ... self=45311444,
parameters_allocated=44, num_params=45
[2388]exit extend_parameter_bindings
[2388]extend_iparameter_bindings: entering ... self=45311508,
parameters_allocated=44, num_params=45
[2388]exit extend_iparameter_bindings
[2388]extend_putdata_info: entering ... self=45311624,
parameters_allocated=44, num_params=45
[2388]exit extend_putdata_info
[2388]PGAPI_BindParamater: ipar=44, paramType=1, fCType=99, fSqlType=1,
cbColDef=20, ibScale=0, rgbValue=21729736, *pcbValue = -1, data_at_exec = 0
[2388][SQLBindParameter][2388]PGAPI_BindParameter: entering...
[2388]extend_parameter_bindings: entering ... self=45311444,
parameters_allocated=45, num_params=46
[2388]exit extend_parameter_bindings
[2388]extend_iparameter_bindings: entering ... self=45311508,
parameters_allocated=45, num_params=46
[2388]exit extend_iparameter_bindings
[2388]extend_putdata_info: entering ... self=45311624,
parameters_allocated=45, num_params=46
[2388]exit extend_putdata_info
[2388]PGAPI_BindParamater: ipar=45, paramType=1, fCType=99, fSqlType=1,
cbColDef=4, ibScale=0, rgbValue=21729736, *pcbValue = -1, data_at_exec = 0
[2388][SQLBindParameter][2388]PGAPI_BindParameter: entering...
[2388]extend_parameter_bindings: entering ... self=45311444,
parameters_allocated=46, num_params=47
[2388]exit extend_parameter_bindings
[2388]extend_iparameter_bindings: entering ... self=45311508,
parameters_allocated=46, num_params=47
[2388]exit extend_iparameter_bindings
[2388]extend_putdata_info: entering ... self=45311624,
parameters_allocated=46, num_params=47
[2388]exit extend_putdata_info
[2388]PGAPI_BindParamater: ipar=46, paramType=1, fCType=-7, fSqlType=-7,
cbColDef=1, ibScale=0, rgbValue=21721456, *pcbValue = 1, data_at_exec = 0
[2388][SQLBindParameter][2388]PGAPI_BindParameter: entering...
[2388]extend_parameter_bindings: entering ... self=45311444,
parameters_allocated=47, num_params=48
[2388]exit extend_parameter_bindings
[2388]extend_iparameter_bindings: entering ... self=45311508,
parameters_allocated=47, num_params=48
[2388]exit extend_iparameter_bindings
[2388]extend_putdata_info: entering ... self=45311624,
parameters_allocated=47, num_params=48
[2388]exit extend_putdata_info
[2388]PGAPI_BindParamater: ipar=47, paramType=1, fCType=99, fSqlType=91,
cbColDef=10, ibScale=0, rgbValue=21721456, *pcbValue = -1, data_at_exec = 0
[2388][SQLBindParameter][2388]PGAPI_BindParameter: entering...
[2388]extend_parameter_bindings: entering ... self=45311444,
parameters_allocated=48, num_params=49
[2388]exit extend_parameter_bindings
[2388]extend_iparameter_bindings: entering ... self=45311508,
parameters_allocated=48, num_params=49
[2388]exit extend_iparameter_bindings
[2388]extend_putdata_info: entering ... self=45311624,
parameters_allocated=48, num_params=49
[2388]exit extend_putdata_info
[2388]PGAPI_BindParamater: ipar=48, paramType=1, fCType=99, fSqlType=1,
cbColDef=16, ibScale=0, rgbValue=21721456, *pcbValue = -1, data_at_exec = 0
[2388][SQLBindParameter][2388]PGAPI_BindParameter: entering...
[2388]extend_parameter_bindings: entering ... self=45311444,
parameters_allocated=49, num_params=50
[2388]exit extend_parameter_bindings
[2388]extend_iparameter_bindings: entering ... self=45311508,
parameters_allocated=49, num_params=50
[2388]exit extend_iparameter_bindings
[2388]extend_putdata_info: entering ... self=45311624,
parameters_allocated=49, num_params=50
[2388]exit extend_putdata_info
[2388]PGAPI_BindParamater: ipar=49, paramType=1, fCType=8, fSqlType=2,
cbColDef=5, ibScale=1, rgbValue=21721644, *pcbValue = 8, data_at_exec = 0
[2388][SQLBindParameter][2388]PGAPI_BindParameter: entering...
[2388]extend_parameter_bindings: entering ... self=45311444,
parameters_allocated=50, num_params=51
[2388]exit extend_parameter_bindings
[2388]extend_iparameter_bindings: entering ... self=45311508,
parameters_allocated=50, num_params=51
[2388]exit extend_iparameter_bindings
[2388]extend_putdata_info: entering ... self=45311624,
parameters_allocated=50, num_params=51
[2388]exit extend_putdata_info
[2388]PGAPI_BindParamater: ipar=50, paramType=1, fCType=1, fSqlType=-1,
cbColDef=8190, ibScale=0, rgbValue=50, *pcbValue = -2, data_at_exec = 1
[2388][SQLBindParameter][2388]PGAPI_BindParameter: entering...
[2388]extend_parameter_bindings: entering ... self=45311444,
parameters_allocated=51, num_params=52
[2388]exit extend_parameter_bindings
[2388]extend_iparameter_bindings: entering ... self=45311508,
parameters_allocated=51, num_params=52
[2388]exit extend_iparameter_bindings
[2388]extend_putdata_info: entering ... self=45311624,
parameters_allocated=51, num_params=52
[2388]exit extend_putdata_info
[2388]PGAPI_BindParamater: ipar=51, paramType=1, fCType=99, fSqlType=1,
cbColDef=70, ibScale=0, rgbValue=50, *pcbValue = -1, data_at_exec = 0
[2388][SQLExecDirect][2388]PGAPI_ExecDirect: entering...
[2388]recycle statement: self= 45311192
[2388]PDATA_free_params:  ENTER, self=45311624
[2388]PDATA_free_params:  EXIT
[2388]**** PGAPI_ExecDirect: hstmt=45311192, statement='INSERT INTO klient

(kood,nimi,a_a,p_kood,regnr,vatpayno,piirkond,postiindek,tanav,kontaktisi,telefon,faks,email,wwwpage,liik,viitenr,riik,riik2,riigikood,hinnak,erihinnak,myygikood,objekt2,objekt5,objekt7,maksetin,omakseti,krediit,ostukredii,masin,info,maksja,timestamp,atimestamp,elanikud,pindala,grmaja,apindala,kpindala,idmakett,tulemus,omandisuhe,username,changedby,parool,hinnaale,mitteakt,kontakteer,klikaart,mhprotsent,aadress,_nimi)

VALUES
(?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)'
[2388]PGAPI_ExecDirect: calling PGAPI_Execute...
[2388]PGAPI_Execute: entering...
[2388]PGAPI_Execute: clear errors...
[2388]recycle statement: self= 45311192
[2388]PDATA_free_params:  ENTER, self=45311624
[2388]PDATA_free_params:  EXIT
[2388]PGAPI_ExecDirect: returned 99 from PGAPI_Execute
[2388][SQLParamData][2388]PGAPI_ParamData: entering...
[2388]PGAPI_ParamData: data_at_exec=2, params_alloc=52
[2388][SQLPutData][2388]PGAPI_PutData: entering...
[2388]PGAPI_PutData: (1) cbValue = 0
[2388][SQLParamData][2388]PGAPI_ParamData: entering...
[2388]PGAPI_ParamData: data_at_exec=1, params_alloc=52
[2388][SQLPutData][2388]PGAPI_PutData: entering...
[2388]PGAPI_PutData: (1) cbValue = 0
[2388][SQLParamData][2388]PGAPI_ParamData: entering...
[2388]PGAPI_ParamData: data_at_exec=0, params_alloc=52
[2388]Exec_with_parameters_resolved: copying statement params:
trans_status=1, len=553, stmt='INSERT INTO klient

(kood,nimi,a_a,p_kood,regnr,vatpayno,piirkond,postiindek,tanav,kontaktisi,telefon,faks,email,wwwpage,liik,viitenr,riik,riik2,riigikood,hinnak,erihinnak,myygikood,objekt2,objekt5,objekt7,maksetin,omakseti,krediit,ostukredii,masin,info,maksja,timestamp,atimestamp,elanikud,pindala,grmaja,apindala,kpindala,idmakett,tulemus,omandisuhe,username,changedby,parool,hinnaale,mitteakt,kontakteer,klikaart,mhprotsent,aadress,_nimi)

VALUES
(?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)'
[2388]ResolveOneParam: from(fcType)=1, to(fSqlType)=1
[2388]ResolveOneParam: from(fcType)=1, to(fSqlType)=1
[2388]ResolveOneParam: from(fcType)=1, to(fSqlType)=1
[2388]ResolveOneParam: from(fcType)=1, to(fSqlType)=1
[2388]ResolveOneParam: from(fcType)=1, to(fSqlType)=1
[2388]ResolveOneParam: from(fcType)=8, to(fSqlType)=2
[2388]ResolveOneParam: from(fcType)=8, to(fSqlType)=2
[2388]ResolveOneParam: from(fcType)=1, to(fSqlType)=1
[2388]ResolveOneParam: from(fcType)=1, to(fSqlType)=-1
[2388]ResolveOneParam: from(fcType)=1, to(fSqlType)=1
[2388]ResolveOneParam: from(fcType)=1, to(fSqlType)=1
[2388]ResolveOneParam: from(fcType)=8, to(fSqlType)=2
[2388]ResolveOneParam: from(fcType)=8, to(fSqlType)=2
[2388]ResolveOneParam: from(fcType)=8, to(fSqlType)=2
[2388]ResolveOneParam: from(fcType)=8, to(fSqlType)=2
[2388]ResolveOneParam: from(fcType)=1, to(fSqlType)=1
[2388]ResolveOneParam: from(fcType)=1, to(fSqlType)=1
[2388]ResolveOneParam: from(fcType)=-7, to(fSqlType)=-7
[2388]ResolveOneParam: from(fcType)=8, to(fSqlType)=2
[2388]ResolveOneParam: from(fcType)=1, to(fSqlType)=-1
[2388]   stmt_with_params = 'INSERT INTO klient

(kood,nimi,a_a,p_kood,regnr,vatpayno,piirkond,postiindek,tanav,kontaktisi,telefon,faks,email,wwwpage,liik,viitenr,riik,riik2,riigikood,hinnak,erihinnak,myygikood,objekt2,objekt5,objekt7,maksetin,omakseti,krediit,ostukredii,masin,info,maksja,timestamp,atimestamp,elanikud,pindala,grmaja,apindala,kpindala,idmakett,tulemus,omandisuhe,username,changedby,parool,hinnaale,mitteakt,kontakteer,klikaart,mhprotsent,aadress,_nimi)

VALUES ('AKUEXPERTOU ','Akuexpert O?
',NULL,NULL,'           0',NULL,'Tallinn
',NULL,'Kadaka tee 44

',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,'0','0','MAREK','',NULL,'20051103193304','20051103193304','0','0',NULL,'0','0',NULL,NULL,NULL,'ADMIN

','ADMIN     ',NULL,NULL,'0',NULL,NULL,'0','',NULL)'
[2388]      it's NOT a select statement: stmt=45311192
[2388]send_query(): conn=45299344, query='INSERT INTO klient

(kood,nimi,a_a,p_kood,regnr,vatpayno,piirkond,postiindek,tanav,kontaktisi,telefon,faks,email,wwwpage,liik,viitenr,riik,riik2,riigikood,hinnak,erihinnak,myygikood,objekt2,objekt5,objekt7,maksetin,omakseti,krediit,ostukredii,masin,info,maksja,timestamp,atimestamp,elanikud,pindala,grmaja,apindala,kpindala,idmakett,tulemus,omandisuhe,username,changedby,parool,hinnaale,mitteakt,kontakteer,klikaart,mhprotsent,aadress,_nimi)

VALUES ('AKUEXPERTOU ','Akuexpert O?
',NULL,NULL,'           0',NULL,'Tallinn
',NULL,'Kadaka tee 44

',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,'0','0','MAREK','',NULL,'20051103193304','20051103193304','0','0',NULL,'0','0',NULL,NULL,NULL,'ADMIN

','ADMIN     ',NULL,NULL,'0',NULL,NULL,'0','',NULL)'
[2388]in QR_Constructor
[2388]exit QR_Constructor
[2388]the server returned the error: ERROR:  invalid UTF-8 byte sequence
detected near byte 0xdc
[2388]send_query: done sending query
[2388]QR_fetch_tuples: cursor = '', self->cursor=0
[2388]QR_fetch_tuples: past CI_read_fields: num_fields = 0
[2388]MALLOC: tuple_size = 100, size = 0
[2388]STATEMENT ERROR: func=SC_execute, desc='', errnum=7, errmsg='Error
while executing the query'
[2388]CONN ERROR: func=SC_execute, desc='', errnum=108, errmsg='ERROR:
invalid UTF-8 byte sequence detected near byte 0xdc'
[2388]dequeueNeedDataCallback ret=-1 count=0
[2388][[SQLGetDiagRec]]
[2388]PGAPI_GetDiagRec entering rec=1[2388]**** PGAPI_StmtError:
hstmt=45311192 <512>
[2388]SC_get_error: status = 7, msg = #Error while executing the query;
ERROR:  invalid UTF-8 byte sequence detected near byte 0xdc#
[2388]      szSqlState = 'S1000',len=92, szError='Error while executing the
query;
ERROR:  invalid UTF-8 byte sequence detected near byte 0xdc'
[2388]PGAPI_GetDiagRec exiting 0
[2388][[SQLGetDiagRec]]
[2388]PGAPI_GetDiagRec entering rec=2[2388]**** PGAPI_StmtError:
hstmt=45311192 <512>
[2388]SC_get_error: status = 7, msg = #Error while executing the query;
ERROR:  invalid UTF-8 byte sequence detected near byte 0xdc#
[2388]PGAPI_GetDiagRec exiting 100
[2388][SQLCancel][2388]PGAPI_Cancel: entering...
[2388][SQLExecDirect][2388]PGAPI_ExecDirect: entering...
[2388]recycle statement: self= 45311192
[2388]QResult: in DESTRUCTOR
[2388]QResult: free memory in, fcount=101
[2388]QResult: free memory out
[2388]QResult: exit DESTRUCTOR
[2388]PDATA_free_params:  ENTER, self=45311624
[2388]PDATA_free_params:  EXIT
[2388]**** PGAPI_ExecDirect: hstmt=45311192, statement='SELECT * FROM dok
WHERE false'
[2388]PGAPI_ExecDirect: calling PGAPI_Execute...
[2388]PGAPI_Execute: entering...
[2388]PGAPI_Execute: clear errors...
[2388]recycle statement: self= 45311192
[2388]PDATA_free_params:  ENTER, self=45311624
[2388]PDATA_free_params:  EXIT
[2388]PGAPI_ExecDirect: returned 99 from PGAPI_Execute
[2388][SQLParamData][2388]PGAPI_ParamData: entering...
[2388]PGAPI_ParamData: data_at_exec=2, params_alloc=52


> Don't you have some bad code after failing insert?

I use FoxPro high level append from command for insert.
I do'nt know what code FoxPro runtime executes  in case of error, no source
available.

However, FoxPro is widely used with odbc drivers without problems.

Andrus.



Re: Application crash after error

From
Ludek Finstrle
Date:
> Yes.  When using ANSI driver, I got an error

Do you get same error message with unicode one?

> Connectivity error: Error while executing the query;
> ERROR:  invalid UTF-8 byte sequence detected near byte 0xdc
>
> and after selecting Ignore my appl crashes with access violation (C0000005)
> error

> Last lines in log file (before crash) are:

...

> [2388]   stmt_with_params = 'INSERT INTO klient
>
(kood,nimi,a_a,p_kood,regnr,vatpayno,piirkond,postiindek,tanav,kontaktisi,telefon,faks,email,wwwpage,liik,viitenr,riik,riik2,riigikood,hinnak,erihinnak,myygikood,objekt2,objekt5,objekt7,maksetin,omakseti,krediit,ostukredii,masin,info,maksja,timestamp,atimestamp,elanikud,pindala,grmaja,apindala,kpindala,idmakett,tulemus,omandisuhe,username,changedby,parool,hinnaale,mitteakt,kontakteer,klikaart,mhprotsent,aadress,_nimi)

> VALUES ('AKUEXPERTOU ','Akuexpert O?
                                    ^^^ Is there really char '?' ?
> ',NULL,NULL,'           0',NULL,'Tallinn
> ',NULL,'Kadaka tee 44
>
',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,'0','0','MAREK','',NULL,'20051103193304','20051103193304','0','0',NULL,'0','0',NULL,NULL,NULL,'ADMIN

> ','ADMIN     ',NULL,NULL,'0',NULL,NULL,'0','',NULL)'

...

> hstmt=45311192 <512>
> [2388]SC_get_error: status = 7, msg = #Error while executing the query;
> ERROR:  invalid UTF-8 byte sequence detected near byte 0xdc#
> [2388]PGAPI_GetDiagRec exiting 100
> [2388][SQLCancel][2388]PGAPI_Cancel: entering...
> [2388][SQLExecDirect][2388]PGAPI_ExecDirect: entering...

It seems that psqlodbc fail (in SQLCancel) here. It enter but it doesn't
exit.

I'll try to reproduce the problem. You can help me with sending
a minimalistic exe and table structure which reproduce the error.

Regards,

Luf

Re: Application crash after error

From
"Andrus"
Date:
Ludek,

In klient table I have
info text,

column.

If I remove this column from klient table, error does not occur.

So it seems that this error occurs if table has text type column.

I'm in progress of creating simplified repro code. Please tell me if you
need it.



Andrus.




It seems that the problem is realtated
"Ludek Finstrle" <luf@pzkagis.cz> wrote in message
news:20051129134743.GA32475@soptik.pzkagis.cz...
>> Yes.  When using ANSI driver, I got an error
>
> Do you get same error message with unicode one?
>
>> Connectivity error: Error while executing the query;
>> ERROR:  invalid UTF-8 byte sequence detected near byte 0xdc
>>
>> and after selecting Ignore my appl crashes with access violation
>> (C0000005)
>> error
>
>> Last lines in log file (before crash) are:
>
> ...
>
>> [2388]   stmt_with_params = 'INSERT INTO klient
>>
(kood,nimi,a_a,p_kood,regnr,vatpayno,piirkond,postiindek,tanav,kontaktisi,telefon,faks,email,wwwpage,liik,viitenr,riik,riik2,riigikood,hinnak,erihinnak,myygikood,objekt2,objekt5,objekt7,maksetin,omakseti,krediit,ostukredii,masin,info,maksja,timestamp,atimestamp,elanikud,pindala,grmaja,apindala,kpindala,idmakett,tulemus,omandisuhe,username,changedby,parool,hinnaale,mitteakt,kontakteer,klikaart,mhprotsent,aadress,_nimi)
>> VALUES ('AKUEXPERTOU ','Akuexpert O?
>                                    ^^^ Is there really char '?' ?
>> ',NULL,NULL,'           0',NULL,'Tallinn
>> ',NULL,'Kadaka tee 44
>>
',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,'0','0','MAREK','',NULL,'20051103193304','20051103193304','0','0',NULL,'0','0',NULL,NULL,NULL,'ADMIN
>> ','ADMIN     ',NULL,NULL,'0',NULL,NULL,'0','',NULL)'
>
> ...
>
>> hstmt=45311192 <512>
>> [2388]SC_get_error: status = 7, msg = #Error while executing the query;
>> ERROR:  invalid UTF-8 byte sequence detected near byte 0xdc#
>> [2388]PGAPI_GetDiagRec exiting 100
>> [2388][SQLCancel][2388]PGAPI_Cancel: entering...
>> [2388][SQLExecDirect][2388]PGAPI_ExecDirect: entering...
>
> It seems that psqlodbc fail (in SQLCancel) here. It enter but it doesn't
> exit.
>
> I'll try to reproduce the problem. You can help me with sending
> a minimalistic exe and table structure which reproduce the error.
>
> Regards,
>
> Luf
>
> ---------------------------(end of broadcast)---------------------------
> TIP 9: In versions below 8.0, the planner will ignore your desire to
>       choose an index scan if your joining column's datatypes do not
>       match
>



Re: Application crash after error - please help

From
Ludek Finstrle
Date:
> In klient table I have
> info text,
>
> column.
>
> If I remove this column from klient table, error does not occur.
>
> So it seems that this error occurs if table has text type column.

Hello,

  I investigate it a little bit more and I go to the end of my
knolwdge. I hope someone on the list could help.

Description:
You insert data with data at exec. It mean you call:
1) SQLExecDirect with ? as parameters needed (3 of them)
2) SQLParamData
3) SQLPutData (only for text column)
4) SQLParamData - which execute the query but fail and return SQL_ERROR
5) SQLCancel - this is point of the problem. I don't know if it may
     destroy Binding Parameters at all

6) SQLExecDirect without parameters needed - but ODBC driver execpt
     3 parameters becouse you didn't call SQLFreeStmt (SQL_DROP or
     SQL_ - I forget the name which frees only binding params)
     ODBC driver doesn't investigate number od parameters from statement.
     Maybe this is point of problem?
7) SQLParamData - go throught well
- your application failed. The point of failure isn't exactly in ODBC
driver but it correspond with SQLPutData is needed.

I'm not sure if it's problem of psqlODBC driver. Could someone more
experienced help?

Thanks a lot

Luf

Re: Application crash after error - please help

From
"Andrus"
Date:
>  I investigate it a little bit more and I go to the end of my
> knolwdge. I hope someone on the list could help.
>
> Description:
> You insert data with data at exec. It mean you call:
> 1) SQLExecDirect with ? as parameters needed (3 of them)
> 2) SQLParamData
> 3) SQLPutData (only for text column)
> 4) SQLParamData - which execute the query but fail and return SQL_ERROR
> 5) SQLCancel - this is point of the problem. I don't know if it may
>     destroy Binding Parameters at all
>
> 6) SQLExecDirect without parameters needed - but ODBC driver execpt
>     3 parameters becouse you didn't call SQLFreeStmt (SQL_DROP or
>     SQL_ - I forget the name which frees only binding params)
>     ODBC driver doesn't investigate number od parameters from statement.
>     Maybe this is point of problem?
> 7) SQLParamData - go throught well
> - your application failed. The point of failure isn't exactly in ODBC
> driver but it correspond with SQLPutData is needed.

Here are steps to reproduce:

1. Unpack www.eetasoft.ee/postgresrepro.zip  (5 MB) (link valid at least one
week)

2. Edit sqltest.prg to change password for connection string instead of
aaaa, user name instead of admin and possibly other parameters.

3. Run the main.exe.

Observed result:

Fatal error: exception code C0000005


Expected result:

message  Program flow does not reach to this point.

Environment:

1. Postgres 8.1 on Windows XP SP2. cluster locale is Estonian (occurs with
other locales also). Database (sample code uses pre-installed postgres
database) encoding is UTF8
2. Client in Windows XP SP2 (occurs with Win 98 client also), Unicode ODBC
driver vers. 8.1.1. (occurs with ANSI driver also)
3. Client application is created using Microsoft Visual FoxPro 9 SP1beta
(occurs in VFP vers 7 also)
4. Client windows locale is Estonian (occurs with other windows locales
also). You may remove � character from sqltest.prg source code to run it in
other locales and encodings.

Notes:

1. Occurs only if SQLParamData returns SQL_ERROR. If not error is returned,
problem does not occur.

2. Occurs only if table contains text type field. If there are only char or
varchars fields, problem does not occur.

> I'm not sure if it's problem of psqlODBC driver. Could someone more
> experienced help?

Visual FoxPro is closed source. Microsoft does not support Postgres ODBC
driver.
Since we have large amout of VFP code, we cannot change to other client at
this moment.
So only hope is it make some changes to ODBC driver code.
I don't have C compiler and enough knowledge to compile odbc driver and
investigate this issue.

Should I add this issue to bug tracker ?

Andrus.



Re: Application crash after error - please help

From
"Andrus"
Date:
Ludek,

> Main.exe doesn't use auth info prom sqltest.prg.

I'm sorry. Modified repro code is available in same address
(www.eetasoft.ee/postgresrepro.zip)
This repro contains text type column. Fox mysql it should probably be
replaced also. My co-worker tries to run it in mysql in weekend.

> I don't know if the problem is in ODBC driver. But to fix this problem
> imidiately in your app it's enough
> if you add Calling SQLFreeStmt with SQL_DROP in the code when insert
> fail.

Thank you. This would be a good fix. Unfortunately it it difficult to
implement in VFP.

I don't use ODBC direct calls in my code. In repro code I issue APPEND FROM

APPEND FROM DBF('testk')

This causes VFP to generate ODBC calls automatically. I do'nt know is it
possible to add ODBC SQLFreeStmt direct call after high-level VFP APPEND
FROM command.

More generally: I create form, bind it to Postgres server data. Users edit
this form.
During editing process VFP generates ODBC calls automatically. Trying to
insert duplicate primary by end user or some other odbc error causes my appl
crash shortly after that. My code is not involved in this process.

Theoretically, I can determine odbc handle used by VFP and make direct ODBC
dll calls from my application. I can add my code to editing events to fix
something.
However, I do'nt know the  places where to add SQLFreeStmt calls and i'm not
sure how to add such fixes in all situations which may occur during editing
process.

Andrus.