Skip to content

Commit cc52469

Browse files
authored
Merge branch 'main' into version16
2 parents bd9d86c + ab76a10 commit cc52469

20 files changed

+612
-54
lines changed

.github/workflows/main.yml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ on:
66
branches: [ "main" ]
77
tags:
88
- 'REL-*'
9+
- '!REL-*-mimalloc'
910
pull_request:
1011
branches: [ "main" ]
1112

@@ -23,9 +24,9 @@ env:
2324
WORKFLOW_VERSION_POSTGRESQL: '1' # for build steps related to the 'cachePostgres' cache
2425

2526
# Software versions.
26-
POSTGRESQL_SOURCE_TAG: 'REL_16_3'
27+
POSTGRESQL_SOURCE_TAG: 'REL_17_STABLE'
2728
POSTGRESQL_PACKAGE_FILEID: '1259019'
28-
OPENSSL_VERSION: '3_3_0'
29+
OPENSSL_VERSION: '3_3_2'
2930
PKGCONFIGLITE_VERSION: '0.28-1'
3031
WINFLEXBISON_VERSION: '2.5.24'
3132
DIFFUTILS_VERSION: '2.8.7-1'

.gitignore

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,13 +36,15 @@ windows-local.mak
3636
/Makefile.in
3737
/aclocal.m4
3838
/autom4te.cache/
39+
/autom4te.cache/*
3940
/config/
4041
/config.h
4142
/config.h.in
4243
/config.log
4344
/config.status
4445
/configure
4546
/libtool
47+
/psqlodbca.la
4648
/psqlodbcw.la
4749
/stamp-h1
4850

@@ -107,6 +109,11 @@ bld/
107109
[Ll]og/
108110
[Ll]ogs/
109111

112+
# Eclipse project options
113+
/.project
114+
/.cproject
115+
/.settings
116+
110117
# Visual Studio 2015/2017 cache/options directory
111118
.vs/
112119
# Uncomment if you have tasks that create the project's static files in wwwroot

connection.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -556,6 +556,7 @@ CC_clear_col_info(ConnectionClass *self, BOOL destroy)
556556
/* Going through COL_INFO cache table and releasing coli objects. */
557557
if (coli = self->col_info[i], NULL != coli)
558558
{
559+
MYLOG(0, "!!!refcnt %p:%d -> %d\n", coli, coli->refcnt, coli->refcnt - 1);
559560
coli->refcnt--;
560561
if (coli->refcnt <= 0)
561562
{

convert.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1389,7 +1389,7 @@ MYLOG(0, "null_cvt_date_string=%d\n", conn->connInfo.cvt_null_date_string);
13891389
else
13901390
{
13911391
SC_set_error(stmt, STMT_RETURN_NULL_WITHOUT_INDICATOR, "StrLen_or_IndPtr was a null pointer and NULL data was retrieved", func);
1392-
return SQL_ERROR;
1392+
return COPY_GENERAL_ERROR;
13931393
}
13941394
}
13951395

descriptor.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -705,6 +705,8 @@ static const struct
705705
{ DESC_OPTION_NOT_FOR_THE_DRIVER, "HYC00", "HYC00" },
706706
{ DESC_FETCH_OUT_OF_RANGE, "HY106", "S1106" },
707707
{ DESC_COUNT_FIELD_INCORRECT, "07002", "07002" },
708+
{ DESC_STATEMENT_NOT_PREPARED, "HY007", "S1010" },
709+
{ DESC_STRING_DATA_TRUNCATED, "01004", "01004"}
708710
};
709711

710712
static PG_ErrorInfo *DC_create_errorinfo(const DescriptorClass *self)

descriptor.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -262,5 +262,7 @@ enum {
262262
,DESC_OPTION_NOT_FOR_THE_DRIVER
263263
,DESC_FETCH_OUT_OF_RANGE
264264
,DESC_COUNT_FIELD_INCORRECT
265+
,DESC_STATEMENT_NOT_PREPARED
266+
,DESC_STRING_DATA_TRUNCATED
265267
};
266268
#endif /* __DESCRIPTOR_H__ */

docs/release.html

Lines changed: 57 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,63 @@
66
</HEAD>
77

