pg.ddx.io  pgsql-odbc@postgresql.org mailing list archive  
help / color / mirror / Atom feed
Some bug fixes and improvements
3+ messages / 2 participants
[nested] [flat]

* Some bug fixes and improvements
@ 2016-03-29 02:17 Tsunakawa, Takayuki <tsunakawa.takay@jp.fujitsu.com>
  2016-03-30 08:31 ` Re: Some bug fixes and improvements Inoue, Hiroshi <h-inoue@dream.email.ne.jp>
  0 siblings, 1 reply; 3+ messages in thread

From: Tsunakawa, Takayuki @ 2016-03-29 02:17 UTC (permalink / raw)
  To: pgsql-odbc

Hello, Inoue-san and all,

While I'm learning the psqlODBC source code and investigating the cause of the scroll cursor crash problem I reported in January, I found some bugs and useless code fragments.  Please find the attached patches to remove them.  I hope these will be included in the next release.

However, I've not been able to find the cause of the crash.  The code of psqlODBC is pretty complex, particularly around handling cursors, isn't it?

The below are the brief descriptions of the patches:


[bind_mem_failure.patch]
The existing memory is not freed upon realloc() failure.  

PGAPI_BindCol() doesn't check the failure of extend_getdata_info().


[duplicate_env_alloc.patch]
setup.c:test_connection() calls EN_Constructor() twice, leaking small memory.


[flag_overwrite.patch]
Checking a flag bit mistakenly resets other flag bits.  I don't know what failure this would cause.



[ineffective_code.patch]
The third stricmp() in writeDriverCommoninfo() is useless, because the second one causes the function to return.

SC_get_errormsg() definition is repeated twice in succession.

CC_on_abort_partial() is not used.

In info.c:SQLGetInfo(), "len = 0" is unnecessary because len is assigned at the end of the function.

In execute.c:PGAPI_ExecDirect(), flag doesn't need to be set as its value doesn't change.

PODBC_PER_STATEMENT_ROLLBACK is not used.


[multi_stmt_prepare.patch]
The statement linked list is not properly chained, which throws away some statements.  I don't know what failure this would cause.


[win_build.patch]
LINKMT is not used in the build process.

ADDL_INC should be ADD_INC.  Just a typo.

The CLEAN target doesn't delete .pdb files.

Regards
Takayuki Tsunakawa

-- 
Sent via pgsql-odbc mailing list (pgsql-odbc@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-odbc

Attachments: download all (6 files, .tar.gz)

bind_mem_failure.patch (application/octet-stream, 1.3K) download diff -Nacr a/bind.c b/bind.c *** a/bind.c 2016-01-10 22:25:14.000000000 +0900 --- b/bind.c 2016-03-29 10:29:55.000000000 +0900 *************** *** 228,234 **** extend_getdata_info(gdata_info, icol, FALSE); /* check to see if the bindings were allocated */ ! if (!opts->bindings) { SC_set_error(stmt, STMT_NO_MEMORY_ERROR, "Could not allocate memory for bindings.", func); ret = SQL_ERROR; --- 228,234 ---- extend_getdata_info(gdata_info, icol, FALSE); /* check to see if the bindings were allocated */ ! if (!opts->bindings || !gdata_info->gdata) { SC_set_error(stmt, STMT_NO_MEMORY_ERROR, "Could not allocate memory for bindings.", func); ret = SQL_ERROR; *************** *** 506,511 **** --- 506,513 ---- { mylog("%s: unable to create %d new bindings from %d old bindings\n", func, num_params, self->allocated); + if (self->parameters) + free(self->parameters); self->parameters = NULL; self->allocated = 0; return; *************** *** 538,543 **** --- 540,547 ---- { mylog("%s: unable to create %d new bindings from %d old bindings\n", func, num_params, self->allocated); + if (self->parameters) + free(self->parameters); self->parameters = NULL; self->allocated = 0; return;
duplicate_env_alloc.patch (application/octet-stream, 586B) download diff -Nacr a/setup.c b/setup.c *** a/setup.c 2016-01-10 22:25:14.000000000 +0900 --- b/setup.c 2016-03-28 15:30:30.000000000 +0900 *************** *** 400,406 **** void test_connection(HANDLE hwnd, ConnInfo *ci, BOOL withDTC) { ! EnvironmentClass *env = EN_Constructor(); ConnectionClass *conn = NULL; char szMsg[SQL_MAX_MESSAGE_LENGTH]; char *emsg = NULL; --- 400,406 ---- void test_connection(HANDLE hwnd, ConnInfo *ci, BOOL withDTC) { ! EnvironmentClass *env; ConnectionClass *conn = NULL; char szMsg[SQL_MAX_MESSAGE_LENGTH]; char *emsg = NULL;
flag_overwrite.patch (application/octet-stream, 1.4K) download diff -Nacr a/descriptor.h b/descriptor.h *** a/descriptor.h 2016-01-10 22:25:14.000000000 +0900 --- b/descriptor.h 2016-03-29 09:41:44.000000000 +0900 *************** *** 29,40 **** UInt4 flags; } TABLE_INFO; #define TI_set_updatable(ti) (ti->flags |= TI_UPDATABLE) ! #define TI_is_updatable(ti) (0 != (ti->flags &= TI_UPDATABLE)) #define TI_no_updatable(ti) (ti->flags &= (~TI_UPDATABLE)) #define TI_set_hasoids_checked(ti) (ti->flags |= TI_HASOIDS_CHECKED) ! #define TI_checked_hasoids(ti) (0 != (ti->flags &= TI_HASOIDS)) #define TI_set_hasoids(ti) (ti->flags |= TI_HASOIDS) ! #define TI_has_oids(ti) (0 != (ti->flags &= TI_HASOIDS)) #define TI_set_has_no_oids(ti) (ti->flags &= (~TI_HASOIDS)) void TI_Constructor(TABLE_INFO *, const ConnectionClass *); void TI_Destructor(TABLE_INFO **, int); --- 29,40 ---- UInt4 flags; } TABLE_INFO; #define TI_set_updatable(ti) (ti->flags |= TI_UPDATABLE) ! #define TI_is_updatable(ti) (0 != (ti->flags & TI_UPDATABLE)) #define TI_no_updatable(ti) (ti->flags &= (~TI_UPDATABLE)) #define TI_set_hasoids_checked(ti) (ti->flags |= TI_HASOIDS_CHECKED) ! #define TI_checked_hasoids(ti) (0 != (ti->flags & TI_HASOIDS)) #define TI_set_hasoids(ti) (ti->flags |= TI_HASOIDS) ! #define TI_has_oids(ti) (0 != (ti->flags & TI_HASOIDS)) #define TI_set_has_no_oids(ti) (ti->flags &= (~TI_HASOIDS)) void TI_Constructor(TABLE_INFO *, const ConnectionClass *); void TI_Destructor(TABLE_INFO **, int);
ineffective_code.patch (application/octet-stream, 4.2K) download diff -Nacr a/connection.c b/connection.c *** a/connection.c 2016-01-10 22:25:14.000000000 +0900 --- b/connection.c 2016-03-29 09:24:39.000000000 +0900 *************** *** 1474,1488 **** CONNLOCK_RELEASE(conn); } - void CC_on_abort_partial(ConnectionClass *conn) - { - mylog("CC_on_abort_partial in\n"); - ProcessRollback(conn, TRUE, TRUE); - CONNLOCK_ACQUIRE(conn); - CC_discard_marked_objects(conn); - CONNLOCK_RELEASE(conn); - } - static BOOL is_setting_search_path(const char *query) { --- 1474,1479 ---- diff -Nacr a/connection.h b/connection.h *** a/connection.h 2016-01-10 22:25:14.000000000 +0900 --- b/connection.h 2016-03-29 09:24:47.000000000 +0900 *************** *** 473,479 **** int CC_send_cancel_request(const ConnectionClass *conn); void CC_on_commit(ConnectionClass *conn); void CC_on_abort(ConnectionClass *conn, UDWORD opt); - void CC_on_abort_partial(ConnectionClass *conn); void ProcessRollback(ConnectionClass *conn, BOOL undo, BOOL partial); const char *CC_get_current_schema(ConnectionClass *conn); int CC_mark_a_object_to_discard(ConnectionClass *conn, int type, const char *plan); --- 473,478 ---- diff -Nacr a/dlg_specific.c b/dlg_specific.c *** a/dlg_specific.c 2016-01-10 22:25:14.000000000 +0900 --- b/dlg_specific.c 2016-03-28 17:05:17.000000000 +0900 *************** *** 1086,1100 **** sprintf(tmp, "%d", comval->unique_index); if (!SQLWritePrivateProfileString(sectionName, INI_UNIQUEINDEX, tmp, fileName)) errc--; - /* - * Never update the onlyread from this module. - */ - if (stricmp(ODBCINST_INI, fileName) == 0) - { - sprintf(tmp, "%d", comval->onlyread); - SQLWritePrivateProfileString(sectionName, INI_READONLY, tmp, - fileName); - } sprintf(tmp, "%d", comval->use_declarefetch); if (!SQLWritePrivateProfileString(sectionName, INI_USEDECLAREFETCH, tmp, fileName)) --- 1086,1091 ---- diff -Nacr a/execute.c b/execute.c *** a/execute.c 2016-01-10 22:25:14.000000000 +0900 --- b/execute.c 2016-03-29 09:35:33.000000000 +0900 *************** *** 193,199 **** mylog("%s: calling PGAPI_Execute...\n", func); - flag = SC_is_with_hold(stmt) ? PODBC_WITH_HOLD : 0; result = PGAPI_Execute(hstmt, flag); mylog("%s: returned %hd from PGAPI_Execute\n", func, result); --- 193,198 ---- diff -Nacr a/info.c b/info.c *** a/info.c 2016-01-10 22:25:14.000000000 +0900 --- b/info.c 2016-03-29 09:28:33.000000000 +0900 *************** *** 817,830 **** value = SQL_BS_SELECT_EXPLICIT | SQL_BS_ROW_COUNT_EXPLICIT; break; case SQL_CATALOG_NAME: - len = 0; if (CurrCat(conn)) p = "Y"; else p = "N"; break; case SQL_COLLATION_SEQ: - len = 0; p = ""; break; case SQL_CREATE_ASSERTION: --- 817,828 ---- *************** *** 872,878 **** value = SQL_DI_CREATE_INDEX | SQL_DI_DROP_INDEX; break; case SQL_DESCRIBE_PARAMETER: - len = 0; p = "N"; break; case SQL_DROP_ASSERTION: --- 870,875 ---- *************** *** 928,934 **** value = NAMEDATALEN_V73 - 1; break; case SQL_MAX_ROW_SIZE_INCLUDES_LONG: - len = 0; p = "Y"; break; case SQL_PARAM_ARRAY_ROW_COUNTS: --- 925,930 ---- diff -Nacr a/pgapifunc.h b/pgapifunc.h *** a/pgapifunc.h 2016-01-10 22:25:14.000000000 +0900 --- b/pgapifunc.h 2016-03-29 09:36:24.000000000 +0900 *************** *** 22,28 **** #define PODBC_INHERIT_CONNECT_OPTIONS (1L << 1) /* Internal flags for PGAPI_Exec... functions */ #define PODBC_WITH_HOLD 1L - #define PODBC_PER_STATEMENT_ROLLBACK (1L << 1) /* Flags for the error handling */ #define PODBC_ALLOW_PARTIAL_EXTRACT 1L #define PODBC_ERROR_CLEAR (1L << 1) --- 22,27 ---- diff -Nacr a/statement.h b/statement.h *** a/statement.h 2016-01-10 22:25:14.000000000 +0900 --- b/statement.h 2016-03-28 17:20:17.000000000 +0900 *************** *** 325,331 **** #define SC_get_errornumber(a) (a->__error_number) #define SC_set_errornumber(a, n) (a->__error_number = n) #define SC_get_errormsg(a) (a->__error_message) - #define SC_get_errormsg(a) (a->__error_message) #define SC_is_prepare_statement(a) (0 != (a->prepare & PREPARE_STATEMENT)) #define SC_get_prepare_method(a) (a->prepare & (~PREPARE_STATEMENT)) --- 325,330 ----
multi_stmt_prepare.patch (application/octet-stream, 327B) download diff -Nacr a/convert.c b/convert.c *** a/convert.c 2016-01-10 22:25:14.000000000 +0900 --- b/convert.c 2016-03-29 10:33:37.000000000 +0900 *************** *** 2684,2689 **** --- 2684,2690 ---- if (!pstmt) goto cleanup; last_pstmt->next = pstmt; + last_pstmt = pstmt; } SC_set_planname(stmt, plan_name);
win_build.patch (application/octet-stream, 1.4K) download diff -Nacr a/docs/win32-compilation.html b/docs/win32-compilation.html *** a/docs/win32-compilation.html 2016-01-10 22:25:14.000000000 +0900 --- b/docs/win32-compilation.html 2016-03-29 09:43:58.000000000 +0900 *************** *** 106,115 **** <td>C:\OpenSSL-Win32\lib</td> </tr> <tr> - <td>LINKMT</td> - <td>MT</td> - </tr> - <tr> <td>ANSI_VERSION</td> <td>no (If set to "yes", output dll name to psqlodbc30a.dll)</td> </tr> --- 106,111 ---- diff -Nacr a/win64.mak b/win64.mak *** a/win64.mak 2016-01-10 22:25:15.000000000 +0900 --- b/win64.mak 2016-03-29 09:54:14.000000000 +0900 *************** *** 107,113 **** !IF "$(PG_INC)" != "" INC_OPT = $(INC_OPT) /I "$(PG_INC)" !ENDIF ! !IF "$(ADDL_INC)" != "" INC_OPT = $(INC_OPT) /I "$(ADD_INC)" !ENDIF --- 107,113 ---- !IF "$(PG_INC)" != "" INC_OPT = $(INC_OPT) /I "$(PG_INC)" !ENDIF ! !IF "$(ADD_INC)" != "" INC_OPT = $(INC_OPT) /I "$(ADD_INC)" !ENDIF *************** *** 159,169 **** -@erase "$(OUTDIR)\*.lib" -@erase "$(OUTDIR)\*.exp" -@erase "$(INTDIR)\*.pch" ! -@erase "$(OUTDIR)\$(MAINDLL)" ! !IF "$(MSDTC)" != "no" ! -@erase "$(OUTDIR)\$(DTCDLL)" ! -@erase "$(OUTDIR)\$(XADLL)" ! !ENDIF "$(INTDIR)" : !IF !EXISTS($(INTDIR)) --- 159,166 ---- -@erase "$(OUTDIR)\*.lib" -@erase "$(OUTDIR)\*.exp" -@erase "$(INTDIR)\*.pch" ! -@erase "$(INTDIR)\*.dll" ! -@erase "$(INTDIR)\*.pdb" "$(INTDIR)" : !IF !EXISTS($(INTDIR))
^ permalink raw reply [nested|flat] 3+ messages in thread

* Re: Some bug fixes and improvements
  2016-03-29 02:17 Some bug fixes and improvements Tsunakawa, Takayuki <tsunakawa.takay@jp.fujitsu.com>
@ 2016-03-30 08:31 ` Inoue, Hiroshi <h-inoue@dream.email.ne.jp>
  2016-04-01 00:02   ` Re: Some bug fixes and improvements Tsunakawa, Takayuki <tsunakawa.takay@jp.fujitsu.com>
  0 siblings, 1 reply; 3+ messages in thread

From: Inoue, Hiroshi @ 2016-03-30 08:31 UTC (permalink / raw)
  To: Tsunakawa, Takayuki <tsunakawa.takay@jp.fujitsu.com>; +Cc: pgsql-odbc

井上です。

On 2016/03/29 11:17, Tsunakawa, Takayuki wrote:
> Hello, Inoue-san and all,
>
> While I'm learning the psqlODBC source code and investigating the cause of the scroll cursor crash problem I reported in January, I found some bugs and useless code fragments.  Please find the attached patches to remove them.  I hope these will be included in the next release.

ありがとうございます。
ineffective_code.patchとwin_build.patchを除いてpushしました。
ineffective_code.patchは関しては、なぜCC_on_abort_partialが抜けてしまっ 
たのか調べる必要がありま す。 これはsavepoint単位のrollback時に必要な処 
理をするものです。
win_build.patchに関しては、使用を勧めてはいないnmake関連のバグを修正する 
というのは矛盾を感じるというか何というか。

>
> However, I've not been able to find the cause of the crash.  The code of psqlODBC is pretty complex, particularly around handling cursors, isn't it?
とりあえず、 crashについて基本的なことを確認させてください。
  declare/fetchモードですか?
  以前のメールにあったトレースの中で
   psqlodbc35w.dll!SQLFetchScroll(void * StatementHandle=0x007f3b30, 
short FetchOrientation=5, long FetchOffset=27326472)
  の引数(FetchOrientation=SQL_FETCH_ABSOLUTEとFetchOffset)は正しいと 
考えてよろしいので しょうか?



-- 
Sent via pgsql-odbc mailing list (pgsql-odbc@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-odbc



^ permalink  raw  reply  [nested|flat] 3+ messages in thread

* Re: Some bug fixes and improvements
  2016-03-29 02:17 Some bug fixes and improvements Tsunakawa, Takayuki <tsunakawa.takay@jp.fujitsu.com>
  2016-03-30 08:31 ` Re: Some bug fixes and improvements Inoue, Hiroshi <h-inoue@dream.email.ne.jp>
