Changeset 68 for trunk/src/sh_database.c
- Timestamp:
- Oct 30, 2006, 12:03:44 AM (18 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/sh_database.c
r54 r68 109 109 char link_old[1024]; 110 110 char link_new[1024]; 111 char acl_old[1024]; 112 char acl_new[1024]; 111 113 112 114 long long_data[20]; … … 204 206 { NULL, N_("attr_old"), 0, 71, 16, 0, offsetof(struct dbins_, attr_old)}, 205 207 { NULL, N_("attr_new"), 0, 72, 16, 0, offsetof(struct dbins_, attr_new)}, 208 { NULL, N_("acl_old"), 0, 73, 1024, 0, offsetof(struct dbins_, acl_old)}, 209 { NULL, N_("acl_new"), 0, 74, 1024, 0, offsetof(struct dbins_, acl_new)}, 206 210 207 211 { NULL, NULL, 0, 0, 0, 0, 0 } … … 497 501 static OCIError * o_error = NULL; 498 502 static OCIStmt * o_statement; 503 static OCIBind * o_bind = (OCIBind *) 0; 499 504 static text o_errormsg[512]; 500 505 static sb4 o_errorcode; … … 666 671 oracle_connected: 667 672 668 /* 669 * Insert 670 */ 673 /* Get row index 674 */ 675 sl_strlcpy (row_query, _("SELECT log_log_index_seq.NEXTVAL FROM dual"), 128); 676 671 677 #ifdef DB_DEBUG 672 678 sh_error_handle(SH_ERR_NOTICE, FIL__, __LINE__, 0, MSG_E_SUBGEN, 673 query,679 row_query, 674 680 _("sh_database_query")); 675 681 #endif 676 682 677 683 if (OCIStmtPrepare(o_statement, o_error, 678 (OraText*) query, sl_strlen(query),684 (OraText*) row_query, sl_strlen(row_query), 679 685 OCI_NTV_SYNTAX, OCI_DEFAULT)) 680 {681 OCIErrorGet(o_error, 1, NULL,682 &o_errorcode, o_errormsg, sizeof(o_errormsg),683 OCI_HTYPE_ERROR);684 sh_stripnl (o_errormsg);685 sh_error_handle((-1), FIL__, __LINE__, (long) o_errorcode, MSG_E_SUBGEN,686 o_errormsg,687 _("sh_database_query"));688 if (retry == 0 &&689 (3114 == o_errorcode || 0 == strncmp(o_errormsg, _("ORA-03114"), 9)))690 {691 ++retry; sh_database_reset(); goto oracle_doconnect;692 }693 goto err_out;694 }695 696 if (OCIStmtExecute(o_servicecontext,697 o_statement, o_error, 1, 0,698 NULL, NULL, OCI_COMMIT_ON_SUCCESS))699 686 { 700 687 OCIErrorGet(o_error, 1, NULL, … … 713 700 } 714 701 715 #ifdef DB_DEBUG 716 sh_error_handle(SH_ERR_NOTICE, FIL__, __LINE__, 0, MSG_E_SUBGEN, 717 _("No error on insert"), 718 _("sh_database_query")); 719 #endif 720 721 /* Get row index 722 */ 723 sl_strlcpy (row_query, _("SELECT MAX(log_index) FROM "), 128); 724 sl_strlcat (row_query, db_table, 128); 725 726 #ifdef DB_DEBUG 727 sh_error_handle(SH_ERR_NOTICE, FIL__, __LINE__, 0, MSG_E_SUBGEN, 728 row_query, 729 _("sh_database_query")); 730 #endif 731 732 if (OCIStmtPrepare(o_statement, o_error, 733 (OraText*) row_query, sl_strlen(row_query), 734 OCI_NTV_SYNTAX, OCI_DEFAULT)) 702 if (OCIStmtExecute(o_servicecontext, o_statement, o_error, 703 0, 0, NULL, NULL, OCI_DEFAULT)) 735 704 { 736 705 OCIErrorGet(o_error, 1, NULL, … … 749 718 } 750 719 751 if (OCIStmtExecute(o_servicecontext, o_statement, o_error, 752 0, 0, NULL, NULL, OCI_DEFAULT)) 720 if (OCIDefineByPos (o_statement, &o_define, o_error, 1, 721 &result, sizeof(result), 722 SQLT_INT, 0, 0, 0, OCI_DEFAULT)) 753 723 { 754 724 OCIErrorGet(o_error, 1, NULL, … … 766 736 goto err_out; 767 737 } 768 769 if (OCIDefineByPos (o_statement, &o_define, o_error, 1, 770 &result, sizeof(result), 771 SQLT_INT, 0, 0, 0, OCI_DEFAULT)) 738 if (OCIStmtFetch (o_statement, o_error, 1, OCI_FETCH_NEXT, OCI_DEFAULT)) 772 739 { 773 740 OCIErrorGet(o_error, 1, NULL, … … 785 752 goto err_out; 786 753 } 787 if (OCIStmtFetch (o_statement, o_error, 1, OCI_FETCH_NEXT, OCI_DEFAULT)) 754 755 #ifdef DB_DEBUG 756 sl_snprintf(row_query, 127, _("Returned value: %d"), result); 757 sh_error_handle(SH_ERR_NOTICE, FIL__, __LINE__, 0, MSG_E_SUBGEN, 758 row_query, 759 _("sh_database_query")); 760 #endif 761 762 *id = result; 763 764 /* do the insert 765 */ 766 #ifdef DB_DEBUG 767 sh_error_handle(SH_ERR_NOTICE, FIL__, __LINE__, 0, MSG_E_SUBGEN, 768 query, 769 _("sh_database_query")); 770 #endif 771 772 if (OCIStmtPrepare(o_statement, o_error, 773 (OraText*) query, sl_strlen(query), 774 OCI_NTV_SYNTAX, OCI_DEFAULT)) 775 { 776 OCIErrorGet(o_error, 1, NULL, 777 &o_errorcode, o_errormsg, sizeof(o_errormsg), 778 OCI_HTYPE_ERROR); 779 sh_stripnl (o_errormsg); 780 sh_error_handle((-1), FIL__, __LINE__, (long) o_errorcode, MSG_E_SUBGEN, 781 o_errormsg, 782 _("sh_database_query")); 783 if (retry == 0 && 784 (3114 == o_errorcode || 0 == strncmp(o_errormsg, _("ORA-03114"), 9))) 785 { 786 ++retry; sh_database_reset(); goto oracle_doconnect; 787 } 788 goto err_out; 789 } 790 791 if (OCIBindByPos(o_statement, &o_bind, o_error, 1, 792 (dvoid *) &result, (sword) sizeof(result), SQLT_INT, 793 (dvoid *) 0, (ub2 *) 0, (ub2 *) 0, (ub4) 0, (ub4 *) 0, OCI_DEFAULT)) 788 794 { 789 795 OCIErrorGet(o_error, 1, NULL, … … 801 807 goto err_out; 802 808 } 803 809 810 if (OCIStmtExecute(o_servicecontext, 811 o_statement, o_error, 1, 0, 812 NULL, NULL, OCI_COMMIT_ON_SUCCESS)) 813 { 814 OCIErrorGet(o_error, 1, NULL, 815 &o_errorcode, o_errormsg, sizeof(o_errormsg), 816 OCI_HTYPE_ERROR); 817 sh_stripnl (o_errormsg); 818 sh_error_handle((-1), FIL__, __LINE__, (long) o_errorcode, MSG_E_SUBGEN, 819 o_errormsg, 820 _("sh_database_query")); 821 if (retry == 0 && 822 (3114 == o_errorcode || 0 == strncmp(o_errormsg, _("ORA-03114"), 9))) 823 { 824 ++retry; sh_database_reset(); goto oracle_doconnect; 825 } 826 goto err_out; 827 } 828 804 829 #ifdef DB_DEBUG 805 sl_snprintf(row_query, 127, _("Returned value: %d"), result);806 830 sh_error_handle(SH_ERR_NOTICE, FIL__, __LINE__, 0, MSG_E_SUBGEN, 807 row_query,831 _("No error on insert"), 808 832 _("sh_database_query")); 809 833 #endif 810 811 *id = result;812 834 813 835 if (sh_persistent_dbconn == S_FALSE) … … 1254 1276 (void) 1255 1277 sl_snprintf (values, SH_QUERY_MAX, 1256 _("( %s,%c%s%c,to_date(%c%s%c,'YYYY-MM-DD HH24:MI:SS'),%c%s%c,%c%s%c"),1278 _("(:1,%s,%c%s%c,to_date(%c%s%c,'YYYY-MM-DD HH24:MI:SS'),%c%s%c,%c%s%c"), 1257 1279 id >= 0 ? num : _("NULL"), 1258 1280 '\'', db_entry->host,'\'', … … 1263 1285 '\''); 1264 1286 (void) sl_snprintf (columns, 1023, 1265 _("(log_ ref,log_host,log_time,log_sev,log_msg"));1287 _("(log_index,log_ref,log_host,log_time,log_sev,log_msg")); 1266 1288 #elif defined(WITH_POSTGRES) 1267 1289 /* Prepare query for PQexecParams … … 1495 1517 } 1496 1518 1497 static int is_escaped( unsigned char * p) {1519 static int is_escaped(char * p_in) { 1498 1520 1499 1521 int escp = 0; 1500 1522 int retv = S_TRUE; 1523 unsigned char * p = (unsigned char *) p_in; 1501 1524 1502 1525 while (*p != '\0')
Note:
See TracChangeset
for help on using the changeset viewer.