2 * Description: This module contains UNICODE routines
10 #include "connection.h"
11 #include "statement.h"
13 RETCODE SQL_API
SQLColumnsW(HSTMT StatementHandle
,
14 SQLWCHAR
* CatalogName
,
15 SQLSMALLINT NameLength1
,
16 SQLWCHAR
* SchemaName
,
17 SQLSMALLINT NameLength2
,
19 SQLSMALLINT NameLength3
,
20 SQLWCHAR
* ColumnName
,
21 SQLSMALLINT NameLength4
)
23 CSTR func
= "SQLColumnsW";
25 char *ctName
, *scName
, *tbName
, *clName
;
26 SQLLEN nmlen1
, nmlen2
, nmlen3
, nmlen4
;
27 StatementClass
*stmt
= (StatementClass
*) StatementHandle
;
28 ConnectionClass
*conn
;
30 UWORD flag
= PODBC_SEARCH_PUBLIC_SCHEMA
;
33 conn
= SC_get_conn(stmt
);
34 lower_id
= SC_is_lower_case(stmt
, conn
);
35 ctName
= ucs2_to_utf8(CatalogName
, NameLength1
, &nmlen1
, lower_id
);
36 scName
= ucs2_to_utf8(SchemaName
, NameLength2
, &nmlen2
, lower_id
);
37 tbName
= ucs2_to_utf8(TableName
, NameLength3
, &nmlen3
, lower_id
);
38 clName
= ucs2_to_utf8(ColumnName
, NameLength4
, &nmlen4
, lower_id
);
39 mylog("Params: '%s' '%s' '%s' '%s'\n", ctName
, scName
, tbName
, clName
);
42 StartRollbackState(stmt
);
43 if (stmt
->options
.metadata_id
)
44 flag
|= PODBC_NOT_SEARCH_PATTERN
;
45 if (SC_opencheck(stmt
, func
))
49 PGAPI_Columns(StatementHandle
,
50 (const UCHAR
*)ctName
, (SQLSMALLINT
) nmlen1
,
51 (const UCHAR
*)scName
, (SQLSMALLINT
) nmlen2
,
52 (const UCHAR
*)tbName
, (SQLSMALLINT
) nmlen3
,
53 (const UCHAR
*)clName
, (SQLSMALLINT
) nmlen4
,
55 ret
= DiscardStatementSvp(stmt
, ret
, FALSE
);
69 RETCODE SQL_API
SQLConnectW(HDBC ConnectionHandle
,
70 SQLWCHAR
* ServerName
,
71 SQLSMALLINT NameLength1
,
73 SQLSMALLINT NameLength2
,
74 SQLWCHAR
* Authentication
,
75 SQLSMALLINT NameLength3
)
77 char *svName
, *usName
, *auth
;
78 SQLLEN nmlen1
, nmlen2
, nmlen3
;
80 ConnectionClass
*conn
= (ConnectionClass
*) ConnectionHandle
;
85 CC_set_in_unicode_driver(conn
);
86 svName
= ucs2_to_utf8(ServerName
, NameLength1
, &nmlen1
, FALSE
);
87 usName
= ucs2_to_utf8(UserName
, NameLength2
, &nmlen2
, FALSE
);
88 auth
= ucs2_to_utf8(Authentication
, NameLength3
, &nmlen3
, FALSE
);
89 ret
= PGAPI_Connect(ConnectionHandle
,
90 (const UCHAR
*)svName
, (SQLSMALLINT
) nmlen1
,
91 (const UCHAR
*)usName
, (SQLSMALLINT
) nmlen2
,
92 (const UCHAR
*)auth
, (SQLSMALLINT
) nmlen3
);
103 RETCODE SQL_API
SQLDriverConnectW(HDBC hdbc
,
105 SQLWCHAR
* szConnStrIn
,
106 SQLSMALLINT cbConnStrIn
,
107 SQLWCHAR
* szConnStrOut
,
108 SQLSMALLINT cbConnStrOutMax
,
109 SQLSMALLINT FAR
* pcbConnStrOut
,
110 SQLUSMALLINT fDriverCompletion
)
112 CSTR func
= "SQLDriverConnectW";
113 char *szIn
, *szOut
= NULL
;
114 SQLSMALLINT maxlen
, obuflen
= 0;
116 SQLSMALLINT olen
, *pCSO
;
118 ConnectionClass
*conn
= (ConnectionClass
*) hdbc
;
122 CC_clear_error(conn
);
123 CC_set_in_unicode_driver(conn
);
124 szIn
= ucs2_to_utf8(szConnStrIn
, cbConnStrIn
, &inlen
, FALSE
);
125 maxlen
= cbConnStrOutMax
;
130 obuflen
= maxlen
+ 1;
131 szOut
= (char *)malloc(obuflen
);
133 } else if (pcbConnStrOut
)
135 ret
= PGAPI_DriverConnect(hdbc
, hwnd
,
136 (const UCHAR
*)szIn
, (SQLSMALLINT
) inlen
,
137 (UCHAR
*)szOut
, maxlen
,
138 pCSO
, fDriverCompletion
);
139 if (ret
!= SQL_ERROR
&& NULL
!= pCSO
)
141 SQLLEN outlen
= olen
;
145 utf8_to_ucs2(szOut
, olen
, szConnStrOut
,
148 utf8_to_ucs2(szOut
, maxlen
, szConnStrOut
, cbConnStrOutMax
);
149 if (outlen
>= cbConnStrOutMax
)
151 inolog("cbConnstrOutMax=%d pcb=%p\n", cbConnStrOutMax
,
153 if (SQL_SUCCESS
== ret
)
155 CC_set_error(conn
, CONN_TRUNCATED
,
156 "the ConnStrOut is too small", func
);
157 ret
= SQL_SUCCESS_WITH_INFO
;
161 *pcbConnStrOut
= (SQLSMALLINT
) outlen
;
170 RETCODE SQL_API
SQLBrowseConnectW(HDBC hdbc
,
171 SQLWCHAR
* szConnStrIn
,
172 SQLSMALLINT cbConnStrIn
,
173 SQLWCHAR
* szConnStrOut
,
174 SQLSMALLINT cbConnStrOutMax
,
175 SQLSMALLINT
* pcbConnStrOut
)
179 SQLUSMALLINT obuflen
;
182 ConnectionClass
*conn
= (ConnectionClass
*) hdbc
;
186 CC_clear_error(conn
);
187 CC_set_in_unicode_driver(conn
);
188 szIn
= ucs2_to_utf8(szConnStrIn
, cbConnStrIn
, &inlen
, FALSE
);
189 obuflen
= cbConnStrOutMax
+ 1;
190 szOut
= (char *)malloc(obuflen
);
191 ret
= PGAPI_BrowseConnect(hdbc
,
192 (const UCHAR
*)szIn
, (SQLSMALLINT
)inlen
,
193 (UCHAR
*)szOut
, cbConnStrOutMax
, &olen
);
195 if (ret
!= SQL_ERROR
)
198 utf8_to_ucs2(szOut
, olen
, szConnStrOut
, cbConnStrOutMax
);
200 *pcbConnStrOut
= (SQLSMALLINT
) outlen
;
208 RETCODE SQL_API
SQLDataSourcesW(HENV EnvironmentHandle
,
209 SQLUSMALLINT Direction
,
210 SQLWCHAR
* ServerName
,
211 SQLSMALLINT BufferLength1
,
212 SQLSMALLINT
* NameLength1
,
213 SQLWCHAR
* Description
,
214 SQLSMALLINT BufferLength2
,
215 SQLSMALLINT
* NameLength2
)
219 return PGAPI_DataSources(EnvironmentHandle, Direction, ServerName,
220 BufferLength1, NameLength1, Description, BufferLength2,
226 RETCODE SQL_API
SQLDescribeColW(HSTMT StatementHandle
,
227 SQLUSMALLINT ColumnNumber
,
228 SQLWCHAR
* ColumnName
,
229 SQLSMALLINT BufferLength
,
230 SQLSMALLINT
* NameLength
,
231 SQLSMALLINT
* DataType
,
232 SQLULEN
* ColumnSize
,
233 SQLSMALLINT
* DecimalDigits
,
234 SQLSMALLINT
* Nullable
)
236 CSTR func
= "SQLDescribeColW";
238 StatementClass
*stmt
= (StatementClass
*) StatementHandle
;
239 SQLSMALLINT buflen
, nmlen
;
244 if (BufferLength
> 0)
245 buflen
= BufferLength
* 3;
249 clName
= (char *)malloc(buflen
);
251 SC_clear_error(stmt
);
252 StartRollbackState(stmt
);
253 for (;; buflen
= nmlen
+ 1, clName
= (char *)realloc(clName
, buflen
))
255 ret
= PGAPI_DescribeCol(StatementHandle
, ColumnNumber
,
256 (UCHAR
*)clName
, buflen
, &nmlen
, DataType
,
257 ColumnSize
, DecimalDigits
, Nullable
);
258 if (SQL_SUCCESS_WITH_INFO
!= ret
|| nmlen
< buflen
)
261 if (SQL_SUCCEEDED(ret
))
263 SQLLEN nmcount
= nmlen
;
267 utf8_to_ucs2(clName
, nmlen
, ColumnName
, BufferLength
);
268 if (SQL_SUCCESS
== ret
&& BufferLength
> 0
269 && nmcount
> BufferLength
)
271 ret
= SQL_SUCCESS_WITH_INFO
;
272 SC_set_error(stmt
, STMT_TRUNCATED
, "Column name too large",
276 *NameLength
= (SQLSMALLINT
) nmcount
;
278 ret
= DiscardStatementSvp(stmt
, ret
, FALSE
);
285 RETCODE SQL_API
SQLExecDirectW(HSTMT StatementHandle
,
286 SQLWCHAR
* StatementText
,
287 SQLINTEGER TextLength
)
289 CSTR func
= "SQLExecDirectW";
293 StatementClass
*stmt
= (StatementClass
*) StatementHandle
;
297 stxt
= ucs2_to_utf8(StatementText
, TextLength
, &slen
, FALSE
);
299 SC_clear_error(stmt
);
300 if (PG_VERSION_GE(SC_get_conn(stmt
), 7.4))
301 flag
|= PODBC_WITH_HOLD
;
302 StartRollbackState(stmt
);
303 if (SC_opencheck(stmt
, func
))
307 PGAPI_ExecDirect_Vx(StatementHandle
,
308 (const UCHAR
*)stxt
, (SQLINTEGER
)slen
,
310 ret
= DiscardStatementSvp(stmt
, ret
, FALSE
);
317 RETCODE SQL_API
SQLGetCursorNameW(HSTMT StatementHandle
,
318 SQLWCHAR
* CursorName
,
319 SQLSMALLINT BufferLength
,
320 SQLSMALLINT
* NameLength
)
322 CSTR func
= "SQLGetCursorNameW";
324 StatementClass
*stmt
= (StatementClass
*) StatementHandle
;
326 SQLSMALLINT clen
, buflen
;
329 if (BufferLength
> 0)
330 buflen
= BufferLength
* 3;
333 crName
= (char *)malloc(buflen
);
335 SC_clear_error(stmt
);
336 StartRollbackState(stmt
);
337 for (;; buflen
= clen
+ 1, crName
= (char *)realloc(crName
, buflen
))
340 PGAPI_GetCursorName(StatementHandle
,
341 (UCHAR
*)crName
, buflen
, &clen
);
342 if (SQL_SUCCESS_WITH_INFO
!= ret
|| clen
< buflen
)
345 if (SQL_SUCCEEDED(ret
))
347 SQLLEN nmcount
= clen
;
351 utf8_to_ucs2(crName
, clen
, CursorName
, BufferLength
);
352 if (SQL_SUCCESS
== ret
&& nmcount
> BufferLength
)
354 ret
= SQL_SUCCESS_WITH_INFO
;
355 SC_set_error(stmt
, STMT_TRUNCATED
, "Cursor name too large",
359 *NameLength
= (SQLSMALLINT
) nmcount
;
361 ret
= DiscardStatementSvp(stmt
, ret
, FALSE
);
367 RETCODE SQL_API
SQLGetInfoW(HDBC ConnectionHandle
,
368 SQLUSMALLINT InfoType
, PTR InfoValue
,
369 SQLSMALLINT BufferLength
,
370 SQLSMALLINT
* StringLength
)
372 ConnectionClass
*conn
= (ConnectionClass
*) ConnectionHandle
;
377 CC_set_in_unicode_driver(conn
);
378 CC_clear_error(conn
);
379 if ((ret
= PGAPI_GetInfo(ConnectionHandle
, InfoType
, InfoValue
,
380 BufferLength
, StringLength
)) == SQL_ERROR
)
382 if (conn
->driver_version
>= 0x0300)
384 CC_clear_error(conn
);
385 ret
= PGAPI_GetInfo30(ConnectionHandle
, InfoType
, InfoValue
,
386 BufferLength
, StringLength
);
389 if (SQL_ERROR
== ret
)
390 CC_log_error("SQLGetInfoW(30)", "", conn
);
395 RETCODE SQL_API
SQLPrepareW(HSTMT StatementHandle
,
396 SQLWCHAR
* StatementText
,
397 SQLINTEGER TextLength
)
399 StatementClass
*stmt
= (StatementClass
*) StatementHandle
;
405 stxt
= ucs2_to_utf8(StatementText
, TextLength
, &slen
, FALSE
);
407 SC_clear_error(stmt
);
408 StartRollbackState(stmt
);
409 ret
= PGAPI_Prepare(StatementHandle
,
410 (const UCHAR
*)stxt
, (SQLINTEGER
)slen
);
411 ret
= DiscardStatementSvp(stmt
, ret
, FALSE
);
418 RETCODE SQL_API
SQLSetCursorNameW(HSTMT StatementHandle
,
419 SQLWCHAR
* CursorName
,
420 SQLSMALLINT NameLength
)
423 StatementClass
*stmt
= (StatementClass
*) StatementHandle
;
428 crName
= ucs2_to_utf8(CursorName
, NameLength
, &nlen
, FALSE
);
430 SC_clear_error(stmt
);
431 StartRollbackState(stmt
);
433 PGAPI_SetCursorName(StatementHandle
,
434 (const UCHAR
*)crName
, (SQLSMALLINT
)nlen
);
435 ret
= DiscardStatementSvp(stmt
, ret
, FALSE
);
442 RETCODE SQL_API
SQLSpecialColumnsW(HSTMT StatementHandle
,
443 SQLUSMALLINT IdentifierType
,
444 SQLWCHAR
* CatalogName
,
445 SQLSMALLINT NameLength1
,
446 SQLWCHAR
* SchemaName
,
447 SQLSMALLINT NameLength2
,
448 SQLWCHAR
* TableName
,
449 SQLSMALLINT NameLength3
,
451 SQLUSMALLINT Nullable
)
453 CSTR func
= "SQLSpecialColumnsW";
455 char *ctName
, *scName
, *tbName
;
456 SQLLEN nmlen1
, nmlen2
, nmlen3
;
457 StatementClass
*stmt
= (StatementClass
*) StatementHandle
;
458 ConnectionClass
*conn
;
462 conn
= SC_get_conn(stmt
);
463 lower_id
= SC_is_lower_case(stmt
, conn
);
464 ctName
= ucs2_to_utf8(CatalogName
, NameLength1
, &nmlen1
, lower_id
);
465 scName
= ucs2_to_utf8(SchemaName
, NameLength2
, &nmlen2
, lower_id
);
466 tbName
= ucs2_to_utf8(TableName
, NameLength3
, &nmlen3
, lower_id
);
468 SC_clear_error(stmt
);
469 StartRollbackState(stmt
);
470 if (SC_opencheck(stmt
, func
))
474 PGAPI_SpecialColumns(StatementHandle
, IdentifierType
,
475 (const UCHAR
*)ctName
, (SQLSMALLINT
)nmlen1
,
476 (const UCHAR
*)scName
, (SQLSMALLINT
)nmlen2
,
477 (const UCHAR
*)tbName
, (SQLSMALLINT
)nmlen3
,
479 ret
= DiscardStatementSvp(stmt
, ret
, FALSE
);
490 RETCODE SQL_API
SQLStatisticsW(HSTMT StatementHandle
,
491 SQLWCHAR
* CatalogName
,
492 SQLSMALLINT NameLength1
,
493 SQLWCHAR
* SchemaName
,
494 SQLSMALLINT NameLength2
,
495 SQLWCHAR
* TableName
,
496 SQLSMALLINT NameLength3
,
498 SQLUSMALLINT Reserved
)
500 CSTR func
= "SQLStatisticsW";
502 char *ctName
, *scName
, *tbName
;
503 SQLLEN nmlen1
, nmlen2
, nmlen3
;
504 StatementClass
*stmt
= (StatementClass
*) StatementHandle
;
505 ConnectionClass
*conn
;
509 conn
= SC_get_conn(stmt
);
510 lower_id
= SC_is_lower_case(stmt
, conn
);
511 ctName
= ucs2_to_utf8(CatalogName
, NameLength1
, &nmlen1
, lower_id
);
512 scName
= ucs2_to_utf8(SchemaName
, NameLength2
, &nmlen2
, lower_id
);
513 tbName
= ucs2_to_utf8(TableName
, NameLength3
, &nmlen3
, lower_id
);
516 SC_clear_error(stmt
);
517 StartRollbackState(stmt
);
518 if (SC_opencheck(stmt
, func
))
522 PGAPI_Statistics(StatementHandle
,
523 (const UCHAR
*)ctName
, (SQLSMALLINT
)nmlen1
,
524 (const UCHAR
*)scName
, (SQLSMALLINT
)nmlen2
,
525 (const UCHAR
*)tbName
, (SQLSMALLINT
)nmlen3
,
527 ret
= DiscardStatementSvp(stmt
, ret
, FALSE
);
538 RETCODE SQL_API
SQLTablesW(HSTMT StatementHandle
,
539 SQLWCHAR
* CatalogName
,
540 SQLSMALLINT NameLength1
,
541 SQLWCHAR
* SchemaName
,
542 SQLSMALLINT NameLength2
,
543 SQLWCHAR
* TableName
,
544 SQLSMALLINT NameLength3
,
545 SQLWCHAR
* TableType
,
546 SQLSMALLINT NameLength4
)
548 CSTR func
= "SQLTablesW";
550 char *ctName
, *scName
, *tbName
, *tbType
;
551 SQLLEN nmlen1
, nmlen2
, nmlen3
, nmlen4
;
552 StatementClass
*stmt
= (StatementClass
*) StatementHandle
;
553 ConnectionClass
*conn
;
558 conn
= SC_get_conn(stmt
);
559 lower_id
= SC_is_lower_case(stmt
, conn
);
560 ctName
= ucs2_to_utf8(CatalogName
, NameLength1
, &nmlen1
, lower_id
);
561 scName
= ucs2_to_utf8(SchemaName
, NameLength2
, &nmlen2
, lower_id
);
562 tbName
= ucs2_to_utf8(TableName
, NameLength3
, &nmlen3
, lower_id
);
563 tbType
= ucs2_to_utf8(TableType
, NameLength4
, &nmlen4
, FALSE
);
565 SC_clear_error(stmt
);
566 StartRollbackState(stmt
);
567 if (stmt
->options
.metadata_id
)
568 flag
|= PODBC_NOT_SEARCH_PATTERN
;
569 if (SC_opencheck(stmt
, func
))
573 PGAPI_Tables(StatementHandle
,
574 (const UCHAR
*)ctName
, (SQLSMALLINT
)nmlen1
,
575 (const UCHAR
*)scName
, (SQLSMALLINT
)nmlen2
,
576 (const UCHAR
*)tbName
, (SQLSMALLINT
)nmlen3
,
577 (const UCHAR
*)tbType
, (SQLSMALLINT
) nmlen4
, flag
);
578 ret
= DiscardStatementSvp(stmt
, ret
, FALSE
);
591 RETCODE SQL_API
SQLColumnPrivilegesW(HSTMT hstmt
,
592 SQLWCHAR
* szCatalogName
,
593 SQLSMALLINT cbCatalogName
,
594 SQLWCHAR
* szSchemaName
,
595 SQLSMALLINT cbSchemaName
,
596 SQLWCHAR
* szTableName
,
597 SQLSMALLINT cbTableName
,
598 SQLWCHAR
* szColumnName
,
599 SQLSMALLINT cbColumnName
)
601 CSTR func
= "SQLColumnPrivilegesW";
603 char *ctName
, *scName
, *tbName
, *clName
;
604 SQLLEN nmlen1
, nmlen2
, nmlen3
, nmlen4
;
605 StatementClass
*stmt
= (StatementClass
*) hstmt
;
606 ConnectionClass
*conn
;
611 conn
= SC_get_conn(stmt
);
612 lower_id
= SC_is_lower_case(stmt
, conn
);
614 ucs2_to_utf8(szCatalogName
, cbCatalogName
, &nmlen1
, lower_id
);
616 ucs2_to_utf8(szSchemaName
, cbSchemaName
, &nmlen2
, lower_id
);
617 tbName
= ucs2_to_utf8(szTableName
, cbTableName
, &nmlen3
, lower_id
);
619 ucs2_to_utf8(szColumnName
, cbColumnName
, &nmlen4
, lower_id
);
621 SC_clear_error(stmt
);
622 StartRollbackState(stmt
);
623 if (stmt
->options
.metadata_id
)
624 flag
|= PODBC_NOT_SEARCH_PATTERN
;
625 if (SC_opencheck(stmt
, func
))
629 PGAPI_ColumnPrivileges(hstmt
,
630 (const UCHAR
*)ctName
, (SQLSMALLINT
)nmlen1
,
631 (const UCHAR
*)scName
, (SQLSMALLINT
)nmlen2
,
632 (const UCHAR
*)tbName
, (SQLSMALLINT
)nmlen3
,
633 (const UCHAR
*)clName
, (SQLSMALLINT
)nmlen4
, flag
);
634 ret
= DiscardStatementSvp(stmt
, ret
, FALSE
);
647 RETCODE SQL_API
SQLForeignKeysW(HSTMT hstmt
,
648 SQLWCHAR
* szPkCatalogName
,
649 SQLSMALLINT cbPkCatalogName
,
650 SQLWCHAR
* szPkSchemaName
,
651 SQLSMALLINT cbPkSchemaName
,
652 SQLWCHAR
* szPkTableName
,
653 SQLSMALLINT cbPkTableName
,
654 SQLWCHAR
* szFkCatalogName
,
655 SQLSMALLINT cbFkCatalogName
,
656 SQLWCHAR
* szFkSchemaName
,
657 SQLSMALLINT cbFkSchemaName
,
658 SQLWCHAR
* szFkTableName
,
659 SQLSMALLINT cbFkTableName
)
661 CSTR func
= "SQLForeignKeysW";
663 char *ctName
, *scName
, *tbName
, *fkctName
, *fkscName
, *fktbName
;
664 SQLLEN nmlen1
, nmlen2
, nmlen3
, nmlen4
, nmlen5
, nmlen6
;
665 StatementClass
*stmt
= (StatementClass
*) hstmt
;
666 ConnectionClass
*conn
;
670 conn
= SC_get_conn(stmt
);
671 lower_id
= SC_is_lower_case(stmt
, conn
);
673 ucs2_to_utf8(szPkCatalogName
, cbPkCatalogName
, &nmlen1
,
676 ucs2_to_utf8(szPkSchemaName
, cbPkSchemaName
, &nmlen2
, lower_id
);
678 ucs2_to_utf8(szPkTableName
, cbPkTableName
, &nmlen3
, lower_id
);
680 ucs2_to_utf8(szFkCatalogName
, cbFkCatalogName
, &nmlen4
,
683 ucs2_to_utf8(szFkSchemaName
, cbFkSchemaName
, &nmlen5
, lower_id
);
685 ucs2_to_utf8(szFkTableName
, cbFkTableName
, &nmlen6
, lower_id
);
687 SC_clear_error(stmt
);
688 StartRollbackState(stmt
);
689 if (SC_opencheck(stmt
, func
))
692 ret
= PGAPI_ForeignKeys(hstmt
,
693 (const UCHAR
*)ctName
, (SQLSMALLINT
)nmlen1
,
694 (const UCHAR
*)scName
, (SQLSMALLINT
)nmlen2
,
695 (const UCHAR
*)tbName
, (SQLSMALLINT
)nmlen3
,
696 (const UCHAR
*)fkctName
, (SQLSMALLINT
)nmlen4
,
697 (const UCHAR
*)fkscName
, (SQLSMALLINT
)nmlen5
,
698 (const UCHAR
*)fktbName
, (SQLSMALLINT
)nmlen6
);
699 ret
= DiscardStatementSvp(stmt
, ret
, FALSE
);
716 RETCODE SQL_API
SQLNativeSqlW(HDBC hdbc
,
717 SQLWCHAR
* szSqlStrIn
,
718 SQLINTEGER cbSqlStrIn
,
720 SQLINTEGER cbSqlStrMax
,
721 SQLINTEGER
* pcbSqlStr
)
723 CSTR func
= "SQLNativeSqlW";
725 char *szIn
, *szOut
= NULL
;
727 SQLINTEGER buflen
, olen
;
728 ConnectionClass
*conn
= (ConnectionClass
*) hdbc
;
732 CC_clear_error(conn
);
733 CC_set_in_unicode_driver(conn
);
734 szIn
= ucs2_to_utf8(szSqlStrIn
, cbSqlStrIn
, &slen
, FALSE
);
735 buflen
= 3 * cbSqlStrMax
;
737 szOut
= (char *)malloc(buflen
);
738 for (;; buflen
= olen
+ 1, szOut
= (char *)realloc(szOut
, buflen
))
740 ret
= PGAPI_NativeSql(hdbc
, (const UCHAR
*)szIn
, (SQLINTEGER
)slen
,
741 (UCHAR
*)szOut
, buflen
, &olen
);
742 if (SQL_SUCCESS_WITH_INFO
!= ret
|| olen
< buflen
)
747 if (SQL_SUCCEEDED(ret
))
749 SQLLEN szcount
= olen
;
752 szcount
= utf8_to_ucs2(szOut
, olen
, szSqlStr
, cbSqlStrMax
);
753 if (SQL_SUCCESS
== ret
&& szcount
> cbSqlStrMax
)
755 ConnectionClass
*conn
= (ConnectionClass
*) hdbc
;
757 ret
= SQL_SUCCESS_WITH_INFO
;
758 CC_set_error(conn
, CONN_TRUNCATED
, "Sql string too large",
762 *pcbSqlStr
= (SQLINTEGER
) szcount
;
769 RETCODE SQL_API
SQLPrimaryKeysW(HSTMT hstmt
,
770 SQLWCHAR
* szCatalogName
,
771 SQLSMALLINT cbCatalogName
,
772 SQLWCHAR
* szSchemaName
,
773 SQLSMALLINT cbSchemaName
,
774 SQLWCHAR
* szTableName
,
775 SQLSMALLINT cbTableName
)
777 CSTR func
= "SQLPrimaryKeysW";
779 char *ctName
, *scName
, *tbName
;
780 SQLLEN nmlen1
, nmlen2
, nmlen3
;
781 StatementClass
*stmt
= (StatementClass
*) hstmt
;
782 ConnectionClass
*conn
;
786 conn
= SC_get_conn(stmt
);
787 lower_id
= SC_is_lower_case(stmt
, conn
);
789 ucs2_to_utf8(szCatalogName
, cbCatalogName
, &nmlen1
, lower_id
);
791 ucs2_to_utf8(szSchemaName
, cbSchemaName
, &nmlen2
, lower_id
);
792 tbName
= ucs2_to_utf8(szTableName
, cbTableName
, &nmlen3
, lower_id
);
794 SC_clear_error(stmt
);
795 StartRollbackState(stmt
);
796 if (SC_opencheck(stmt
, func
))
799 ret
= PGAPI_PrimaryKeys(hstmt
,
800 (const UCHAR
*)ctName
, (SQLSMALLINT
)nmlen1
,
801 (const UCHAR
*)scName
, (SQLSMALLINT
)nmlen2
,
802 (const UCHAR
*)tbName
, (SQLSMALLINT
)nmlen3
);
803 ret
= DiscardStatementSvp(stmt
, ret
, FALSE
);
814 RETCODE SQL_API
SQLProcedureColumnsW(HSTMT hstmt
,
815 SQLWCHAR
* szCatalogName
,
816 SQLSMALLINT cbCatalogName
,
817 SQLWCHAR
* szSchemaName
,
818 SQLSMALLINT cbSchemaName
,
819 SQLWCHAR
* szProcName
,
820 SQLSMALLINT cbProcName
,
821 SQLWCHAR
* szColumnName
,
822 SQLSMALLINT cbColumnName
)
824 CSTR func
= "SQLProcedureColumnsW";
826 char *ctName
, *scName
, *prName
, *clName
;
827 SQLLEN nmlen1
, nmlen2
, nmlen3
, nmlen4
;
828 StatementClass
*stmt
= (StatementClass
*) hstmt
;
829 ConnectionClass
*conn
;
834 conn
= SC_get_conn(stmt
);
835 lower_id
= SC_is_lower_case(stmt
, conn
);
837 ucs2_to_utf8(szCatalogName
, cbCatalogName
, &nmlen1
, lower_id
);
839 ucs2_to_utf8(szSchemaName
, cbSchemaName
, &nmlen2
, lower_id
);
840 prName
= ucs2_to_utf8(szProcName
, cbProcName
, &nmlen3
, lower_id
);
842 ucs2_to_utf8(szColumnName
, cbColumnName
, &nmlen4
, lower_id
);
844 SC_clear_error(stmt
);
845 StartRollbackState(stmt
);
846 if (stmt
->options
.metadata_id
)
847 flag
|= PODBC_NOT_SEARCH_PATTERN
;
848 if (SC_opencheck(stmt
, func
))
852 PGAPI_ProcedureColumns(hstmt
,
853 (const UCHAR
*)ctName
, (SQLSMALLINT
)nmlen1
,
854 (const UCHAR
*)scName
, (SQLSMALLINT
)nmlen2
,
855 (const UCHAR
*)prName
, (SQLSMALLINT
)nmlen3
,
856 (const UCHAR
*)clName
, (SQLSMALLINT
)nmlen4
,
858 ret
= DiscardStatementSvp(stmt
, ret
, FALSE
);
871 RETCODE SQL_API
SQLProceduresW(HSTMT hstmt
,
872 SQLWCHAR
* szCatalogName
,
873 SQLSMALLINT cbCatalogName
,
874 SQLWCHAR
* szSchemaName
,
875 SQLSMALLINT cbSchemaName
,
876 SQLWCHAR
* szProcName
,
877 SQLSMALLINT cbProcName
)
879 CSTR func
= "SQLProceduresW";
881 char *ctName
, *scName
, *prName
;
882 SQLLEN nmlen1
, nmlen2
, nmlen3
;
883 StatementClass
*stmt
= (StatementClass
*) hstmt
;
884 ConnectionClass
*conn
;
889 conn
= SC_get_conn(stmt
);
890 lower_id
= SC_is_lower_case(stmt
, conn
);
892 ucs2_to_utf8(szCatalogName
, cbCatalogName
, &nmlen1
, lower_id
);
894 ucs2_to_utf8(szSchemaName
, cbSchemaName
, &nmlen2
, lower_id
);
895 prName
= ucs2_to_utf8(szProcName
, cbProcName
, &nmlen3
, lower_id
);
897 SC_clear_error(stmt
);
898 StartRollbackState(stmt
);
899 if (stmt
->options
.metadata_id
)
900 flag
|= PODBC_NOT_SEARCH_PATTERN
;
901 if (SC_opencheck(stmt
, func
))
904 ret
= PGAPI_Procedures(hstmt
,
905 (const UCHAR
*)ctName
, (SQLSMALLINT
)nmlen1
,
906 (const UCHAR
*)scName
, (SQLSMALLINT
)nmlen2
,
907 (const UCHAR
*)prName
, (SQLSMALLINT
)nmlen3
,
909 ret
= DiscardStatementSvp(stmt
, ret
, FALSE
);
920 RETCODE SQL_API
SQLTablePrivilegesW(HSTMT hstmt
,
921 SQLWCHAR
* szCatalogName
,
922 SQLSMALLINT cbCatalogName
,
923 SQLWCHAR
* szSchemaName
,
924 SQLSMALLINT cbSchemaName
,
925 SQLWCHAR
* szTableName
,
926 SQLSMALLINT cbTableName
)
928 CSTR func
= "SQLTablePrivilegesW";
930 char *ctName
, *scName
, *tbName
;
931 SQLLEN nmlen1
, nmlen2
, nmlen3
;
932 StatementClass
*stmt
= (StatementClass
*) hstmt
;
933 ConnectionClass
*conn
;
938 conn
= SC_get_conn(stmt
);
939 lower_id
= SC_is_lower_case(stmt
, conn
);
941 ucs2_to_utf8(szCatalogName
, cbCatalogName
, &nmlen1
, lower_id
);
943 ucs2_to_utf8(szSchemaName
, cbSchemaName
, &nmlen2
, lower_id
);
944 tbName
= ucs2_to_utf8(szTableName
, cbTableName
, &nmlen3
, lower_id
);
945 ENTER_STMT_CS((StatementClass
*) hstmt
);
946 SC_clear_error(stmt
);
947 StartRollbackState(stmt
);
948 if (stmt
->options
.metadata_id
)
949 flag
|= PODBC_NOT_SEARCH_PATTERN
;
950 if (SC_opencheck(stmt
, func
))
953 ret
= PGAPI_TablePrivileges(hstmt
,
954 (const UCHAR
*)ctName
, (SQLSMALLINT
)nmlen1
,
955 (const UCHAR
*)scName
, (SQLSMALLINT
)nmlen2
,
956 (const UCHAR
*)tbName
, (SQLSMALLINT
)nmlen3
,
958 ret
= DiscardStatementSvp(stmt
, ret
, FALSE
);
959 LEAVE_STMT_CS((StatementClass
*) hstmt
);
969 RETCODE SQL_API
SQLGetTypeInfoW(SQLHSTMT StatementHandle
,
970 SQLSMALLINT DataType
)
973 CSTR func
= "SQLGetTypeInfoW";
975 StatementClass
*stmt
= (StatementClass
*) StatementHandle
;
978 SC_clear_error(stmt
);
979 StartRollbackState(stmt
);
980 if (SC_opencheck(stmt
, func
))
983 ret
= PGAPI_GetTypeInfo(StatementHandle
, DataType
);
984 ret
= DiscardStatementSvp(stmt
, ret
, FALSE
);