@ 2016-04-01 00:02   ` Tsunakawa, Takayuki <tsunakawa.takay@jp.fujitsu.com>
  0 siblings, 0 replies; 3+ messages in thread

From: Tsunakawa, Takayuki @ 2016-04-01 00:02 UTC (permalink / raw)
  To: Inoue, Hiroshi <h-inoue@dream.email.ne.jp>; +Cc: pgsql-odbc

> From: Inoue, Hiroshi [mailto:h-inoue@dream.email.ne.jp]
> ineffective_code.patchは関しては、なぜCC_on_abort_partialが抜けてしま
> っ
> たのか調べる必要がありま す。 これはsavepoint単位のrollback時に必要な
> 処
> 理をするものです。

OK, I eliminated the removal of CC_on_abort_partial().  Please use the revised patch.

Regards
Takayuki Tsunakawa



-- 
Sent via pgsql-odbc mailing list (pgsql-odbc@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-odbc

Attachments:

ineffective_code_v2.patch (application/octet-stream, 3.0K) download diff -Nacr a/dlg_specific.c b/dlg_specific.c *** a/dlg_specific.c 2016-01-10 22:25:14.000000000 +0900 --- b/dlg_specific.c 2016-03-28 17:05:17.000000000 +0900 *************** *** 1086,1100 **** sprintf(tmp, "%d", comval->unique_index); if (!SQLWritePrivateProfileString(sectionName, INI_UNIQUEINDEX, tmp, fileName)) errc--; - /* - * Never update the onlyread from this module. - */ - if (stricmp(ODBCINST_INI, fileName) == 0) - { - sprintf(tmp, "%d", comval->onlyread); - SQLWritePrivateProfileString(sectionName, INI_READONLY, tmp, - fileName); - } sprintf(tmp, "%d", comval->use_declarefetch); if (!SQLWritePrivateProfileString(sectionName, INI_USEDECLAREFETCH, tmp, fileName)) --- 1086,1091 ---- diff -Nacr a/execute.c b/execute.c *** a/execute.c 2016-01-10 22:25:14.000000000 +0900 --- b/execute.c 2016-03-29 09:35:33.000000000 +0900 *************** *** 193,199 **** mylog("%s: calling PGAPI_Execute...\n", func); - flag = SC_is_with_hold(stmt) ? PODBC_WITH_HOLD : 0; result = PGAPI_Execute(hstmt, flag); mylog("%s: returned %hd from PGAPI_Execute\n", func, result); --- 193,198 ---- diff -Nacr a/info.c b/info.c *** a/info.c 2016-01-10 22:25:14.000000000 +0900 --- b/info.c 2016-03-29 09:28:33.000000000 +0900 *************** *** 817,830 **** value = SQL_BS_SELECT_EXPLICIT | SQL_BS_ROW_COUNT_EXPLICIT; break; case SQL_CATALOG_NAME: - len = 0; if (CurrCat(conn)) p = "Y"; else p = "N"; break; case SQL_COLLATION_SEQ: - len = 0; p = ""; break; case SQL_CREATE_ASSERTION: --- 817,828 ---- *************** *** 872,878 **** value = SQL_DI_CREATE_INDEX | SQL_DI_DROP_INDEX; break; case SQL_DESCRIBE_PARAMETER: - len = 0; p = "N"; break; case SQL_DROP_ASSERTION: --- 870,875 ---- *************** *** 928,934 **** value = NAMEDATALEN_V73 - 1; break; case SQL_MAX_ROW_SIZE_INCLUDES_LONG: - len = 0; p = "Y"; break; case SQL_PARAM_ARRAY_ROW_COUNTS: --- 925,930 ---- diff -Nacr a/pgapifunc.h b/pgapifunc.h *** a/pgapifunc.h 2016-01-10 22:25:14.000000000 +0900 --- b/pgapifunc.h 2016-03-29 09:36:24.000000000 +0900 *************** *** 22,28 **** #define PODBC_INHERIT_CONNECT_OPTIONS (1L << 1) /* Internal flags for PGAPI_Exec... functions */ #define PODBC_WITH_HOLD 1L - #define PODBC_PER_STATEMENT_ROLLBACK (1L << 1) /* Flags for the error handling */ #define PODBC_ALLOW_PARTIAL_EXTRACT 1L #define PODBC_ERROR_CLEAR (1L << 1) --- 22,27 ---- diff -Nacr a/statement.h b/statement.h *** a/statement.h 2016-01-10 22:25:14.000000000 +0900 --- b/statement.h 2016-03-28 17:20:17.000000000 +0900 *************** *** 325,331 **** #define SC_get_errornumber(a) (a->__error_number) #define SC_set_errornumber(a, n) (a->__error_number = n) #define SC_get_errormsg(a) (a->__error_message) - #define SC_get_errormsg(a) (a->__error_message) #define SC_is_prepare_statement(a) (0 != (a->prepare & PREPARE_STATEMENT)) #define SC_get_prepare_method(a) (a->prepare & (~PREPARE_STATEMENT)) --- 325,330 ----
^ permalink raw reply [nested|flat] 3+ messages in thread


end of thread, other threads:[~2016-04-01 00:02 UTC | newest]

Thread overview: 3+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2016-03-29 02:17 Some bug fixes and improvements Tsunakawa, Takayuki <tsunakawa.takay@jp.fujitsu.com>
2016-03-30 08:31 ` Inoue, Hiroshi <h-inoue@dream.email.ne.jp>
2016-04-01 00:02   ` Tsunakawa, Takayuki <tsunakawa.takay@jp.fujitsu.com>

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox