FOSSology  3.2.0rc1
Open Source License Compliance by Open Source Software
sqlstatements.h
Go to the documentation of this file.
1 /* **************************************************************
2 Copyright (C) 2012 Hewlett-Packard Development Company, L.P.
3 Copyright (C) 2015, 2018 Siemens AG
4 
5 This program is free software; you can redistribute it and/or
6 modify it under the terms of the GNU General Public License
7 version 2 as published by the Free Software Foundation.
8 
9 This program is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU General Public License for more details.
13 
14 You should have received a copy of the GNU General Public License along
15 with this program; if not, write to the Free Software Foundation, Inc.,
16 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
17  ************************************************************** */
18 
27 #ifndef SQLSTATEMENTS_H
28 #define SQLSTATEMENTS_H
29 
34  " SELECT column_name FROM information_schema.columns "
35  " WHERE table_catalog = '%s' "
36  " AND table_schema = 'public' "
37  " AND table_name = ";
38 
42 const char* url_checkout =
43  " SELECT conf_value FROM sysconfig "
44  " WHERE variablename = 'FOSSologyURL';";
45 
49 const char* select_upload_fk =
50  " SELECT job_upload_fk FROM job, jobqueue "
51  " WHERE jq_job_fk = job_pk "
52  " AND jq_pk = %d;";
53 
57 const char* upload_common =
58  " SELECT * FROM jobqueue "
59  " LEFT JOIN job ON jq_job_fk = job_pk"
60  " WHERE job.job_upload_fk = %d;";
61 
65 const char* folder_name =
66  " SELECT folder_name, folder_pk FROM folder "
67  " LEFT JOIN foldercontents ON folder_pk = foldercontents.parent_fk "
68  " LEFT JOIN job ON child_id = job_upload_fk "
69  " LEFT JOIN jobqueue ON jq_job_fk = job_pk "
70  " WHERE jq_pk = %d;";
71 
76 const char* parent_folder_name =
77  " SELECT folder_name, folder_pk FROM folder "
78  " INNER JOIN foldercontents ON folder_pk=foldercontents.parent_fk "
79  " WHERE child_id = %d AND foldercontents_mode = 1;";
80 
84 const char* upload_name =
85  " SELECT upload_filename FROM upload "
86  " LEFT JOIN job ON upload_pk = job_upload_fk "
87  " LEFT JOIN jobqueue ON jq_job_fk = job_pk "
88  " WHERE jq_pk = %d;";
89 
93 const char* upload_pk =
94  " SELECT upload_fk, uploadtree_pk FROM uploadtree "
95  " LEFT JOIN job ON upload_fk = job_upload_fk "
96  " LEFT JOIN jobqueue ON jq_job_fk = job_pk "
97  " WHERE parent IS NULL"
98  " AND jq_pk = %d;";
99 
103 const char* jobsql_email =
104  " SELECT user_name, user_email, email_notify FROM users, upload "
105  " WHERE user_pk = user_fk "
106  " AND upload_pk = %d;";
107 
111 const char* jobsql_email_job =
112  " SELECT user_name, user_email, email_notify FROM users, job, jobqueue "
113  " WHERE user_pk = job_user_fk AND job_pk = jq_job_fk "
114  " AND jq_pk = %d;";
115 
116 /* job queue related sql */
120 const char* basic_checkout =
121  " SELECT jobqueue.* FROM jobqueue INNER JOIN job ON job_pk = jq_job_fk "
122  " WHERE jq_starttime IS NULL AND jq_end_bits < 2 "
123  " AND NOT EXISTS(SELECT * FROM jobdepends, jobqueue jdep "
124  " WHERE jdep_jq_fk=jobqueue.jq_pk "
125  " AND jdep_jq_depends_fk=jdep.jq_pk"
126  " AND NOT(jdep.jq_endtime IS NOT NULL AND jdep.jq_end_bits < 2)) "
127  " ORDER BY job_priority DESC "
128  " LIMIT 10;";
129 
133 const char* jobsql_information =
134  " SELECT user_pk, job_priority, job_group_fk as group_pk FROM users "
135  " LEFT JOIN job ON job_user_fk = user_pk "
136  " WHERE job_pk = '%s';";
137 
141 const char* jobsql_started =
142  " UPDATE jobqueue "
143  " SET jq_starttime = now(), "
144  " jq_schedinfo ='%s.%d', "
145  " jq_endtext = 'Started' "
146  " WHERE jq_pk = '%d';";
147 
151 const char* jobsql_complete =
152  " UPDATE jobqueue "
153  " SET jq_endtime = now(), "
154  " jq_end_bits = jq_end_bits | 1, "
155  " jq_schedinfo = null, "
156  " jq_endtext = 'Completed' "
157  " WHERE jq_pk = '%d';";
158 
162 const char* jobsql_restart =
163  " UPDATE jobqueue "
164  " SET jq_endtext = 'Restarted', "
165  " jq_starttime = ( CASE "
166  " WHEN jq_starttime = CAST('9999-12-31' AS timestamp with time zone) "
167  " THEN null "
168  " ELSE jq_starttime "
169  " END ) "
170  " WHERE jq_pk = '%d';";
171 
175 const char* jobsql_failed =
176  " UPDATE jobqueue "
177  " SET jq_endtime = now(), "
178  " jq_end_bits = jq_end_bits | 2, "
179  " jq_schedinfo = null, "
180  " jq_endtext = '%s' "
181  " WHERE jq_pk = '%d';";
182 
186 const char* jobsql_processed =
187  " Update jobqueue "
188  " SET jq_itemsprocessed = %d "
189  " WHERE jq_pk = '%d';";
190 
194 const char* jobsql_paused =
195  " UPDATE jobqueue "
196  " SET jq_endtext = 'Paused', "
197  " jq_starttime = ( CASE "
198  " WHEN jq_starttime IS NULL "
199  " THEN CAST('9999-12-31' AS timestamp with time zone) "
200  " ELSE jq_starttime "
201  " END ) "
202  " WHERE jq_pk = '%d';";
203 
207 const char* jobsql_log =
208  " UPDATE jobqueue "
209  " SET jq_log = '%s' "
210  " WHERE jq_pk = '%d';";
211 
215 const char* jobsql_priority =
216  " UPDATE job "
217  " SET job_priority = '%d' "
218  " WHERE job_pk IN ( "
219  " SELECT jq_job_fk FROM jobqueue "
220  " WHERE jq_pk = '%d');";
221 
225 const char* jobsql_anyrunnable =
226  " SELECT * FROM jobqueue "
227  " WHERE jq_starttime IS NULL AND jq_end_bits < 2 "
228  " AND NOT EXISTS(SELECT * FROM jobdepends, jobqueue jdep "
229  " WHERE jdep_jq_fk=jobqueue.jq_pk "
230  " AND jdep_jq_depends_fk=jdep.jq_pk"
231  " AND NOT(jdep.jq_endtime IS NOT NULL AND jdep.jq_end_bits < 2))"
232  " AND jq_job_fk = (SELECT jq_job_fk FROM jobqueue queue WHERE queue.jq_pk = %d)";
233 
237 const char* jobsql_jobendbits =
238  " SELECT jq_pk, jq_end_bits FROM jobqueue "
239  " WHERE jq_job_fk = ( "
240  " SELECT jq_job_fk FROM jobqueue "
241  " WHERE jq_pk = %d "
242  " );";
243 
247 const char* jobsql_resetqueue =
248  "UPDATE jobqueue "
249  " SET jq_starttime=null, "
250  " jq_endtext=null, "
251  " jq_schedinfo=null "
252  " WHERE jq_endtime is NULL;";
253 
257 const char* jobsql_jobinfo =
258  " SELECT * FROM jobqueue "
259  " WHERE jq_job_fk = ( "
260  " SELECT jq_job_fk FROM jobqueue "
261  " WHERE jq_pk = %d "
262  " );";
263 
267 const char* smtp_values =
268  " SELECT conf_value, variablename FROM sysconfig "
269  " WHERE variablename LIKE 'SMTP%';";
270 
271 #endif /* SQLSTATEMENTS_H */
272 
const char * jobsql_email_job
const char * jobsql_started
const char * jobsql_paused
const char * jobsql_resetqueue
const char * upload_common
Definition: sqlstatements.h:57
const char * jobsql_processed
const char * jobsql_complete
const char * jobsql_restart
const char * url_checkout
Definition: sqlstatements.h:42
const char * jobsql_email
const char * basic_checkout
const char * jobsql_jobendbits
const char * jobsql_anyrunnable
const char * upload_name
Definition: sqlstatements.h:84
const char * jobsql_priority
const char * parent_folder_name
Definition: sqlstatements.h:76
const char * jobsql_information
const char * jobsql_failed
const char * check_scheduler_tables
Definition: sqlstatements.h:33
const char * smtp_values
const char * jobsql_jobinfo
const char * select_upload_fk
Definition: sqlstatements.h:49
const char * folder_name
Definition: sqlstatements.h:65
const char * upload_pk
Definition: sqlstatements.h:93
const char * jobsql_log