88
<body bgcolor="#ffffff" text="#000000" link="#ff0000" vlink="#a00000" alink="#0000ff">
9-
9+
1010
<h1>psqlODBC release notes</h1>
1111
<hr>
12+
<ol type="1">
13+
<h2><a id="17.00.0000">psqlODBC 17.00.0000 Release</a></h2>
14+
Changes:<br />
15+
<li>
16+
Release: Update version numbers <a href="https://github.com/postgresql-interfaces/psqlodbc/pull/52">PR #52</a>
17+
Author: <a href="https://github.com/davecramer">Dave Cramer</a>
18+
</li>
19+
</ol>
20+
<ol type="1">
21+
<h2><a id="16.00.0006">psqlODBC 16.00.0006 Release</a></h2>
22+
Changes:<br />
23+
<li>
24+
Change: Build against PostgreSQL 17 RC1 <a href="https://github.com/postgresql-interfaces/psqlodbc/pull/44">PR #44</a>
25+
Author: <a href="https://github.com/davecramer">Dave Cramer</a>
26+
</li>
27+
<li>
28+
Fix: Double free of COL_INFO object <a href="https://github.com/postgresql-interfaces/psqlodbc/pull/48">PR #48</a>
29+
Fixes <a href="https://github.com/postgresql-interfaces/psqlodbc/issues/47"> Issue #47</a>
30+
Author: <a href="https://github.com/progmachine">Alexandr Kuznetsov</a>
31+
</li>
32+
33+
<h2><a id="16.00.0005">psqlODBC 16.00.0005 Release</a></h2>
34+
Changes:<br />
35+
<ol type="1">
36+
<li>Fix: if the connection is broken when calling SQLFreeHandle, the client can't be notified <a href="https://github.com/postgresql-interfaces/psqlodbc/pull/1">PR #1</a>
37+
Author: <a href="https://github.com/apgrucza"> Adrian Grucza</a></li>
38+
<li>Perf: Use mimalloc to improve performance and reduce memory allocation lock contention <a href="https://github.com/postgresql-interfaces/psqlodbc/pull/6">PR#6</a></li>
39+
<li>Add: Build and release using github actions <a href="https://github.com/postgresql-interfaces/psqlodbc/pull/7">PR#7</a></li>
40+
<li>Add: Support building against VC17 on AMD64 <a href="https://github.com/postgresql-interfaces/psqlodbc/pull/9">PR#9</a>
41+
Author: <a href="https://github.com/apgrucza"> Adrian Grucza</a></li>
42+
<li>Fix: Fixed typos in all source code and documentations <a href="https://github.com/postgresql-interfaces/psqlodbc/pull/11">PR#11</a>
43+
Author <a href="https://github.com/Hunaid2000">Hunaid Sohail</a></li>
44+
<li>Fix: during call SQLFreeHandle, if the connection is broken the client is not notified <a href-"https://github.com/postgresql-interfaces/psqlodbc/pull/12">PR #12</a>
45+
Author: <a href="https://github.com/apgrucza"> Adrian Grucza</a></li>
46+
</li>
47+
<li>Fix: Key caches based on software versions <a href-"https://github.com/postgresql-interfaces/psqlodbc/pull/13">PR #13</a><
48+
Author: <a href="https://github.com/apgrucza"> Adrian Grucza</a></li>
49+
<li>Add: Add mimalloc release <a href-"https://github.com/postgresql-interfaces/psqlodbc/pull/14">PR #14</a>
50+
Author: <a href="https://github.com/apgrucza"> Adrian Grucza</a></li>
51+
<li>Fix: Use strdup on non-Windows systems <a href-"https://github.com/postgresql-interfaces/psqlodbc/pull/17">PR #17</a>
52+
Author: <a href="https://github.com/apgrucza"> Adrian Grucza</a></li>
53+
<li>Add: Implementation of SQLSetDescRec & SQLGetDescRec functions <a href="https://github.com/postgresql-interfaces/psqlodbc/pull/23">PR#23</a>
54+
Author <a href="https://github.com/Hunaid2000">Hunaid Sohail</a></li>
55+
<li>Fix: Fix Memory leaks <a href="https://github.com/postgresql-interfaces/psqlodbc/issues/8">Issue #8</a> <a href="https://github.com/postgresql-interfaces/psqlodbc/pull/25">PR#25</a>
56+
Author: <a href="https://github.com/progmachine">Alexandr Kuznetsov</a>
57+
</li>
58+
<li> Fix: SQLGetData function can return an incorrect SQLSTATE <a href="https://github.com/postgresql-interfaces/psqlodbc/issues/33">Issue #33</a> <a href="https://github.com/postgresql-interfaces/psqlodbc/pull/35"> PR #35</a>
59+
Author: <a href=""https://github.com/omeuid">Carlos García</a>
60+
</li>
61+
<li>
62+
Change: Build against PostgreSQL 17 Beta3 <a href="https://github.com/postgresql-interfaces/psqlodbc/pull/37">PR #37</a>
63+
Author: <a href="https://github.com/davecramer">Dave Cramer</a>
64+
</li>
65+
</ol>
1266
<h2><a id="16.00.0000">psqlODBC 16.00.0000 Release</a></h2>
1367
Changes:<br />
1468
<ol type="1">
@@ -27,7 +81,7 @@ <h2><a id="15.00.0000">psqlODBC 15.00.0000 Release</a></h2>
2781
<h2><a id="13.02.0000">psqlODBC 13.02.0000 Release</a></h2>
2882
Changes:<br />
2983
<ol type="1">
30-
<li>Fix a bug of CC_send_query_append() when the ignore_roundtrip_time flag is onRemove a mylog() call which is a dupilicate of the preceding MYLOG() macro call.</li>
84+
<li>Fix a bug of CC_send_query_append() when the ignore_roundtrip_time flag is onRemove a mylog() call which is a duplicate of the preceding MYLOG() macro call.</li>
3185
Also direct use of mylog() should be avoided because mylog() uses lots of CPU.
3286
<li>Noticed that the password field on the PostgreSQL Connection</li>
3387
dialog is always focused when empty, even when other fields that appear
@@ -90,7 +144,7 @@ <h2><a id="12.02.0000">psqlODBC 12.02.0000 Release</a></h2>
90144
<li>Add a new *Display Optional Error Message* option. </li>
91145
This option allows to
92146
display error messages other than primary one.
93-
Also add documentaition about the option and *Numeric as* option.
147+
Also add documentation about the option and *Numeric as* option.
94148
<li>Handle notice messages in libpq_bind_and_exec().</li>
95149
Sets and resets a notify receiver around PQexecParams() or PQexecPrepared().
96150
<li>Ignore PQtransactionStatus PQTRANS_ACTIVE in LIBPQ_update_transaction_status().

