@@ -313,7 +313,35 @@ SQLGetDescField(SQLHDESC DescriptorHandle,
313
313
return ret ;
314
314
}
315
315
316
- /* new function */
316
+ /*
317
+ * SQLGetDescRec
318
+ *
319
+ * Description:
320
+ * This function retrieves the current settings or values of fields in a descriptor record.
321
+ * It's the ANSI version of the function that works with descriptor records.
322
+ *
323
+ * Parameters:
324
+ * DescriptorHandle - Handle to the descriptor
325
+ * RecNumber - The descriptor record number (1-based)
326
+ * Name - Buffer to store the descriptor name (ANSI)
327
+ * BufferLength - Length of the Name buffer in bytes
328
+ * StringLength - Pointer to store the actual length of the name
329
+ * Type - Pointer to store the SQL data type
330
+ * SubType - Pointer to store the data type subcode
331
+ * Length - Pointer to store the data length
332
+ * Precision - Pointer to store the numeric precision
333
+ * Scale - Pointer to store the numeric scale
334
+ * Nullable - Pointer to store the nullability attribute
335
+ *
336
+ * Returns:
337
+ * SQL_SUCCESS, SQL_SUCCESS_WITH_INFO, SQL_ERROR, or SQL_INVALID_HANDLE
338
+ *
339
+ * Comments:
340
+ * This function is a thin wrapper around PGAPI_GetDescRec, which contains
341
+ * the actual implementation. Unlike the wide-character version (SQLGetDescRecW),
342
+ * this function doesn't need to perform character set conversion since it
343
+ * works directly with ANSI strings.
344
+ */
317
345
RETCODE SQL_API
318
346
SQLGetDescRec (SQLHDESC DescriptorHandle ,
319
347
SQLSMALLINT RecNumber , SQLCHAR * Name ,
@@ -326,9 +354,11 @@ SQLGetDescRec(SQLHDESC DescriptorHandle,
326
354
327
355
MYLOG (0 , "Entering h=%p rec=%d name=%p blen=%d\n" , DescriptorHandle , RecNumber , Name , BufferLength );
328
356
MYLOG (0 , "str=%p type=%p sub=%p len=%p prec=%p scale=%p null=%p\n" , StringLength , Type , SubType , Length , Precision , Scale , Nullable );
357
+
329
358
ret = PGAPI_GetDescRec (DescriptorHandle , RecNumber , Name , BufferLength ,
330
359
StringLength , Type , SubType , Length , Precision ,
331
360
Scale , Nullable );
361
+
332
362
return ret ;
333
363
}
334
364
@@ -416,7 +446,28 @@ SQLGetConnectAttr(HDBC ConnectionHandle,
416
446
return ret ;
417
447
}
418
448
419
- /* SQLGetStmtOption -> SQLGetStmtAttr */
449
+ /*
450
+ * SQLGetStmtAttr
451
+ *
452
+ * Description:
453
+ * This function retrieves the current setting of a statement attribute.
454
+ * This is the ANSI version of the function.
455
+ *
456
+ * Parameters:
457
+ * StatementHandle - Handle to the statement
458
+ * Attribute - The attribute to retrieve (SQL_ATTR_* constant)
459
+ * Value - Buffer to store the attribute value
460
+ * BufferLength - Length of the Value buffer in bytes
461
+ * StringLength - Pointer to store the actual length of string data
462
+ *
463
+ * Returns:
464
+ * SQL_SUCCESS, SQL_SUCCESS_WITH_INFO, SQL_ERROR, or SQL_INVALID_HANDLE
465
+ *
466
+ * Comments:
467
+ * This function replaces the deprecated SQLGetStmtOption function.
468
+ * It provides thread-safe access to statement attributes by using
469
+ * critical sections to protect shared resources.
470
+ */
420
471
RETCODE SQL_API
421
472
SQLGetStmtAttr (HSTMT StatementHandle ,
422
473
SQLINTEGER Attribute , PTR Value ,
@@ -426,13 +477,20 @@ SQLGetStmtAttr(HSTMT StatementHandle,
426
477
StatementClass * stmt = (StatementClass * ) StatementHandle ;
427
478
428
479
MYLOG (0 , "Entering Handle=%p " FORMAT_INTEGER "\n" , StatementHandle , Attribute );
480
+
429
481
ENTER_STMT_CS (stmt );
482
+
430
483
SC_clear_error (stmt );
484
+
431
485
StartRollbackState (stmt );
486
+
432
487
ret = PGAPI_GetStmtAttr (StatementHandle , Attribute , Value ,
433
488
BufferLength , StringLength );
434
- ret = DiscardStatementSvp (stmt ,ret , FALSE);
489
+
490
+ ret = DiscardStatementSvp (stmt , ret , FALSE);
491
+
435
492
LEAVE_STMT_CS (stmt );
493
+
436
494
return ret ;
437
495
}
438
496
@@ -455,7 +513,27 @@ SQLSetConnectAttr(HDBC ConnectionHandle,
455
513
return ret ;
456
514
}
457
515
458
- /* new function */
516
+ /*
517
+ * SQLSetDescField
518
+ *
519
+ * Description:
520
+ * This function sets the value of a field in a descriptor record.
521
+ * This is the ANSI version of the function.
522
+ *
523
+ * Parameters:
524
+ * DescriptorHandle - Handle to the descriptor
525
+ * RecNumber - The descriptor record number (1-based, 0 for header fields)
526
+ * FieldIdentifier - The field identifier (SQL_DESC_* constant)
527
+ * Value - The value to set for the field
528
+ * BufferLength - Length of the Value buffer in bytes (for string data)
529
+ *
530
+ * Returns:
531
+ * SQL_SUCCESS, SQL_SUCCESS_WITH_INFO, SQL_ERROR, or SQL_INVALID_HANDLE
532
+ *
533
+ * Comments:
534
+ * This function simply passes through to the core implementation function
535
+ * PGAPI_SetDescField without any additional processing.
536
+ */
459
537
RETCODE SQL_API
460
538
SQLSetDescField (SQLHDESC DescriptorHandle ,
461
539
SQLSMALLINT RecNumber , SQLSMALLINT FieldIdentifier ,
@@ -464,12 +542,39 @@ SQLSetDescField(SQLHDESC DescriptorHandle,
464
542
RETCODE ret ;
465
543
466
544
MYLOG (0 , "Entering h=%p rec=%d field=%d val=%p\n" , DescriptorHandle , RecNumber , FieldIdentifier , Value );
545
+
467
546
ret = PGAPI_SetDescField (DescriptorHandle , RecNumber , FieldIdentifier ,
468
547
Value , BufferLength );
548
+
469
549
return ret ;
470
550
}
471
551
472
- /* new function */
552
+ /*
553
+ * SQLSetDescRec
554
+ *
555
+ * Description:
556
+ * This function sets multiple descriptor fields with a single call.
557
+ * This is the ANSI version of the function.
558
+ *
559
+ * Parameters:
560
+ * DescriptorHandle - Handle to the descriptor
561
+ * RecNumber - The descriptor record number (1-based)
562
+ * Type - SQL data type
563
+ * SubType - Datetime or interval subcode
564
+ * Length - Maximum data length
565
+ * Precision - Precision of numeric types
566
+ * Scale - Scale of numeric types
567
+ * Data - Pointer to data buffer
568
+ * StringLength - Pointer to buffer length
569
+ * Indicator - Pointer to indicator variable
570
+ *
571
+ * Returns:
572
+ * SQL_SUCCESS, SQL_SUCCESS_WITH_INFO, SQL_ERROR, or SQL_INVALID_HANDLE
573
+ *
574
+ * Comments:
575
+ * This function provides a more efficient way to set multiple descriptor
576
+ * fields that are commonly used together.
577
+ */
473
578
RETCODE SQL_API
474
579
SQLSetDescRec (SQLHDESC DescriptorHandle ,
475
580
SQLSMALLINT RecNumber , SQLSMALLINT Type ,
@@ -482,9 +587,11 @@ SQLSetDescRec(SQLHDESC DescriptorHandle,
482
587
483
588
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 );
484
589
MYLOG (0 , "str=%p ind=%p\n" , StringLength , Indicator );
590
+
485
591
ret = PGAPI_SetDescRec (DescriptorHandle , RecNumber , Type ,
486
592
SubType , Length , Precision , Scale , Data ,
487
593
StringLength , Indicator );
594
+
488
595
return ret ;
489
596
}
490
597
#endif /* UNICODE_SUPPORTXX */
@@ -550,7 +657,27 @@ SQLSetEnvAttr(HENV EnvironmentHandle,
550
657
}
551
658
552
659
#ifndef UNICODE_SUPPORTXX
553
- /* SQLSet(Param/Scroll/Stmt)Option -> SQLSetStmtAttr */
660
+ /*
661
+ * SQLSetStmtAttr
662
+ *
663
+ * Description:
664
+ * This function sets the current setting of a statement attribute.
665
+ * This is the ANSI version of the function.
666
+ *
667
+ * Parameters:
668
+ * StatementHandle - Handle to the statement
669
+ * Attribute - The attribute to set (SQL_ATTR_* constant)
670
+ * Value - The value to set for the attribute
671
+ * StringLength - Length of the Value buffer in bytes (for string data)
672
+ *
673
+ * Returns:
674
+ * SQL_SUCCESS, SQL_SUCCESS_WITH_INFO, SQL_ERROR, or SQL_INVALID_HANDLE
675
+ *
676
+ * Comments:
677
+ * This function replaces the deprecated SQLSetStmtOption function.
678
+ * It provides thread-safe access to statement attributes by using
679
+ * critical sections to protect shared resources.
680
+ */
554
681
RETCODE SQL_API
555
682
SQLSetStmtAttr (HSTMT StatementHandle ,
556
683
SQLINTEGER Attribute , PTR Value ,
@@ -560,12 +687,21 @@ SQLSetStmtAttr(HSTMT StatementHandle,
560
687
RETCODE ret ;
561
688
562
689
MYLOG (0 , "Entering Handle=%p " FORMAT_INTEGER "," FORMAT_ULEN "\n" , StatementHandle , Attribute , (SQLULEN ) Value );
690
+
563
691
ENTER_STMT_CS (stmt );
692
+
564
693
SC_clear_error (stmt );
694
+
565
695
StartRollbackState (stmt );
696
+
697
+ /* Call the core implementation function */
566
698
ret = PGAPI_SetStmtAttr (StatementHandle , Attribute , Value , StringLength );
567
- ret = DiscardStatementSvp (stmt ,ret , FALSE);
699
+
700
+ /* Handle transaction state and cleanup */
701
+ ret = DiscardStatementSvp (stmt , ret , FALSE);
702
+
568
703
LEAVE_STMT_CS (stmt );
704
+
569
705
return ret ;
570
706
}
571
707
#endif /* UNICODE_SUPPORTXX */
0 commit comments