mirror of
https://github.com/postgres/postgres.git
synced 2026-05-28 04:35:45 -04:00
ECPGdeallocate_all(), ECPGprepared_statement(), ECPGget_desc(), and ecpg_freeStmtCacheEntry() could crash with a SIGSEGV when called without an established connection (for example, when EXEC SQL CONNECT was forgotten or a non-existent connection name was used), because they dereferenced the result of ecpg_get_connection() without first checking it for NULL. Each site is fixed in the style of the surrounding code. New tests are added for these conditions. Author: Shruthi Gowda <gowdashru@gmail.com> Reviewed-by: Tom Lane <tgl@sss.pgh.pa.us> Reviewed-by: Fujii Masao <masao.fujii@gmail.com> Reviewed-by: Mahendra Singh Thalor <mahi6run@gmail.com> Reviewed-by: Nishant Sharma <nishant.sharma@enterprisedb.com> Discussion: https://postgr.es/m/3007317.1765210195@sss.pgh.pa.us Backpatch-through: 14
50 lines
2.9 KiB
Text
50 lines
2.9 KiB
Text
[NO_PID]: ECPGdebug: set to 1
|
|
[NO_PID]: sqlca: code: 0, state: 00000
|
|
[NO_PID]: ECPGconnect: opening database ecpg1_regression on <DEFAULT> port <DEFAULT>
|
|
[NO_PID]: sqlca: code: 0, state: 00000
|
|
[NO_PID]: ecpg_execute on line 30: query: create table test1 ( a int , b text ); with 0 parameter(s) on connection myconn
|
|
[NO_PID]: sqlca: code: 0, state: 00000
|
|
[NO_PID]: ecpg_execute on line 30: using PQexec
|
|
[NO_PID]: sqlca: code: 0, state: 00000
|
|
[NO_PID]: ecpg_process_output on line 30: OK: CREATE TABLE
|
|
[NO_PID]: sqlca: code: 0, state: 00000
|
|
[NO_PID]: ecpg_execute on line 31: query: insert into test1 ( a , b ) values ( 1 , 'data1' ); with 0 parameter(s) on connection myconn
|
|
[NO_PID]: sqlca: code: 0, state: 00000
|
|
[NO_PID]: ecpg_execute on line 31: using PQexec
|
|
[NO_PID]: sqlca: code: 0, state: 00000
|
|
[NO_PID]: ecpg_process_output on line 31: OK: INSERT 0 1
|
|
[NO_PID]: sqlca: code: 0, state: 00000
|
|
[NO_PID]: prepare_common on line 36: name foo2; query: "SELECT * from test1 where a = $1 and b = $2"
|
|
[NO_PID]: sqlca: code: 0, state: 00000
|
|
[NO_PID]: ecpg_execute on line 41: query: SELECT * from test1 where a = $1 and b = $2; with 2 parameter(s) on connection myconn
|
|
[NO_PID]: sqlca: code: 0, state: 00000
|
|
[NO_PID]: ecpg_execute on line 41: using PQexecPrepared for "SELECT * from test1 where a = $1 and b = $2"
|
|
[NO_PID]: sqlca: code: 0, state: 00000
|
|
[NO_PID]: ecpg_free_params on line 41: parameter 1 = 1
|
|
[NO_PID]: sqlca: code: 0, state: 00000
|
|
[NO_PID]: ecpg_free_params on line 41: parameter 2 = data1
|
|
[NO_PID]: sqlca: code: 0, state: 00000
|
|
[NO_PID]: ecpg_process_output on line 41: correctly got 1 tuples with 2 fields
|
|
[NO_PID]: sqlca: code: 0, state: 00000
|
|
[NO_PID]: ecpg_process_output on line 41: putting result (1 tuples) into descriptor outdesc
|
|
[NO_PID]: sqlca: code: 0, state: 00000
|
|
[NO_PID]: ECPGtrans on line 43: action "rollback"; connection "myconn"
|
|
[NO_PID]: sqlca: code: 0, state: 00000
|
|
[NO_PID]: deallocate_one on line 0: name foo2
|
|
[NO_PID]: sqlca: code: 0, state: 00000
|
|
[NO_PID]: ecpg_finish: connection myconn closed
|
|
[NO_PID]: sqlca: code: 0, state: 00000
|
|
[NO_PID]: ECPGget_desc: reading items for tuple 1
|
|
[NO_PID]: sqlca: code: 0, state: 00000
|
|
[NO_PID]: raising sqlcode -220 on line 45: connection "NULL" does not exist on line 45
|
|
[NO_PID]: sqlca: code: -220, state: 08003
|
|
[NO_PID]: raising sqlcode -220 on line 50: connection "nonexistent" does not exist on line 50
|
|
[NO_PID]: sqlca: code: -220, state: 08003
|
|
[NO_PID]: raising sqlcode -220 on line 55: connection "NULL" does not exist on line 55
|
|
[NO_PID]: sqlca: code: -220, state: 08003
|
|
[NO_PID]: raising sqlcode -220 on line 60: connection "nonexistent" does not exist on line 60
|
|
[NO_PID]: sqlca: code: -220, state: 08003
|
|
[NO_PID]: raising sqlcode -220 on line 63: connection "nonexistent" does not exist on line 63
|
|
[NO_PID]: sqlca: code: -220, state: 08003
|
|
[NO_PID]: raising sqlcode -220 on line 62: connection "nonexistent" does not exist on line 62
|
|
[NO_PID]: sqlca: code: -220, state: 08003
|