1/*********************************************************************
2 *
3 * This is based on code created by Peter Harvey,
4 * (pharvey@codebydesign.com).
5 *
6 * Modified and extended by Nick Gorham
7 * (nick@lurcher.org).
8 *
9 * Any bugs or problems should be considered the fault of Nick and not
10 * Peter.
11 *
12 * copyright (c) 1999 Nick Gorham
13 *
14 * This library is free software; you can redistribute it and/or
15 * modify it under the terms of the GNU Lesser General Public
16 * License as published by the Free Software Foundation; either
17 * version 2 of the License, or (at your option) any later version.
18 *
19 * This library is distributed in the hope that it will be useful,
20 * but WITHOUT ANY WARRANTY; without even the implied warranty of
21 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
22 * Lesser General Public License for more details.
23 *
24 * You should have received a copy of the GNU Lesser General Public
25 * License along with this library; if not, write to the Free Software
26 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
27 *
28 **********************************************************************
29 *
30 * $Id: SQLSetDescRec.c,v 1.4 2009/02/18 17:59:08 lurcher Exp $
31 *
32 * $Log: SQLSetDescRec.c,v $
33 * Revision 1.4 2009/02/18 17:59:08 lurcher
34 * Shift to using config.h, the compile lines were making it hard to spot warnings
35 *
36 * Revision 1.3 2003/10/30 18:20:46 lurcher
37 *
38 * Fix broken thread protection
39 * Remove SQLNumResultCols after execute, lease S4/S% to driver
40 * Fix string overrun in SQLDriverConnect
41 * Add initial support for Interix
42 *
43 * Revision 1.2 2001/12/13 13:00:32 lurcher
44 *
45 * Remove most if not all warnings on 64 bit platforms
46 * Add support for new MS 3.52 64 bit changes
47 * Add override to disable the stopping of tracing
48 * Add MAX_ROWS support in postgres driver
49 *
50 * Revision 1.1.1.1 2001/10/17 16:40:07 lurcher
51 *
52 * First upload to SourceForge
53 *
54 * Revision 1.3 2001/04/17 16:29:39 nick
55 *
56 * More checks and autotest fixes
57 *
58 * Revision 1.2 2001/04/12 17:43:36 nick
59 *
60 * Change logging and added autotest to odbctest
61 *
62 * Revision 1.1.1.1 2000/09/04 16:42:52 nick
63 * Imported Sources
64 *
65 * Revision 1.5 1999/10/24 23:54:19 ngorham
66 *
67 * First part of the changes to the error reporting
68 *
69 * Revision 1.4 1999/07/10 21:10:17 ngorham
70 *
71 * Adjust error sqlstate from driver manager, depending on requested
72 * version (ODBC2/3)
73 *
74 * Revision 1.3 1999/07/04 21:05:08 ngorham
75 *
76 * Add LGPL Headers to code
77 *
78 * Revision 1.2 1999/06/30 23:56:55 ngorham
79 *
80 * Add initial thread safety code
81 *
82 * Revision 1.1.1.1 1999/05/29 13:41:08 sShandyb
83 * first go at it
84 *
85 * Revision 1.1.1.1 1999/05/27 18:23:18 pharvey
86 * Imported sources
87 *
88 * Revision 1.2 1999/05/04 22:41:12 nick
89 * and another night ends
90 *
91 * Revision 1.1 1999/04/25 23:06:11 nick
92 * Initial revision
93 *
94 *
95 **********************************************************************/
96
97#include <config.h>
98#include "drivermanager.h"
99
100static char const rcsid[]= "$RCSfile: SQLSetDescRec.c,v $ $Revision: 1.4 $";
101
102SQLRETURN SQLSetDescRec( SQLHDESC descriptor_handle,
103 SQLSMALLINT rec_number,
104 SQLSMALLINT type,
105 SQLSMALLINT subtype,
106 SQLLEN length,
107 SQLSMALLINT precision,
108 SQLSMALLINT scale,
109 SQLPOINTER data,
110 SQLLEN *string_length,
111 SQLLEN *indicator )
112{
113 /*
114 * not quite sure how the descriptor can be
115 * allocated to a statement, all the documentation talks
116 * about state transitions on statement states, but the
117 * descriptor may be allocated with more than one statement
118 * at one time. Which one should I check ?
119 */
120 DMHDESC descriptor = (DMHDESC) descriptor_handle;
121 SQLRETURN ret;
122
123 /*
124 * check descriptor
125 */
126
127 if ( !__validate_desc( descriptor ))
128 {
129 dm_log_write( __FILE__,
130 __LINE__,
131 LOG_INFO,
132 LOG_INFO,
133 "Error: SQL_INVALID_HANDLE" );
134
135 return SQL_INVALID_HANDLE;
136 }
137
138 function_entry( descriptor );
139
140 thread_protect( SQL_HANDLE_DESC, descriptor );
141
142 if ( descriptor -> connection -> state < STATE_C4 )
143 {
144 dm_log_write( __FILE__,
145 __LINE__,
146 LOG_INFO,
147 LOG_INFO,
148 "Error: HY010" );
149
150 __post_internal_error( &descriptor -> error,
151 ERROR_HY010, NULL,
152 descriptor -> connection -> environment -> requested_version );
153
154 return function_return_nodrv( SQL_HANDLE_DESC, descriptor, SQL_ERROR );
155 }
156
157 /*
158 * check status of statements associated with this descriptor
159 */
160
161 if( __check_stmt_from_desc( descriptor, STATE_S8 ) ||
162 __check_stmt_from_desc( descriptor, STATE_S9 ) ||
163 __check_stmt_from_desc( descriptor, STATE_S10 ) ||
164 __check_stmt_from_desc( descriptor, STATE_S11 ) ||
165 __check_stmt_from_desc( descriptor, STATE_S12 ) ||
166 __check_stmt_from_desc( descriptor, STATE_S13 ) ||
167 __check_stmt_from_desc( descriptor, STATE_S14 ) ||
168 __check_stmt_from_desc( descriptor, STATE_S15 )) {
169
170 dm_log_write( __FILE__,
171 __LINE__,
172 LOG_INFO,
173 LOG_INFO,
174 "Error: HY010" );
175
176 __post_internal_error( &descriptor -> error,
177 ERROR_HY010, NULL,
178 descriptor -> connection -> environment -> requested_version );
179
180 return function_return_nodrv( SQL_HANDLE_DESC, descriptor, SQL_ERROR );
181 }
182
183 if ( !CHECK_SQLSETDESCREC( descriptor -> connection ))
184 {
185 __post_internal_error( &descriptor -> error,
186 ERROR_IM001, NULL,
187 descriptor -> connection -> environment -> requested_version );
188
189 return function_return_nodrv( SQL_HANDLE_DESC, descriptor, SQL_ERROR );
190 }
191
192 ret = SQLSETDESCREC( descriptor -> connection,
193 descriptor -> driver_desc,
194 rec_number,
195 type,
196 subtype,
197 length,
198 precision,
199 scale,
200 data,
201 string_length,
202 indicator );
203
204 return function_return( SQL_HANDLE_DESC, descriptor, ret );
205}
206