Lines Matching refs:S

49 	pdo_pgsql_stmt *S = (pdo_pgsql_stmt*)stmt->driver_data;  in pgsql_stmt_dtor()  local
51 if (S->result) { in pgsql_stmt_dtor()
53 PQclear(S->result); in pgsql_stmt_dtor()
54 S->result = NULL; in pgsql_stmt_dtor()
58 if (S->stmt_name) { in pgsql_stmt_dtor()
59 pdo_pgsql_db_handle *H = S->H; in pgsql_stmt_dtor()
63 if (S->is_prepared) { in pgsql_stmt_dtor()
64 spprintf(&q, 0, "DEALLOCATE %s", S->stmt_name); in pgsql_stmt_dtor()
71 efree(S->stmt_name); in pgsql_stmt_dtor()
72 S->stmt_name = NULL; in pgsql_stmt_dtor()
74 if (S->param_lengths) { in pgsql_stmt_dtor()
75 efree(S->param_lengths); in pgsql_stmt_dtor()
76 S->param_lengths = NULL; in pgsql_stmt_dtor()
78 if (S->param_values) { in pgsql_stmt_dtor()
79 efree(S->param_values); in pgsql_stmt_dtor()
80 S->param_values = NULL; in pgsql_stmt_dtor()
82 if (S->param_formats) { in pgsql_stmt_dtor()
83 efree(S->param_formats); in pgsql_stmt_dtor()
84 S->param_formats = NULL; in pgsql_stmt_dtor()
86 if (S->param_types) { in pgsql_stmt_dtor()
87 efree(S->param_types); in pgsql_stmt_dtor()
88 S->param_types = NULL; in pgsql_stmt_dtor()
90 if (S->query) { in pgsql_stmt_dtor()
91 efree(S->query); in pgsql_stmt_dtor()
92 S->query = NULL; in pgsql_stmt_dtor()
96 if (S->cursor_name) { in pgsql_stmt_dtor()
97 pdo_pgsql_db_handle *H = S->H; in pgsql_stmt_dtor()
101 spprintf(&q, 0, "CLOSE %s", S->cursor_name); in pgsql_stmt_dtor()
105 efree(S->cursor_name); in pgsql_stmt_dtor()
106 S->cursor_name = NULL; in pgsql_stmt_dtor()
109 if(S->cols) { in pgsql_stmt_dtor()
110 efree(S->cols); in pgsql_stmt_dtor()
111 S->cols = NULL; in pgsql_stmt_dtor()
113 efree(S); in pgsql_stmt_dtor()
120 pdo_pgsql_stmt *S = (pdo_pgsql_stmt*)stmt->driver_data; in pgsql_stmt_execute() local
121 pdo_pgsql_db_handle *H = S->H; in pgsql_stmt_execute()
125 if(S->result) { in pgsql_stmt_execute()
126 PQclear(S->result); in pgsql_stmt_execute()
127 S->result = NULL; in pgsql_stmt_execute()
130 S->current_row = 0; in pgsql_stmt_execute()
132 if (S->cursor_name) { in pgsql_stmt_execute()
135 if (S->is_prepared) { in pgsql_stmt_execute()
136 spprintf(&q, 0, "CLOSE %s", S->cursor_name); in pgsql_stmt_execute()
137 S->result = PQexec(H->server, q); in pgsql_stmt_execute()
141 …spprintf(&q, 0, "DECLARE %s SCROLL CURSOR WITH HOLD FOR %s", S->cursor_name, stmt->active_query_st… in pgsql_stmt_execute()
142 S->result = PQexec(H->server, q); in pgsql_stmt_execute()
146 status = PQresultStatus(S->result); in pgsql_stmt_execute()
148 pdo_pgsql_error_stmt(stmt, status, pdo_pgsql_sqlstate(S->result)); in pgsql_stmt_execute()
153 S->is_prepared = 1; in pgsql_stmt_execute()
156 spprintf(&q, 0, "FETCH FORWARD 0 FROM %s", S->cursor_name); in pgsql_stmt_execute()
157 S->result = PQexec(H->server, q); in pgsql_stmt_execute()
161 if (S->stmt_name) { in pgsql_stmt_execute()
164 if (!S->is_prepared) { in pgsql_stmt_execute()
168 S->result = PQprepare(H->server, S->stmt_name, S->query, in pgsql_stmt_execute()
170 S->param_types); in pgsql_stmt_execute()
171 status = PQresultStatus(S->result); in pgsql_stmt_execute()
176 S->is_prepared = 1; in pgsql_stmt_execute()
177 PQclear(S->result); in pgsql_stmt_execute()
180 char *sqlstate = pdo_pgsql_sqlstate(S->result); in pgsql_stmt_execute()
190 snprintf(buf, sizeof(buf), "DEALLOCATE %s", S->stmt_name); in pgsql_stmt_execute()
203 S->result = PQexecPrepared(H->server, S->stmt_name, in pgsql_stmt_execute()
207 (const char**)S->param_values, in pgsql_stmt_execute()
208 S->param_lengths, in pgsql_stmt_execute()
209 S->param_formats, in pgsql_stmt_execute()
214 S->result = PQexec(H->server, stmt->active_query_string); in pgsql_stmt_execute()
216 status = PQresultStatus(S->result); in pgsql_stmt_execute()
219 pdo_pgsql_error_stmt(stmt, status, pdo_pgsql_sqlstate(S->result)); in pgsql_stmt_execute()
224 stmt->column_count = (int) PQnfields(S->result); in pgsql_stmt_execute()
225 S->cols = ecalloc(stmt->column_count, sizeof(pdo_pgsql_column)); in pgsql_stmt_execute()
229 stmt->row_count = (long)atoi(PQcmdTuples(S->result)); in pgsql_stmt_execute()
230 H->pgoid = PQoidValue(S->result); in pgsql_stmt_execute()
232 stmt->row_count = (long)PQntuples(S->result); in pgsql_stmt_execute()
242 pdo_pgsql_stmt *S = (pdo_pgsql_stmt*)stmt->driver_data; in pgsql_stmt_param_hook() local
244 if (S->stmt_name && param->is_param) { in pgsql_stmt_param_hook()
282 if (!S->param_values) { in pgsql_stmt_param_hook()
283 S->param_values = ecalloc( in pgsql_stmt_param_hook()
286 S->param_lengths = ecalloc( in pgsql_stmt_param_hook()
289 S->param_formats = ecalloc( in pgsql_stmt_param_hook()
292 S->param_types = ecalloc( in pgsql_stmt_param_hook()
316 S->param_values[param->paramno] = (char*)&P->oid; in pgsql_stmt_param_hook()
317 S->param_lengths[param->paramno] = sizeof(P->oid); in pgsql_stmt_param_hook()
318 S->param_formats[param->paramno] = 1; in pgsql_stmt_param_hook()
319 S->param_types[param->paramno] = OIDOID; in pgsql_stmt_param_hook()
342 S->param_values[param->paramno] = NULL; in pgsql_stmt_param_hook()
343 S->param_lengths[param->paramno] = 0; in pgsql_stmt_param_hook()
345 S->param_values[param->paramno] = Z_BVAL_P(param->parameter) ? "t" : "f"; in pgsql_stmt_param_hook()
346 S->param_lengths[param->paramno] = 1; in pgsql_stmt_param_hook()
347 S->param_formats[param->paramno] = 0; in pgsql_stmt_param_hook()
351 S->param_values[param->paramno] = Z_STRVAL_P(param->parameter); in pgsql_stmt_param_hook()
352 S->param_lengths[param->paramno] = Z_STRLEN_P(param->parameter); in pgsql_stmt_param_hook()
353 S->param_formats[param->paramno] = 0; in pgsql_stmt_param_hook()
357 S->param_types[param->paramno] = 0; in pgsql_stmt_param_hook()
358 S->param_formats[param->paramno] = 1; in pgsql_stmt_param_hook()
360 S->param_types[param->paramno] = 0; in pgsql_stmt_param_hook()
385 pdo_pgsql_stmt *S = (pdo_pgsql_stmt*)stmt->driver_data; in pgsql_stmt_fetch() local
387 if (S->cursor_name) { in pgsql_stmt_fetch()
403 spprintf(&q, 0, "FETCH %s FROM %s", ori_str, S->cursor_name); in pgsql_stmt_fetch()
405 S->result = PQexec(S->H->server, q); in pgsql_stmt_fetch()
407 status = PQresultStatus(S->result); in pgsql_stmt_fetch()
410 pdo_pgsql_error_stmt(stmt, status, pdo_pgsql_sqlstate(S->result)); in pgsql_stmt_fetch()
414 if (PQntuples(S->result)) { in pgsql_stmt_fetch()
415 S->current_row = 1; in pgsql_stmt_fetch()
421 if (S->current_row < stmt->row_count) { in pgsql_stmt_fetch()
422 S->current_row++; in pgsql_stmt_fetch()
432 pdo_pgsql_stmt *S = (pdo_pgsql_stmt*)stmt->driver_data; in pgsql_stmt_describe() local
436 if (!S->result) { in pgsql_stmt_describe()
440 cols[colno].name = estrdup(PQfname(S->result, colno)); in pgsql_stmt_describe()
442 cols[colno].maxlen = PQfsize(S->result, colno); in pgsql_stmt_describe()
443 cols[colno].precision = PQfmod(S->result, colno); in pgsql_stmt_describe()
444 S->cols[colno].pgsql_type = PQftype(S->result, colno); in pgsql_stmt_describe()
446 switch(S->cols[colno].pgsql_type) { in pgsql_stmt_describe()
494 pdo_pgsql_stmt *S = (pdo_pgsql_stmt*)stmt->driver_data; in pgsql_stmt_get_col() local
498 if (!S->result) { in pgsql_stmt_get_col()
503 if (PQgetisnull(S->result, S->current_row - 1, colno)) { /* Check if we got NULL */ in pgsql_stmt_get_col()
507 *ptr = PQgetvalue(S->result, S->current_row - 1, colno); in pgsql_stmt_get_col()
508 *len = PQgetlength(S->result, S->current_row - 1, colno); in pgsql_stmt_get_col()
513 S->cols[colno].intval = atol(*ptr); in pgsql_stmt_get_col()
514 *ptr = (char *) &(S->cols[colno].intval); in pgsql_stmt_get_col()
519 S->cols[colno].boolval = **ptr == 't' ? 1: 0; in pgsql_stmt_get_col()
520 *ptr = (char *) &(S->cols[colno].boolval); in pgsql_stmt_get_col()
525 if (S->cols[colno].pgsql_type == OIDOID) { in pgsql_stmt_get_col()
529 int loid = lo_open(S->H->server, oid, INV_READ); in pgsql_stmt_get_col()
573 pdo_pgsql_stmt *S = (pdo_pgsql_stmt*)stmt->driver_data; in pgsql_stmt_get_column_meta() local
578 if (!S->result) { in pgsql_stmt_get_column_meta()
587 add_assoc_long(return_value, "pgsql:oid", S->cols[colno].pgsql_type); in pgsql_stmt_get_column_meta()
590 spprintf(&q, 0, "SELECT TYPNAME FROM PG_TYPE WHERE OID=%u", S->cols[colno].pgsql_type); in pgsql_stmt_get_column_meta()
591 res = PQexec(S->H->server, q); in pgsql_stmt_get_column_meta()