From: Stefan Reddig Date: Fri, 12 Mar 2010 16:29:59 +0000 (+0100) Subject: syntax fix, test improved, empty results fixed X-Git-Tag: Release-5.0.2~160 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=94717278b5a96911f9dd5c5f6d73efd9fd6ecbf0;p=bacula%2Fbacula syntax fix, test improved, empty results fixed --- diff --git a/bacula/src/cats/ingres.c b/bacula/src/cats/ingres.c index a7834d501c..a00b3f9353 100755 --- a/bacula/src/cats/ingres.c +++ b/bacula/src/cats/ingres.c @@ -351,7 +351,7 @@ bool db_sql_query(B_DB *mdb, const char *query, DB_RESULT_HANDLER *result_handle if (result_handler != NULL) { Dmsg0(500, "db_sql_query invoking handler\n"); - if ((mdb->result = sql_store_result(mdb)) != NULL) { + if (mdb->result != NULL) { int num_fields = sql_num_fields(mdb); Dmsg0(500, "db_sql_query sql_store_result suceeded\n"); @@ -386,6 +386,13 @@ INGRES_ROW my_ingres_fetch_row(B_DB *mdb) int j; INGRES_ROW row = NULL; // by default, return NULL + if (!mdb->result) { + return row; + } + if (mdb->result->num_rows <= 0) { + return row; + } + Dmsg0(500, "my_ingres_fetch_row start\n"); if (!mdb->row || mdb->row_size < mdb->num_fields) { @@ -401,11 +408,11 @@ INGRES_ROW my_ingres_fetch_row(B_DB *mdb) mdb->row_size = num_fields; // now reset the row_number now that we have the space allocated - mdb->row_number = 0; + mdb->row_number = 1; } // if still within the result set - if (mdb->row_number < mdb->num_rows) { + if (mdb->row_number <= mdb->num_rows) { Dmsg2(500, "my_ingres_fetch_row row number '%d' is acceptable (0..%d)\n", mdb->row_number, mdb->num_rows); // get each value from this row for (j = 0; j < mdb->num_fields; j++) { diff --git a/bacula/src/cats/myingres.c b/bacula/src/cats/myingres.c index 53cfd64d80..88d86d4fb6 100644 --- a/bacula/src/cats/myingres.c +++ b/bacula/src/cats/myingres.c @@ -1,11 +1,11 @@ #include "bacula.h" /* # line 3 "myingres.sc" */ #ifdef HAVE_INGRES -#include -#include +#include #include -extern IISQLCA sqlca; /* SQL Communications Area */ + extern IISQLCA sqlca; /* SQL Communications Area */ #include +/* # line 7 "myingres.sc" */ /* host code */ #include #include #include @@ -103,6 +103,9 @@ IISQLDA *INGgetDescriptor(short numCols, const char *stmt) } void INGfreeDescriptor(IISQLDA *sqlda) { + if (!sqlda) { + return; + } int i; for (i = 0; i < sqlda->sqld; ++i) { if (sqlda->sqlvar[i].sqldata) { @@ -136,6 +139,9 @@ int INGgetTypeSize(IISQLVAR *ingvar) } INGresult *INGgetINGresult(IISQLDA *sqlda) { + if (!sqlda) { + return NULL; + } int i; INGresult *result = NULL; result = (INGresult *)malloc(sizeof(INGresult)); @@ -162,6 +168,9 @@ INGresult *INGgetINGresult(IISQLDA *sqlda) } void INGfreeINGresult(INGresult *ing_res) { + if (!ing_res) { + return; + } int rows; ING_ROW *rowtemp; /* @@ -278,42 +287,33 @@ int INGfetchAll(const char *stmt, INGresult *ing_res) IISQLDA *desc; int check = -1; desc = ing_res->sqlda; -/* # line 305 "myingres.sc" */ /* host code */ +/* # line 317 "myingres.sc" */ /* host code */ if ((check = INGcheck()) < 0) { return check; } -/* # line 309 "myingres.sc" */ /* open */ +/* # line 321 "myingres.sc" */ /* open */ { IIsqInit(&sqlca); - IIcsOpen((char *)"c2",4824,17405); + IIcsOpen((char *)"c2",27229,4179); IIwritio(0,(short *)0,1,32,0,(char *)"s2"); - IIcsQuery((char *)"c2",4824,17405); + IIcsQuery((char *)"c2",27229,4179); } -/* # line 310 "myingres.sc" */ /* host code */ +/* # line 322 "myingres.sc" */ /* host code */ if ((check = INGcheck()) < 0) { return check; } /* for (linecount = 0; sqlca.sqlcode == 0; ++linecount) */ - while(sqlca.sqlcode == 0) { -/* # line 316 "myingres.sc" */ /* fetch */ + do { +/* # line 328 "myingres.sc" */ /* fetch */ { IIsqInit(&sqlca); - if (IIcsRetScroll((char *)"c2",4824,17405,-1,-1) != 0) { + if (IIcsRetScroll((char *)"c2",27229,4179,-1,-1) != 0) { IIcsDaGet(0,desc); IIcsERetrieve(); } /* IIcsRetrieve */ } -/* # line 317 "myingres.sc" */ /* host code */ - if ((check = INGcheck()) < 0) { -/* # line 318 "myingres.sc" */ /* close */ - { - IIsqInit(&sqlca); - IIcsClose((char *)"c2",4824,17405); - } -/* # line 319 "myingres.sc" */ /* host code */ - return check; - } - if (sqlca.sqlcode == 0) { +/* # line 330 "myingres.sc" */ /* host code */ + if ( (sqlca.sqlcode == 0) || (sqlca.sqlcode == -40202) ) { row = INGgetRowSpace(ing_res); /* alloc space for fetched row */ /* * Initialize list when encountered first time @@ -325,16 +325,16 @@ int INGfetchAll(const char *stmt, INGresult *ing_res) } ing_res->act_row->next = row; /* append row to old act_row */ ing_res->act_row = row; /* set row as act_row */ - row->row_number = linecount; ++linecount; + row->row_number = linecount; } - } -/* # line 340 "myingres.sc" */ /* close */ + } while ( (sqlca.sqlcode == 0) || (sqlca.sqlcode == -40202) ) +/* # line 348 "myingres.sc" */ /* close */ { IIsqInit(&sqlca); - IIcsClose((char *)"c2",4824,17405); + IIcsClose((char *)"c2",27229,4179); } -/* # line 342 "myingres.sc" */ /* host code */ +/* # line 350 "myingres.sc" */ /* host code */ ing_res->status = ING_COMMAND_OK; ing_res->num_rows = linecount; return linecount; @@ -346,7 +346,8 @@ ING_STATUS INGresultStatus(INGresult *res) } void INGrowSeek(INGresult *res, int row_number) { - ING_ROW *trow; + ING_ROW *trow = NULL; + int i; if (res->act_row->row_number == row_number) { return; } @@ -356,7 +357,7 @@ void INGrowSeek(INGresult *res, int row_number) if (row_number<0 || row_number>res->num_rows) { return; } - for (trow = res->first_row; trow->row_number != row_number; trow = trow->next) ; + for (trow = res->first_row , i=1 ; trow->row_number != row_number , i <= res->num_rows; trow = trow->next , ++i); res->act_row = trow; /* * Note - can be null - if row_number not found, right? @@ -399,31 +400,31 @@ short INGftype(const INGresult *res, int column_number) int INGexec(INGconn *conn, const char *query) { int check; -/* # line 417 "myingres.sc" */ +/* # line 426 "myingres.sc" */ int rowcount; char *stmt; -/* # line 420 "myingres.sc" */ +/* # line 429 "myingres.sc" */ stmt = (char *)malloc(strlen(query)+1); bstrncpy(stmt,query,strlen(query)+1); rowcount = -1; -/* # line 426 "myingres.sc" */ /* execute */ +/* # line 435 "myingres.sc" */ /* execute */ { IIsqInit(&sqlca); IIsqExImmed(stmt); IIsyncup((char *)0,0); } -/* # line 427 "myingres.sc" */ /* host code */ +/* # line 436 "myingres.sc" */ /* host code */ free(stmt); if ((check = INGcheck()) < 0) { return check; } -/* # line 432 "myingres.sc" */ /* inquire_ingres */ +/* # line 441 "myingres.sc" */ /* inquire_ingres */ { IILQisInqSqlio((short *)0,1,30,sizeof(rowcount),&rowcount,8); } -/* # line 433 "myingres.sc" */ /* host code */ +/* # line 442 "myingres.sc" */ /* host code */ if ((check = INGcheck()) < 0) { return check; } @@ -439,10 +440,17 @@ INGresult *INGquery(INGconn *conn, const char *query) int rows = -1; int cols = INGgetCols(query); desc = INGgetDescriptor(cols, query); + if (!desc) { + return NULL; + } res = INGgetINGresult(desc); + if (!res) { + return NULL; + } rows = INGfetchAll(query, res); if (rows < 0) { INGfreeINGresult(res); + INGfreeDescriptor(desc); return NULL; } return res; @@ -463,14 +471,14 @@ INGconn *INGconnectDB(char *dbname, char *user, char *passwd) } INGconn *dbconn = (INGconn *)malloc(sizeof(INGconn)); memset(dbconn, 0, sizeof(INGconn)); -/* # line 480 "myingres.sc" */ +/* # line 496 "myingres.sc" */ char ingdbname[24]; char ingdbuser[32]; char ingdbpasw[32]; char conn_name[32]; int sess_id; -/* # line 486 "myingres.sc" */ +/* # line 502 "myingres.sc" */ bstrncpy(ingdbname, dbname, sizeof(ingdbname)); if (user != NULL) { @@ -480,7 +488,7 @@ INGconn *INGconnectDB(char *dbname, char *user, char *passwd) } else { memset(ingdbpasw, 0, sizeof(ingdbpasw)); } -/* # line 497 "myingres.sc" */ /* connect */ +/* # line 513 "myingres.sc" */ /* connect */ { IIsqInit(&sqlca); IIsqUser(ingdbuser); @@ -488,26 +496,26 @@ INGconn *INGconnectDB(char *dbname, char *user, char *passwd) (char *)0, (char *)0, (char *)0, (char *)0, (char *)0, (char *)0, (char *)0, (char *)0, (char *)0, (char *)0); } -/* # line 501 "myingres.sc" */ /* host code */ +/* # line 517 "myingres.sc" */ /* host code */ } else { -/* # line 502 "myingres.sc" */ /* connect */ +/* # line 518 "myingres.sc" */ /* connect */ { IIsqInit(&sqlca); IIsqConnect(0,ingdbname,(char *)0, (char *)0, (char *)0, (char *)0, (char *)0, (char *)0, (char *)0, (char *)0, (char *)0, (char *)0, (char *)0, (char *)0, (char *)0); } -/* # line 503 "myingres.sc" */ /* host code */ +/* # line 519 "myingres.sc" */ /* host code */ } -/* # line 505 "myingres.sc" */ /* inquire_sql */ +/* # line 521 "myingres.sc" */ /* inquire_sql */ { IILQisInqSqlio((short *)0,1,32,31,conn_name,13); } -/* # line 506 "myingres.sc" */ /* inquire_sql */ +/* # line 522 "myingres.sc" */ /* inquire_sql */ { IILQisInqSqlio((short *)0,1,30,sizeof(sess_id),&sess_id,11); } -/* # line 508 "myingres.sc" */ /* host code */ +/* # line 524 "myingres.sc" */ /* host code */ bstrncpy(dbconn->dbname, ingdbname, sizeof(dbconn->dbname)); bstrncpy(dbconn->user, ingdbuser, sizeof(dbconn->user)); bstrncpy(dbconn->password, ingdbpasw, sizeof(dbconn->password)); @@ -522,12 +530,12 @@ void INGdisconnectDB(INGconn *dbconn) /* * TODO: check for any real use of dbconn: maybe whenn multithreaded? */ -/* # line 524 "myingres.sc" */ /* disconnect */ +/* # line 540 "myingres.sc" */ /* disconnect */ { IIsqInit(&sqlca); IIsqDisconnect(); } -/* # line 525 "myingres.sc" */ /* host code */ +/* # line 541 "myingres.sc" */ /* host code */ if (dbconn != NULL) { free(dbconn->msg); free(dbconn); @@ -535,16 +543,16 @@ void INGdisconnectDB(INGconn *dbconn) } char *INGerrorMessage(const INGconn *conn) { -/* # line 533 "myingres.sc" */ +/* # line 549 "myingres.sc" */ char errbuf[256]; -/* # line 535 "myingres.sc" */ +/* # line 551 "myingres.sc" */ -/* # line 537 "myingres.sc" */ /* inquire_ingres */ +/* # line 553 "myingres.sc" */ /* inquire_ingres */ { IILQisInqSqlio((short *)0,1,32,255,errbuf,63); } -/* # line 538 "myingres.sc" */ /* host code */ +/* # line 554 "myingres.sc" */ /* host code */ memcpy(conn->msg,&errbuf,256); return conn->msg; } @@ -556,5 +564,5 @@ char *INGcmdTuples(INGresult *res) int INGputCopyEnd(INGconn *conn, const char *errormsg); int INGputCopyData(INGconn *conn, const char *buffer, int nbytes); */ -/* # line 552 "myingres.sc" */ +/* # line 568 "myingres.sc" */ #endif diff --git a/bacula/src/cats/myingres.sc b/bacula/src/cats/myingres.sc index 9f7f380ec0..8dba48c09b 100644 --- a/bacula/src/cats/myingres.sc +++ b/bacula/src/cats/myingres.sc @@ -101,6 +101,10 @@ IISQLDA *INGgetDescriptor(short numCols, const char *stmt) void INGfreeDescriptor(IISQLDA *sqlda) { + if (!sqlda) { + return; + } + int i; for (i = 0; i < sqlda->sqld; ++i) { @@ -139,6 +143,10 @@ int INGgetTypeSize(IISQLVAR *ingvar) INGresult *INGgetINGresult(IISQLDA *sqlda) { + if (!sqlda) { + return NULL; + } + int i; INGresult *result = NULL; @@ -171,6 +179,10 @@ INGresult *INGgetINGresult(IISQLDA *sqlda) void INGfreeINGresult(INGresult *ing_res) { + if (!ing_res) { + return; + } + int rows; ING_ROW *rowtemp; @@ -312,14 +324,10 @@ int INGfetchAll(const char *stmt, INGresult *ing_res) } /* for (linecount = 0; sqlca.sqlcode == 0; ++linecount) */ - while(sqlca.sqlcode == 0) { + do { EXEC SQL FETCH c2 USING DESCRIPTOR :desc; - if ((check = INGcheck()) < 0) { - EXEC SQL CLOSE c2; - return check; - } - if (sqlca.sqlcode == 0) { + if ( (sqlca.sqlcode == 0) || (sqlca.sqlcode == -40202) ) { row = INGgetRowSpace(ing_res); /* alloc space for fetched row */ /* @@ -332,10 +340,10 @@ int INGfetchAll(const char *stmt, INGresult *ing_res) } ing_res->act_row->next = row; /* append row to old act_row */ ing_res->act_row = row; /* set row as act_row */ - row->row_number = linecount; ++linecount; + row->row_number = linecount; } - } + } while ( (sqlca.sqlcode == 0) || (sqlca.sqlcode == -40202) ) EXEC SQL CLOSE c2; @@ -352,7 +360,8 @@ ING_STATUS INGresultStatus(INGresult *res) void INGrowSeek(INGresult *res, int row_number) { - ING_ROW *trow; + ING_ROW *trow = NULL; + int i; if (res->act_row->row_number == row_number) { return; } @@ -364,7 +373,7 @@ void INGrowSeek(INGresult *res, int row_number) return; } - for (trow = res->first_row; trow->row_number != row_number; trow = trow->next) ; + for (trow = res->first_row , i=1 ; trow->row_number != row_number , i <= res->num_rows; trow = trow->next , ++i); res->act_row = trow; /* * Note - can be null - if row_number not found, right? @@ -448,11 +457,18 @@ INGresult *INGquery(INGconn *conn, const char *query) int cols = INGgetCols(query); desc = INGgetDescriptor(cols, query); + if (!desc) { + return NULL; + } res = INGgetINGresult(desc); + if (!res) { + return NULL; + } rows = INGfetchAll(query, res); if (rows < 0) { INGfreeINGresult(res); + INGfreeDescriptor(desc); return NULL; } return res; diff --git a/bacula/src/cats/sql_cmds.c b/bacula/src/cats/sql_cmds.c index 85ab546a1e..18c0ac968f 100644 --- a/bacula/src/cats/sql_cmds.c +++ b/bacula/src/cats/sql_cmds.c @@ -640,7 +640,16 @@ const char *create_deltabs[4] = { "PurgedFiles TINYINT, " "FileSetId INTEGER UNSIGNED, " "JobFiles INTEGER UNSIGNED, " - "JobStatus CHAR)"}; + "JobStatus CHAR)", + /* Ingres */ + "DECLARE GLOBAL TEMPORARY TABLE DelCandidates (" + "JobId INTEGER NOT NULL, " + "PurgedFiles SMALLINT, " + "FileSetId INTEGER, " + "JobFiles INTEGER, " + "JobStatus char(1))" + "ON COMMIT PERSERVE ROWS WITH NORECOVERY" +}; /* ======= ua_restore.c */ @@ -735,7 +744,22 @@ const char *uar_create_temp[4] = { "VolumeName TEXT," "StartFile INTEGER UNSIGNED," "VolSessionId INTEGER UNSIGNED," - "VolSessionTime INTEGER UNSIGNED)"}; + "VolSessionTime INTEGER UNSIGNED)", + /* Ingres */ + "DECLARE GLOBAL TEMPORARY TABLE temp (" + "JobId INTEGER NOT NULL," + "JobTDate BIGINT," + "ClientId INTEGER," + "Level CHAR," + "JobFiles INTEGER," + "JobBytes BIGINT," + "StartTime TEXT," + "VolumeName TEXT," + "StartFile INTEGER," + "VolSessionId INTEGER," + "VolSessionTime INTEGER)" + "ON COMMIT PRESERVE ROWS WITH NORECOVERY" + }; const char *uar_create_temp1[4] = { /* Mysql */ @@ -753,7 +777,13 @@ const char *uar_create_temp1[4] = { /* SQLite3 */ "CREATE TEMPORARY TABLE temp1 (" "JobId INTEGER UNSIGNED NOT NULL," - "JobTDate BIGINT UNSIGNED)"}; + "JobTDate BIGINT UNSIGNED)", + /* Ingres */ + "DECLARE GLOBAL TEMPORARY TABLE temp1 (" + "JobId INTEGER NOT NULL," + "JobTDate BIGINT)" + "ON COMMIT PRESERVE ROWS WITH NORECOVERY" + }; /* Query to get all files in a directory -- no recursing * Note, for PostgreSQL since it respects the "Single Value diff --git a/bacula/src/cats/sql_create.c b/bacula/src/cats/sql_create.c index ae1affbfb6..510358ffe0 100644 --- a/bacula/src/cats/sql_create.c +++ b/bacula/src/cats/sql_create.c @@ -1112,7 +1112,13 @@ const char *create_temp_basefile[4] = { /* SQLite3 */ "CREATE TEMPORARY TABLE basefile%lld (" "Path TEXT," - "Name TEXT)" + "Name TEXT)", + + /* Ingres */ + "DECLARE GLOBAL TEMPORARY TABLE basefile%lld (" + "Path TEXT NOT NULL," + "Name TEXT NOT NULL)" + "ON COMMIT PRESERVE ROWS WITH NORECOVERY" }; /* diff --git a/bacula/src/tools/ing_test.c b/bacula/src/tools/ing_test.c index 6d49b4bbe3..d8b0505749 100644 --- a/bacula/src/tools/ing_test.c +++ b/bacula/src/tools/ing_test.c @@ -72,13 +72,23 @@ PROG_COPYRIGHT exit(1); } -/* simple handler for debug output of CRUD example*/ +/* + * simple handler for debug output of CRUD example + */ static int test_handler(void *ctx, int num_fields, char **row) { Dmsg2(200, " Values are %d, %s\n", str_to_int64(row[0]), row[1]); return 0; } +/* + * string handler for debug output of simple SELECT tests + */ +static int string_handler(void *ctx, int num_fields, char **row) +{ + Dmsg1(200, " Value is >>%s<<\n", row[0]); + return 0; +} /* number of thread started */ @@ -196,54 +206,72 @@ int main (int argc, char *argv[]) Pmsg0(0, "\nsimple CRUD test...\n\n"); Dmsg0(200, "DB-Statement: CREATE TABLE t1 ( c1 integer, c2 varchar(29))\n"); - if (!db_sql_query(db, "CREATE TABLE t1 ( c1 integer, c2 varchar(29))", NULL, NULL)) - { + if (!db_sql_query(db, "CREATE TABLE t1 ( c1 integer, c2 varchar(29))", NULL, NULL)) { Emsg0(M_ERROR_TERM, 0, _("CREATE-Stmt went wrong\n")); } Dmsg0(200, "DB-Statement: INSERT INTO t1 VALUES (1, 'foo')\n"); - if (!db_sql_query(db, "INSERT INTO t1 VALUES (1, 'foo')", NULL, NULL)) - { + if (!db_sql_query(db, "INSERT INTO t1 VALUES (1, 'foo')", NULL, NULL)) { Emsg0(M_ERROR_TERM, 0, _("INSERT-Stmt went wrong\n")); } - Dmsg0(200, "DB-Statement: SELECT * FROM t1 (should be 1, foo)\n"); - if (!db_sql_query(db, "SELECT * FROM t1", test_handler, NULL)) - { + Dmsg0(200, "DB-Statement: SELECT c1,c2 FROM t1 (should be 1, foo)\n"); + if (!db_sql_query(db, "SELECT c1,c2 FROM t1", test_handler, NULL)) { Emsg0(M_ERROR_TERM, 0, _("SELECT-Stmt went wrong\n")); } Dmsg0(200, "DB-Statement: UPDATE t1 SET c2='bar' WHERE c1=1\n"); - if (!db_sql_query(db, "UPDATE t1 SET c2='bar' WHERE c1=1", NULL, NULL)) - { + if (!db_sql_query(db, "UPDATE t1 SET c2='bar' WHERE c1=1", NULL, NULL)) { Emsg0(M_ERROR_TERM, 0, _("UPDATE-Stmt went wrong\n")); } Dmsg0(200, "DB-Statement: SELECT * FROM t1 (should be 1, bar)\n"); - if (!db_sql_query(db, "SELECT * FROM t1", test_handler, NULL)) - { + if (!db_sql_query(db, "SELECT * FROM t1", test_handler, NULL)) { Emsg0(M_ERROR_TERM, 0, _("SELECT-Stmt went wrong\n")); } - Dmsg0(200, "DB-Statement: DELETE FROM t1 WHERE c2 LIKE '%r'\n"); - if (!db_sql_query(db, "DELETE FROM t1 WHERE c2 LIKE '%r'", NULL, NULL)) - { + Dmsg0(200, "DB-Statement: DELETE FROM t1 WHERE c2 LIKE '\%r'\n"); + if (!db_sql_query(db, "DELETE FROM t1 WHERE c2 LIKE '%r'", NULL, NULL)) { Emsg0(M_ERROR_TERM, 0, _("DELETE-Stmt went wrong\n")); } Dmsg0(200, "DB-Statement: SELECT * FROM t1 (should be 0 rows)\n"); - if (!db_sql_query(db, "SELECT * FROM t1", test_handler, NULL)) - { + if (!db_sql_query(db, "SELECT * FROM t1", test_handler, NULL)) { Emsg0(M_ERROR_TERM, 0, _("SELECT-Stmt went wrong\n")); } Dmsg0(200, "DB-Statement: DROP TABLE t1\n"); - if (!db_sql_query(db, "DROP TABLE t1", NULL, NULL)) - { + if (!db_sql_query(db, "DROP TABLE t1", NULL, NULL)) { Emsg0(M_ERROR_TERM, 0, _("DROP-Stmt went wrong\n")); } - /* datatypes test */ + /* + * simple SELECT test without tables + */ + + Dmsg0(200, "DB-Statement: SELECT 'Test of simple SELECT!'\n"); + if (!db_sql_query(db, "SELECT 'Test of simple SELECT!'", string_handler, NULL)) { + Emsg0(M_ERROR_TERM, 0, _("SELECT-Stmt went wrong\n")); + } + + Dmsg0(200, "DB-Statement: SELECT 'Test of simple SELECT!' as Text\n"); + if (!db_sql_query(db, "SELECT 'Test of simple SELECT!' as Text", string_handler, NULL)) { + Emsg0(M_ERROR_TERM, 0, _("SELECT-Stmt went wrong\n")); + } + + Dmsg0(200, "DB-Statement: SELECT VARCHAR(LENGTH('Test of simple SELECT!'))\n"); + if (!db_sql_query(db, "SELECT VARCHAR(LENGTH('Test of simple SELECT!'))", string_handler, NULL)) { + Emsg0(M_ERROR_TERM, 0, _("SELECT-Stmt went wrong\n")); + } + + Dmsg0(200, "DB-Statement: SELECT DBMSINFO('_version')\n"); + if (!db_sql_query(db, "SELECT DBMSINFO('_version')", string_handler, NULL)) { + Emsg0(M_ERROR_TERM, 0, _("SELECT-Stmt went wrong\n")); + } + + /* + * datatypes test + */ Pmsg0(0, "\ndatatypes test... (TODO)\n\n"); @@ -253,14 +281,12 @@ int main (int argc, char *argv[]) "c2 varchar(255)," "c3 char(255)" /* some more datatypes... "c4 ," */ - ")" , NULL, NULL)) - { + ")" , NULL, NULL)) { Emsg0(M_ERROR_TERM, 0, _("CREATE-Stmt went wrong\n")); } Dmsg0(200, "DB-Statement: DROP TABLE for datatypes\n"); - if (!db_sql_query(db, "DROP TABLE t2", NULL, NULL)) - { + if (!db_sql_query(db, "DROP TABLE t2", NULL, NULL)) { Emsg0(M_ERROR_TERM, 0, _("DROP-Stmt went wrong\n")); }