info.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1565,18 +1565,18 @@ PGAPI_GetFunctions(HDBC hdbc,
15651565
case SQL_API_SQLFREEHANDLE: /* 1006 */
15661566
case SQL_API_SQLGETCONNECTATTR: /* 1007 */
15671567
case SQL_API_SQLGETDESCFIELD: /* 1008 */
1568+
case SQL_API_SQLGETDESCREC: /* 1009 */
15681569
case SQL_API_SQLGETDIAGFIELD: /* 1010 */
15691570
case SQL_API_SQLGETDIAGREC: /* 1011 */
15701571
case SQL_API_SQLGETENVATTR: /* 1012 */
15711572
case SQL_API_SQLGETSTMTATTR: /* 1014 */
15721573
case SQL_API_SQLSETCONNECTATTR: /* 1016 */
15731574
case SQL_API_SQLSETDESCFIELD: /* 1017 */
1575+
case SQL_API_SQLSETDESCREC: /* 1018 */
15741576
case SQL_API_SQLSETENVATTR: /* 1019 */
15751577
case SQL_API_SQLSETSTMTATTR: /* 1020 */
15761578
*pfExists = TRUE;
15771579
break;
1578-
case SQL_API_SQLGETDESCREC: /* 1009 */
1579-
case SQL_API_SQLSETDESCREC: /* 1018 */
15801580
case SQL_API_SQLCOPYDESC: /* 1004 */
15811581
*pfExists = FALSE;
15821582
break;

odbcapi30.c

Lines changed: 18 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -308,9 +308,14 @@ SQLGetDescRec(SQLHDESC DescriptorHandle,
308308
SQLLEN *Length, SQLSMALLINT *Precision,
309309
SQLSMALLINT *Scale, SQLSMALLINT *Nullable)
310310
{
311-
MYLOG(0, "Entering\n");
312-
MYLOG(0, "Error not implemented\n");
313-
return SQL_ERROR;
311+
RETCODE ret;
312+
313+
MYLOG(0, "Entering h=%p rec=%d name=%p blen=%d\n", DescriptorHandle, RecNumber, Name, BufferLength);
314+
MYLOG(0, "str=%p type=%p sub=%p len=%p prec=%p scale=%p null=%p\n", StringLength, Type, SubType, Length, Precision, Scale, Nullable);
315+
ret = PGAPI_GetDescRec(DescriptorHandle, RecNumber, Name, BufferLength,
316+
StringLength, Type, SubType, Length, Precision,
317+
Scale, Nullable);
318+
return ret;
314319
}
315320

316321
/* new function */
@@ -459,9 +464,14 @@ SQLSetDescRec(SQLHDESC DescriptorHandle,
459464
PTR Data, SQLLEN *StringLength,
460465
SQLLEN *Indicator)
461466
{
462-
MYLOG(0, "Entering\n");
463-
MYLOG(0, "Error not implemented\n");
464-
return SQL_ERROR;
467+
RETCODE ret;
468+
469+
MYLOG(0, "Entering h=%p rec=%d type=%d sub=%d len=" FORMAT_LEN " prec=%d scale=%d data=%p\n", DescriptorHandle, RecNumber, Type, SubType, Length, Precision, Scale, Data);
470+
MYLOG(0, "str=%p ind=%p\n", StringLength, Indicator);
471+
ret = PGAPI_SetDescRec(DescriptorHandle, RecNumber, Type,
472+
SubType, Length, Precision, Scale, Data,
473+
StringLength, Indicator);
474+
return ret;
465475
}
466476
#endif /* UNICODE_SUPPORTXX */
467477

@@ -646,20 +656,14 @@ MYLOG(DETAIL_LOG_LEVEL, "lie=%d\n", ci->drivers.lie);
646656
SQL_FUNC_ESET(pfExists, SQL_API_SQLFREEHANDLE); /* 1006 */
647657
SQL_FUNC_ESET(pfExists, SQL_API_SQLGETCONNECTATTR); /* 1007 */
648658
SQL_FUNC_ESET(pfExists, SQL_API_SQLGETDESCFIELD); /* 1008 */
649-
if (ci->drivers.lie)
650-
{
651-
SQL_FUNC_ESET(pfExists, SQL_API_SQLGETDESCREC); /* 1009 not implemented yet */
652-
}
659+
SQL_FUNC_ESET(pfExists, SQL_API_SQLGETDESCREC); /* 1009 */
653660
SQL_FUNC_ESET(pfExists, SQL_API_SQLGETDIAGFIELD); /* 1010 minimal implementation */
654661
SQL_FUNC_ESET(pfExists, SQL_API_SQLGETDIAGREC); /* 1011 */
655662
SQL_FUNC_ESET(pfExists, SQL_API_SQLGETENVATTR); /* 1012 */
656663
SQL_FUNC_ESET(pfExists, SQL_API_SQLGETSTMTATTR); /* 1014 */
657664
SQL_FUNC_ESET(pfExists, SQL_API_SQLSETCONNECTATTR); /* 1016 */
658665
SQL_FUNC_ESET(pfExists, SQL_API_SQLSETDESCFIELD); /* 1017 */
659-
if (ci->drivers.lie)
660-
{
661-
SQL_FUNC_ESET(pfExists, SQL_API_SQLSETDESCREC); /* 1018 not implemented yet */
662-
}
666+
SQL_FUNC_ESET(pfExists, SQL_API_SQLSETDESCREC); /* 1018 */
663667
SQL_FUNC_ESET(pfExists, SQL_API_SQLSETENVATTR); /* 1019 */
664668
SQL_FUNC_ESET(pfExists, SQL_API_SQLSETSTMTATTR); /* 1020 */
665669
SQL_FUNC_ESET(pfExists, SQL_API_SQLFETCHSCROLL); /* 1021 */

odbcapi30w.c

Lines changed: 55 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -426,9 +426,37 @@ SQLGetDescRecW(SQLHDESC DescriptorHandle,
426426
SQLLEN *Length, SQLSMALLINT *Precision,
427427
SQLSMALLINT *Scale, SQLSMALLINT *Nullable)
428428
{
429-
MYLOG(0, "Entering\n");
430-
MYLOG(0, "Error not implemented\n");
431-
return SQL_ERROR;
429+
RETCODE ret;
430+
char *NameA = NULL;
431+
SQLSMALLINT nlen;
432+
433+
MYLOG(0, "Entering h=%p rec=%d name=%p blen=%d\n", DescriptorHandle, RecNumber, Name, BufferLength);
434+
MYLOG(0, "str=%p type=%p sub=%p len=%p prec=%p scale=%p null=%p\n", StringLength, Type, SubType, Length, Precision, Scale, Nullable);
435+
436+
if (BufferLength > 0)
437+
NameA = malloc(BufferLength);
438+
439+
ret = PGAPI_GetDescRec(DescriptorHandle, RecNumber, (SQLCHAR *) NameA, BufferLength,
440+
&nlen, Type, SubType, Length, Precision,
441+
Scale, Nullable);
442+
if (SQL_SUCCEEDED(ret))
443+
{
444+
if (NameA && nlen <= BufferLength)
445+
{
446+
SQLULEN ulen = utf8_to_ucs2_lf(NameA, nlen, FALSE, Name, BufferLength, TRUE);
447+
if (ulen == (SQLULEN) -1)
448+
nlen = (SQLSMALLINT) locale_to_sqlwchar((SQLWCHAR *) Name, NameA, BufferLength, FALSE);
449+
else
450+
nlen = (SQLSMALLINT) ulen;
451+
if (nlen >= BufferLength)
452+
ret = SQL_SUCCESS_WITH_INFO;
453+
}
454+
if (StringLength)
455+
*StringLength = nlen;
456+
}
457+
if (NameA)
458+
free(NameA);
459+
return ret;
432460
}
433461

434462
/* new function */
@@ -440,7 +468,28 @@ SQLSetDescRecW(SQLHDESC DescriptorHandle,
440468
PTR Data, SQLLEN *StringLength,
441469
SQLLEN *Indicator)
442470
{
443-
MYLOG(0, "Entering\n");
444-
MYLOG(0, "Error not implemented\n");
445-
return SQL_ERROR;
471+
RETCODE ret;
472+
SQLLEN vallen;
473+
char *uval = NULL;
474+
BOOL val_alloced = FALSE;
475+
476+
MYLOG(0, "Entering h=%p rec=%d type=%d sub=%d len=" FORMAT_LEN " prec=%d scale=%d data=%p\n", DescriptorHandle, RecNumber, Type, SubType, Length, Precision, Scale, Data);
477+
MYLOG(0, "str=%p ind=%p\n", StringLength, Indicator);
478+
479+
if (Length > 0 || SQL_NTS == Length)
480+
{
481+
uval = ucs2_to_utf8(Data, Length > 0 ? Length / WCLEN : Length, &vallen, FALSE);
482+
val_alloced = TRUE;
483+
}
484+
if (!val_alloced)
485+
{
486+
uval = Data;
487+
vallen = Length;
488+
}
489+
ret = PGAPI_SetDescRec(DescriptorHandle, RecNumber, Type,
490+
SubType, Length, Precision, Scale, uval,
491+
&vallen, Indicator);
492+
if (val_alloced)
493+
free(uval);
494+
return ret;
446495
}

parse.c

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -829,7 +829,7 @@ getColumnsInfo(ConnectionClass *conn, TABLE_INFO *wti, OID greloid, StatementCla
829829
{
830830
BOOL coli_exist = FALSE;
831831
COL_INFO *coli = NULL, *ccoli = NULL, *tcoli;
832-
int k;
832+
int k, tmp_refcnt = 0;
833833
time_t acctime = 0;
834834

835835
MYLOG(0, " Success\n");
@@ -882,6 +882,8 @@ getColumnsInfo(ConnectionClass *conn, TABLE_INFO *wti, OID greloid, StatementCla
882882
if (coli_exist)
883883
{
884884
/* We have ready to use coli object. Cleaning it. */
885+
tmp_refcnt = coli->refcnt; /* If we found coli with greloid, then some TABLE_INFO objects may have references to it -> save refcnt for them. */
886+
tmp_refcnt--; /* Down the road we will increase refcnt again to account for the reference from ConnectionClass object to coli object. */
885887
free_col_info_contents(coli);
886888
}
887889
else
@@ -921,6 +923,7 @@ getColumnsInfo(ConnectionClass *conn, TABLE_INFO *wti, OID greloid, StatementCla
921923
}
922924
col_info_initialize(coli);
923925

926+
coli->refcnt = tmp_refcnt;
924927
coli->refcnt++; /* Counting one reference to coli object from connection COL_INFO cache table. */
925928
coli->result = res;
926929
if (res && QR_get_num_cached_tuples(res) > 0)
@@ -976,6 +979,17 @@ MYLOG(DETAIL_LOG_LEVEL, "oid item == %s\n", (const char *) QR_get_value_backend_
976979
MYLOG(0, "Created col_info table='%s', ntables=%d\n", PRINT_NAME(wti->table_name), conn->ntables);
977980
/* Associate a table from the statement with a SQLColumn info */
978981
found = TRUE;
982+
if (wti->col_info)
983+
{
984+
/* wti also has reference to COL_INFO object, so we must release it. */
985+
MYLOG(0, "!!!refcnt %p:%d -> %d\n", wti->col_info, wti->col_info->refcnt, wti->col_info->refcnt - 1);
986+
wti->col_info->refcnt--;
987+
if (wti->col_info->refcnt <= 0)
988+
{
989+
free_col_info_contents(wti->col_info);
990+
free(wti->col_info);
991+
}
992+
}
979993
coli->refcnt++; /* Counting another one reference to coli object from TABLE_INFO wti object. */
980994
wti->col_info = coli;
981995
}

0 commit comments

Comments
 (0)