[asterisk-commits] ivaxer: branch ivaxer/ast_storage r281290 - /team/ivaxer/ast_storage/res/
SVN commits to the Asterisk project
asterisk-commits at lists.digium.com
Sun Aug 8 14:47:10 CDT 2010
Author: ivaxer
Date: Sun Aug 8 14:47:07 2010
New Revision: 281290
URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=281290
Log:
deleted columns analyse (odbc backend)
Modified:
team/ivaxer/ast_storage/res/res_storage_odbc.c
Modified: team/ivaxer/ast_storage/res/res_storage_odbc.c
URL: http://svnview.digium.com/svn/asterisk/team/ivaxer/ast_storage/res/res_storage_odbc.c?view=diff&rev=281290&r1=281289&r2=281290
==============================================================================
--- team/ivaxer/ast_storage/res/res_storage_odbc.c (original)
+++ team/ivaxer/ast_storage/res/res_storage_odbc.c Sun Aug 8 14:47:07 2010
@@ -47,22 +47,10 @@
#include <fcntl.h>
#include <errno.h>
-struct columns {
- SQLSMALLINT type;
- SQLINTEGER size;
- SQLSMALLINT decimals;
- SQLSMALLINT radix;
- SQLSMALLINT nullable;
- SQLINTEGER octetlen;
- AST_LIST_ENTRY(columns) list;
- char name[1];
-};
-
struct odbc_storage_pvt {
char odbc_class[128];
char tablename[128];
struct odbc_obj *conn;
- AST_RWLIST_HEAD(odbc_columns, columns) columns;
char pathname[1];
};
@@ -128,19 +116,17 @@
static struct ast_storage *se_create(const char *uri)
{
- char tmp[256], columnname[80];
+ char tmp[256];
SQLRETURN ret;
struct ast_storage *st;
struct odbc_storage_pvt *pvt;
- struct columns *entry;
- int pathname_len, columnname_len;
+ int pathname_len;
AST_DECLARE_APP_ARGS(args,
AST_APP_ARG(class);
AST_APP_ARG(tablename);
AST_APP_ARG(pathname);
);
SQLHSTMT stmt = NULL;
- SQLLEN sqlptr;
st = ast_calloc(1, sizeof(*st));
if (!st) {
@@ -167,8 +153,6 @@
st->storage_pvt = (void *)pvt;
st->be = &odbc_se;
-
- AST_RWLIST_HEAD_INIT(&pvt->columns);
ast_copy_string(pvt->odbc_class, args.class, sizeof(pvt->odbc_class));
ast_copy_string(pvt->tablename, args.tablename, sizeof(pvt->tablename));
@@ -186,37 +170,6 @@
ast_log(LOG_ERROR, "Allocation of database handle failed.\n");
se_release(st);
return NULL;
- }
-
- /* Get the table columns */
- ret = SQLColumns(stmt, NULL, 0, NULL, 0, (unsigned char *)pvt->tablename, SQL_NTS, (unsigned char *)"%", SQL_NTS);
- if (!SQL_SUCCEEDED(ret)) {
- ast_log(LOG_ERROR, "Unable to query database columns on table '%s@%s'. Storage method fails.\n", pvt->tablename, pvt->odbc_class);
- se_release(st);
- return NULL;
- }
-
- while ((ret = SQLFetch(stmt)) != SQL_NO_DATA && ret != SQL_ERROR) {
- SQLGetData(stmt, 4, SQL_C_CHAR, columnname, sizeof(columnname), &sqlptr);
- columnname_len = sizeof(char) * strlen(columnname);
-
- entry = ast_calloc(1, sizeof(*entry) + columnname_len);
- if (!entry) {
- ast_log(LOG_ERROR, "Unable to allocate column entry\n");
- se_release(st);
- return NULL;
- }
-
- strcpy(entry->name, columnname);
-
- SQLGetData(stmt, 5, SQL_C_SHORT, &entry->type, sizeof(entry->type), NULL);
- SQLGetData(stmt, 7, SQL_C_LONG, &entry->size, sizeof(entry->size), NULL);
- SQLGetData(stmt, 9, SQL_C_SHORT, &entry->decimals, sizeof(entry->decimals), NULL);
- SQLGetData(stmt, 10, SQL_C_SHORT, &entry->radix, sizeof(entry->radix), NULL);
- SQLGetData(stmt, 11, SQL_C_SHORT, &entry->nullable, sizeof(entry->nullable), NULL);
- SQLGetData(stmt, 16, SQL_C_LONG, &entry->octetlen, sizeof(entry->octetlen), NULL);
-
- AST_LIST_INSERT_TAIL(&pvt->columns, entry, list);
}
return st;
More information about the asterisk-commits
mailing list