Advertisement
Guest User

Untitled

a guest
May 8th, 2017
79
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 15.96 KB | None | 0 0
  1. #include "wet.h"
  2. #include <stdio.h>
  3. #include <string.h>
  4. #include <libpq-fe.h>
  5.  
  6.  
  7. // ===================== HELPER FUNCTIONS =============================
  8. int cmpDates (char* date1, char* date2) {
  9.     //returns -1 if date1 < date2, +1 if date1>date2, 0 if date1==date2.
  10.     char yr1[4], yr2[4];
  11.     char mon1[2], mon2[2];
  12.     int i;
  13.     for (i=0; i<4;i++ ) {
  14.         yr1[i] = date1[i];
  15.         yr2[i] = date2[i];
  16.     }
  17.     if (atoi(yr1) < atoi(yr2))
  18.         return -1;
  19.     else if (atoi(yr1) > atoi(yr2))
  20.         return 1;
  21.    
  22.     //else if years are equal
  23.     for (i=0; i<2;i++ ) {
  24.         mon1[i] = date1[i+5];
  25.         mon2[i] = date2[i+5];
  26.     }
  27.     if (atoi(mon1) < atoi(mon2))
  28.         return -1;
  29.     else if (atoi(mon1) > atoi(mon2))
  30.         return 1;
  31.     //else if months are equal
  32.     for (i=0; i<2;i++ ) {
  33.         mon1[i] = date1[i+8];
  34.         mon2[i] = date2[i+8];
  35.     }
  36.     if (atoi(mon1) < atoi(mon2))
  37.         return -1;
  38.     else if (atoi(mon1) > atoi(mon2))
  39.         return 1;
  40.     else
  41.         return 0;
  42. }
  43.  
  44.  
  45. void  checkQuery(PGresult* res)
  46. {
  47.     if(!res || PQresultStatus(res) != PGRES_TUPLES_OK){
  48.         fprintf(stdout, "Error executing query: %s\n",
  49.             PQresultErrorMessage(res));
  50.         PQclear(res);
  51.         exit(1);
  52.     }
  53. }
  54.  
  55. int dropView (PGconn* conn, char* cmd, char* viewName, int viewsToDrop) {
  56.         if (0 > viewsToDrop--)  {
  57.             PQfinish(conn);
  58.             exit(1);
  59.         }
  60.         sprintf(cmd,viewName);
  61.         PQexec(conn,cmd);
  62.         return viewsToDrop;
  63. }
  64.  
  65. void  checkCmd(PGresult* res)   {
  66.  
  67.     if(!res || PQresultStatus(res) != PGRES_COMMAND_OK) {
  68.         fprintf(stdout, "Error executing query: %s\n",
  69.             PQresultErrorMessage(res));
  70.         PQclear(res);
  71.         return;
  72.     }
  73. }
  74.  
  75. void  checkCmdDropViews(PGconn* conn, PGresult* res, int viewsToDrop)   {
  76.  
  77.     if(!res || PQresultStatus(res) != PGRES_COMMAND_OK) {
  78.         char cmd[50];
  79.         fprintf(stdout, "Error executing query: %s\n",
  80.             PQresultErrorMessage(res));
  81.         PQclear(res);
  82.         fprintf(stdout, "Dropping temp views.\n");
  83.        
  84.         viewsToDrop = dropView (conn, cmd, "DROP VIEW loser_versions", viewsToDrop);
  85.         viewsToDrop = dropView (conn, cmd, "DROP VIEW first_update", viewsToDrop);
  86.         viewsToDrop = dropView (conn, cmd, "DROP VIEW hostiles", viewsToDrop);
  87.         viewsToDrop = dropView (conn, cmd, "DROP VIEW hos_count", viewsToDrop);
  88.         viewsToDrop = dropView (conn, cmd, "DROP VIEW hostileNoriginal", viewsToDrop);
  89.         viewsToDrop = dropView (conn, cmd, "DROP VIEW pre_report", viewsToDrop);
  90.         viewsToDrop = dropView (conn, cmd, "DROP VIEW usersusers", viewsToDrop);
  91.         exit (1);
  92.        
  93.     }
  94. }
  95.    
  96.  
  97.  
  98.  
  99. void  checkConn(PGconn* conn)   {
  100.    
  101.     if (!conn || PQstatus(conn) == CONNECTION_BAD) {
  102.         fprintf(stdout, "Connection to server failed: %s\n",
  103.             PQerrorMessage(conn));
  104.         PQfinish(conn);
  105.         exit(1);
  106.     }
  107. }
  108. // ============================ MAIN FUNCTIONS ================================
  109.    
  110. void * addUser(int id, char * name)
  111. {
  112.     char cmd[200];
  113.     char connect_param[80];
  114.     PGresult *res;
  115.     PGconn *conn;
  116.     sprintf(connect_param,
  117.         "host=pgsql.cs.technion.ac.il dbname=%s user=%s password=%s",
  118.         USERNAME, USERNAME, PASSWORD);
  119.     conn = PQconnectdb(connect_param);
  120.     checkConn(conn);
  121.     sprintf(cmd, "SELECT * FROM users
  122.                     WHERE id=%d", id);
  123.     res = PQexec(conn, cmd);
  124.     checkQuery(res);
  125.     if (PQntuples(res)!=0){
  126.         printf (ILL_PARAMS);
  127.         return NULL;
  128.     }
  129.     cmd[0] = '\0';
  130.     sprintf(cmd, "INSERT INTO users VALUES %d %s", id, name);
  131.     res = PQexec(conn, cmd);
  132.     checkCmd(res);
  133.     PQfinish(conn);
  134.     return NULL;
  135. }
  136.  
  137. void * addEditor(int id)
  138. {
  139.     char cmd[200];
  140.     char connect_param[80];
  141.     PGresult *res;
  142.     PGconn *conn;
  143.     sprintf(connect_param,
  144.         "host=pgsql.cs.technion.ac.il dbname=%s user=%s password=%s",
  145.         USERNAME, USERNAME, PASSWORD);
  146.     conn = PQconnectdb(connect_param);
  147.     checkConn(conn);
  148.     sprintf(cmd, "SELECT * FROM users
  149.                     WHERE id=%d", id);
  150.     res = PQexec(conn, cmd);
  151.     checkQuery(res);
  152.     if (PQntuples(res)==0){
  153.         printf (ILL_PARAMS);
  154.         return NULL;
  155.     }
  156.    
  157.     sprintf(cmd, "SELECT * FROM editor
  158.                     WHERE id=%d", id);
  159.     res = PQexec(conn, cmd);
  160.     checkQuery(res);
  161.     if (PQntuples(res)!=0){
  162.         printf (ILL_PARAMS);
  163.         return NULL;
  164.     }
  165.    
  166.     sprintf(cmd, "INSERT INTO editor VALUES %d", id);
  167.     res = PQexec(conn, cmd);
  168.     checkCmd(res);
  169.     PQfinish(conn);
  170.     return NULL;
  171. }
  172.  
  173. void * addAdmin(int id)
  174. {
  175.     char cmd[200];
  176.     char connect_param[80];
  177.     PGresult *res;
  178.     PGconn *conn;
  179.     sprintf(connect_param,
  180.         "host=pgsql.cs.technion.ac.il dbname=%s user=%s password=%s",
  181.         USERNAME, USERNAME, PASSWORD);
  182.     conn = PQconnectdb(connect_param);
  183.     checkConn(conn);
  184.     sprintf(cmd, "SELECT * FROM users
  185.                     WHERE id=%d", id);
  186.     res = PQexec(conn, cmd);
  187.     checkQuery(res);
  188.     if (PQntuples(res)==0){
  189.         printf (ILL_PARAMS);
  190.         return NULL;
  191.     }
  192.    
  193.     sprintf(cmd, "SELECT * FROM admin
  194.                     WHERE id=%d", id);
  195.     res = PQexec(conn, cmd);
  196.     checkQuery(res);
  197.     if (PQntuples(res)!=0){
  198.         printf (ILL_PARAMS);
  199.         return NULL;
  200.     }
  201.    
  202.     sprintf(cmd, "SELECT * FROM editor
  203.                     WHERE id=%d", id);
  204.     res = PQexec(conn, cmd);
  205.     checkQuery(res);
  206.     if (PQntuples(res)==0){
  207.            
  208.             sprintf(cmd, "INSERT INTO editor VALUES %d", id);
  209.             res = PQexec(conn, cmd);
  210.             checkCmd(res);
  211.     }
  212.    
  213.     sprintf(cmd, "INSERT INTO admin VALUES %d", id);
  214.     res = PQexec(conn, cmd);
  215.     checkCmd(res);
  216.     PQfinish(conn);
  217.     return NULL;
  218. }
  219. void * addLink(char * fromTitle, char * toTitle)
  220. {
  221.     char cmd[200];
  222.     PGresult *res1, *res2;
  223.     PGconn *conn;
  224.     char connect_param[80];
  225.         sprintf(connect_param,
  226.         "host=pgsql.cs.technion.ac.il dbname=%s user=%s password=%s",
  227.         USERNAME, USERNAME, PASSWORD);
  228.     conn = PQconnectdb(connect_param);
  229.     checkConn(conn);
  230.     sprintf(cmd, "SELECT * FROM article
  231.                     WHERE title=%s", fromTitle);
  232.     res1 = PQexec(conn, cmd);
  233.     checkQuery(res1);
  234.    
  235.     sprintf(cmd, "SELECT * FROM article
  236.                     WHERE title=%s", toTitle);
  237.     res2 = PQexec(conn, cmd);
  238.     checkQuery(res2);
  239.     if ((PQntuples(res1)==0) || (PQntuples(res2)==0)) {
  240.         printf(ILL_PARAMS);
  241.         return NULL;
  242.     }
  243.    
  244.     sprintf(cmd, "INSERT INTO link VALUES '%s' '%s'", fromTitle, toTitle);
  245.     res1 = PQexec(conn, cmd);
  246.     checkCmd(res1);
  247.     PQfinish(conn);
  248.     return NULL;
  249. }
  250.  
  251. void * addViewed(int id, char * title, char * date)
  252. {
  253.     char cmd[200];
  254.     char connect_param[80];
  255.     PGresult *res1, *res2;
  256.     PGconn *conn;
  257.     sprintf(connect_param,
  258.         "host=pgsql.cs.technion.ac.il dbname=%s user=%s password=%s",
  259.         USERNAME, USERNAME, PASSWORD);
  260.     conn = PQconnectdb(connect_param);
  261.     checkConn(conn);
  262.     sprintf(cmd, "SELECT * FROM users
  263.                     WHERE id=%d", id);
  264.     res1 = PQexec(conn, cmd);
  265.     checkQuery(res1);
  266.    
  267.     sprintf(cmd, "SELECT * FROM version
  268.                     WHERE title=%s", title);
  269.     res2 = PQexec(conn, cmd);
  270.     checkQuery(res2);
  271.     if ((PQntuples(res1)==0) || (PQntuples(res2)==0)) {
  272.         printf(ILL_PARAMS);
  273.         return NULL;
  274.     }
  275.    
  276.     sprintf(cmd, "INSERT INTO viewed VALUES %d %s DATE(%s)", id, title, date);
  277.     res1 = PQexec(conn, cmd);
  278.     checkCmd(res1);
  279.     PQfinish(conn);
  280.     return NULL;
  281. }
  282.  
  283. void * addVersion(int id, char * date, char * title, char * content)
  284. {
  285.     char cmd[200];
  286.     char connect_param[80];
  287.     PGresult *res;
  288.     PGconn *conn;
  289.     printf("in addVer().\n");
  290.     sprintf(connect_param,
  291.         "host=pgsql.cs.technion.ac.il dbname=%s user=%s password=%s",
  292.         USERNAME, USERNAME, PASSWORD);
  293.     conn = PQconnectdb(connect_param);
  294.     checkConn(conn);
  295.     sprintf(cmd, "SELECT * FROM editor WHERE id=%d", id);
  296.     res = PQexec(conn, cmd);
  297.     checkQuery(res);
  298.     if (PQntuples(res)==0) {
  299.         printf(ILL_PARAMS);
  300.         return NULL;
  301.     }
  302.    
  303.     sprintf(cmd, "SELECT * FROM article WHERE title='%s'", title);
  304.     res = PQexec(conn, cmd);
  305.     checkQuery(res);
  306.     if (PQntuples(res)==0) {
  307.         sprintf(cmd, "INSERT INTO article VALUES ('%s') ", title);
  308.         res = PQexec(conn, cmd);
  309.         checkCmd(res);
  310.     }
  311.     sprintf(cmd, "INSERT INTO version VALUES (%d,'%s','%s','%s')", id, date, title, content);
  312.     res = PQexec(conn, cmd);
  313.     checkCmd(res);
  314.     PQfinish(conn);
  315.     printf("not in addVer().\n");
  316.     return NULL;
  317. }
  318.  
  319. void * addAccepted(int eid, int aid, char * title, char * vdate, char * adate)
  320. {
  321.     char cmd[200];
  322.     char connect_param[80];
  323.     PGresult *res1, *res2;
  324.     PGconn *conn;
  325.     sprintf(connect_param,
  326.         "host=pgsql.cs.technion.ac.il dbname=%s user=%s password=%s",
  327.         USERNAME, USERNAME, PASSWORD);
  328.     conn = PQconnectdb(connect_param);
  329.     checkConn(conn);
  330.     sprintf(cmd, "SELECT * FROM admin
  331.                     WHERE id=%d", aid);
  332.     res1 = PQexec(conn, cmd);
  333.     checkQuery(res1);
  334.    
  335.     sprintf(cmd, "SELECT * FROM editor
  336.                     WHERE id=%d", eid);
  337.     res2 = PQexec(conn, cmd);
  338.     if(!res2 || PQresultStatus(res2) != PGRES_TUPLES_OK){
  339.         fprintf(stdout, "Error executing query: %s\n",
  340.         PQresultErrorMessage(res2));
  341.         PQclear(res2);
  342.         return NULL;
  343.     }
  344.     if ((PQntuples(res1)==0) || (PQntuples(res2)==0)) {
  345.         printf(ILL_PARAMS);
  346.         return NULL;
  347.     }
  348.    
  349.     sprintf(cmd, "SELECT * FROM version
  350.                     WHERE title=%s AND date= %s", title, vdate);
  351.     res1 = PQexec(conn, cmd);
  352.     checkQuery(res1);
  353.     if ((PQntuples(res1)==0) || (cmpDates(adate,vdate)==-1)) {
  354.         printf(ILL_PARAMS);
  355.         return NULL;
  356.     }
  357.    
  358.     sprintf(cmd, "INSERT INTO accepted VALUES %d, %d, %s, DATE(%s), DATE(%s)",eid, aid, title,vdate,adate);
  359.     res1 = PQexec(conn, cmd);
  360.     checkCmd(res1);
  361.     PQfinish(conn);
  362.     return NULL;
  363. }
  364.  
  365. void * removeUser(int id, int opt, int newId)
  366. {
  367.     char cmd[200];
  368.     char connect_param[80];
  369.     PGresult *res,*res1,*res2;
  370.     PGconn *conn;
  371.     sprintf(connect_param,
  372.         "host=pgsql.cs.technion.ac.il dbname=%s user=%s password=%s",
  373.         USERNAME, USERNAME, PASSWORD);
  374.     conn = PQconnectdb(connect_param);
  375.     checkConn(conn);
  376.     sprintf(cmd, "SELECT * FROM users
  377.                     WHERE id=%d", id);
  378.     res = PQexec(conn, cmd);
  379.     checkQuery(res);
  380.     if (PQntuples(res)==0){
  381.         printf (ILL_PARAMS);
  382.         return NULL;
  383.     }
  384.    
  385.     sprintf(cmd, "SELECT * FROM viewed  WHERE id=%d", id);
  386.     res1 = PQexec(conn, cmd);
  387.     checkCmd(res1);
  388.    
  389.     sprintf(cmd, "SELECT * FROM accepted WHERE aid=%d", id);
  390.     res2 = PQexec(conn, cmd);
  391.     checkCmd(res2);
  392.     if ( (PQntuples(res1)!=0) && (PQntuples(res2)!=0) && (opt==REJECT)) {
  393.         printf(ILL_PARAMS);
  394.         return NULL;
  395.     }
  396.     switch (opt)    {
  397.         case DELETE:
  398.            
  399.             sprintf(cmd, "DELETE FROM viewed WHERE id=%d", id);
  400.             res = PQexec(conn, cmd);
  401.             checkCmd(res);
  402.            
  403.             sprintf(cmd, "DELETE FROM accepted WHERE aid=%d", id);
  404.             res = PQexec(conn, cmd);
  405.             checkCmd(res);
  406.            
  407.             sprintf(cmd, "DELETE FROM accepted WHERE eid=%d",id);
  408.             res = PQexec(conn, cmd);
  409.             checkCmd(res);
  410.            
  411.             sprintf(cmd,"DELETE FROM viewed WHERE title, date IN
  412.                     SELECT title, date FROM viewed
  413.                     WHERE date < ALL(SELECT adate FROM accepted WHERE accepted.title=viewed.title)");
  414.             res = PQexec(conn,cmd);
  415.             checkCmd(res);
  416.            
  417.             break;
  418.    
  419.         case CHANGE:
  420.            
  421.             sprintf(cmd, "SELECT * FROM editor WHERE id=%d", id);
  422.             res1 = PQexec(conn, cmd);
  423.             checkQuery (res1);
  424.             if (PQntuples(res1) >0) {
  425.                
  426.                 sprintf(cmd, "SELECT * FROM editor WHERE id=%d", newId);
  427.                 res2 = PQexec(conn, cmd);
  428.                 checkQuery (res2);
  429.                 if (PQntuples(res2)==0)  {
  430.                     printf(ILL_PARAMS);
  431.                     return NULL;
  432.                 }
  433.             }
  434.            
  435.             sprintf(cmd, "SELECT * FROM accepted WHERE aid=%d", id);
  436.             res1 = PQexec(conn, cmd);
  437.             checkQuery (res1);
  438.             if (PQntuples(res1) >0) {
  439.                
  440.                 sprintf(cmd, "SELECT * FROM admin WHERE id=%d", newId);
  441.                 res2 = PQexec(conn, cmd);
  442.                 checkQuery (res2);
  443.                 if (PQntuples(res2)==0)  {
  444.                     printf(ILL_PARAMS);
  445.                     return NULL;
  446.                 }
  447.             }
  448.            
  449.             sprintf(cmd, "UPDATE version SET id=%d WHERE id=%d", newId, id);
  450.             res = PQexec(conn, cmd);
  451.             checkCmd (res);
  452.            
  453.             sprintf(cmd, "UPDATE accepted SET eid=%d WHERE eid=%d", newId, id);
  454.             res = PQexec(conn, cmd);
  455.             checkCmd (res);
  456.            
  457.             sprintf(cmd, "UPDATE accepted SET aid=%d WHERE aid=%d", newId, id);
  458.             res = PQexec(conn, cmd);
  459.             checkCmd (res);
  460.         break;
  461.         default: printf("error! default case reached in removeUSer()!.\n");
  462.             exit(1);   
  463.             break;
  464.     }
  465.     sprintf(cmd, "DELETE FROM users WHERE id=%d", id);
  466.     res = PQexec(conn, cmd);
  467.     checkCmd(res);
  468.    
  469.    
  470.     sprintf(cmd, "DELETE FROM editor WHERE id=%d", id);
  471.     res = PQexec(conn, cmd);
  472.     checkCmd(res);
  473.    
  474.     sprintf(cmd, "DELETE FROM admin WHERE id=%d", id);
  475.     res = PQexec(conn, cmd);
  476.     checkCmd(res);
  477. }
  478. void * popularVersions(char * fromDate, char * toDate, int distinct, int aboveAvg)
  479. {
  480.     return NULL;
  481. }
  482. void * hostileEditors()
  483. {
  484.     char cmd[400];
  485.     char connect_param[200];
  486.     PGresult *res,*res1,*res2;
  487.     int i,nTuples;
  488.     PGconn *conn;
  489.     int viewsToDrop = 1;
  490.  
  491.     printf("in hostileeditors().\n");
  492.    
  493.     sprintf(connect_param,
  494.         "host=pgsql.cs.technion.ac.il dbname=%s user=%s password=%s",
  495.         USERNAME, USERNAME, PASSWORD);
  496.     conn = PQconnectdb(connect_param);
  497.     checkConn(conn);
  498.     sprintf(cmd, "CREATE VIEW loser_versions AS (SELECT id, title, date FROM version WHERE      id IN(          SELECT id FROM editor           WHERE id NOT IN (SELECT id FROM version)))");
  499.     res = PQexec(conn, cmd);
  500.     checkCmdDropViews(conn, res, viewsToDrop++);
  501.    
  502.     sprintf(cmd,"CREATE VIEW TempView1 AS       SELECT N.id AS Editor, V.id AS O_Editor, V.title AS title, N.date AS e_date, V.date AS o_date       FROM loser_versions N LEFT OUTER JOIN Version V         ON (N.title = V.title) AND (V.date - N.date BETWEEN 0 AND 7) AND (V.id <> N.id)");
  503.     PQclear(res);
  504.     res = PQexec(conn,cmd);
  505.     checkCmdDropViews(conn, res, viewsToDrop++);
  506.  
  507.     sprintf(cmd,"CREATE VIEW first_update AS    SELECT Editor, title, e_date, min(o_date) AS orig_date  FROM TempView1  GROUP BY Editor,title,e_date");
  508.     PQclear(res);
  509.     res = PQexec(conn,cmd);
  510.     checkCmdDropViews(conn, res, viewsToDrop++);
  511.  
  512.     sprintf(cmd,"CREATE VIEW hostiles AS        SELECT DISTINCT T1.Editor, o_editor     FROM TempView1 T1, first_update F       WHERE (T1.editor = F.editor) AND (T1.o_date = F.orig_date)");
  513.     PQclear(res);
  514.     res = PQexec(conn,cmd);
  515.     checkCmdDropViews(conn, res, viewsToDrop++);
  516.  
  517.     sprintf(cmd,"CREATE VIEW hos_count AS       SELECT * FROM       (SELECT editor, count(o_editor) as num FROM hostiles GROUP BY editor) T     WHERE num = 1");
  518.     PQclear(res);
  519.     res = PQexec(conn,cmd);
  520.     checkCmdDropViews(conn, res, viewsToDrop++);
  521.  
  522.     sprintf(cmd,"CREATE VIEW hostileNoriginal AS        SELECT hos_count.editor, o_editor FROM      hos_count LEFT OUTER JOIN hostiles ON (hos_count.editor = hostiles.editor)");
  523.     PQclear(res);
  524.     res = PQexec(conn,cmd);
  525.     checkCmdDropViews(conn, res, viewsToDrop++);
  526.  
  527.     sprintf(cmd,"CREATE VIEW pre_report AS      SELECT loser_versions.id AS loser_id, o_editor AS hostile_id FROM       loser_versions LEFT OUTER JOIN hostileNoriginal HN ON (loser_versions.id = HN.editor)       ORDER BY loser_versions.id");
  528.     PQclear(res);
  529.     res = PQexec(conn,cmd);
  530.     checkCmdDropViews(conn, res, viewsToDrop++);
  531.  
  532.     sprintf(cmd,"CREATE VIEW usersusers AS      SELECT U1.id AS u1_id, U1.name AS u1_name, U2.id AS u2_id, U2.name AS u2_name FROM users U1, users U2");
  533.     PQclear(res);
  534.     res = PQexec(conn,cmd);
  535.     checkCmdDropViews(conn, res, viewsToDrop++);
  536.  
  537.  
  538.     sprintf(cmd,"SELECT u1_id,u1_name,u2_id,u2_name FROM pre_report LEFT OUTER JOIN usersusers ON (u1_id=pre_report.loser_id) AND (u2_id=pre_report.hostile_id)");
  539.     PQclear(res);
  540.     res = PQexec(conn,cmd);
  541.     checkQuery(res);
  542.     nTuples=PQntuples(res);
  543.     printf(HOSTILE_EDITOR_HEAD);
  544.     for (i=0;i<nTuples;i++) {
  545.         char value1[11];
  546.         char value2[16];
  547.         char value3[11];
  548.         char value4[16];
  549.         strcpy(value1, PQgetvalue(res, i,1));
  550.         strcpy(value2, PQgetvalue(res, i,2));
  551.         if (!PQgetisnull(res, i, 3))
  552.             strcpy(value3, PQgetvalue(res, i,3));
  553.         else
  554.             strcpy(value3, "");
  555.         if (!PQgetisnull(res, i, 4))
  556.             strcpy(value4, PQgetvalue(res, i,4));
  557.         else
  558.             strcpy(value4, "");
  559.         printf(HOSTILE_EDITOR_REC,value1,value2,value3,value4);
  560.     }
  561.    
  562.     sprintf(cmd,"DROP VIEW loser_versions");
  563.     res = PQexec(conn,cmd);
  564.     //checkCmdDropViews(res, viewsToDrop--);
  565.  
  566.     sprintf(cmd,"DROP VIEW TempView1");
  567.     res = PQexec(conn,cmd);
  568.     //checkCmdDropViews(conn, res, viewsToDrop++);
  569.  
  570.     sprintf(cmd,"DROP VIEW first_update");
  571.     res = PQexec(conn,cmd);
  572.     //checkCmdDropViews(conn, res, viewsToDrop++);
  573.  
  574.     sprintf(cmd,"DROP VIEW hostiles");
  575.     res = PQexec(conn,cmd);
  576.     //checkCmdDropViews(conn, res, viewsToDrop++);
  577.  
  578.     sprintf(cmd,"DROP VIEW hos_count");
  579.     res = PQexec(conn,cmd);
  580.     //checkCmdDropViews(conn, res, viewsToDrop++);
  581.  
  582.     sprintf(cmd,"DROP VIEW hostileNoriginal");
  583.     res = PQexec(conn,cmd);
  584.     //checkCmdDropViews(conn, res, viewsToDrop++);
  585.  
  586.     sprintf(cmd,"DROP VIEW pre_report");
  587.     res = PQexec(conn,cmd);
  588.     //checkCmdDropViews(conn, res, viewsToDrop++);
  589.     PQclear(res);
  590.     PQfinish(conn);
  591.     printf("not in hostileeditors().\n");
  592.     return NULL;
  593. }
  594.  
  595. int main()
  596. {
  597.     startParsing();
  598. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement