@@ -148,11 +148,17 @@ process_truncate(Node *parsetree)
148
148
149
149
foreach (cell , truncatestmt -> relations )
150
150
{
151
- Oid relId = RangeVarGetRelid (lfirst (cell ), NoLock , true);
151
+ RangeVar * relation = lfirst (cell );
152
+ Oid relid ;
152
153
153
- if (OidIsValid (relId ))
154
+ if (NULL == relation )
155
+ continue ;
156
+
157
+ relid = RangeVarGetRelid (relation , NoLock , true);
158
+
159
+ if (OidIsValid (relid ))
154
160
{
155
- Hypertable * ht = hypertable_cache_get_entry (hcache , relId );
161
+ Hypertable * ht = hypertable_cache_get_entry (hcache , relid );
156
162
157
163
if (ht != NULL )
158
164
{
@@ -172,7 +178,7 @@ process_alterobjectschema(Node *parsetree)
172
178
Cache * hcache ;
173
179
Hypertable * ht ;
174
180
175
- if (alterstmt -> objectType != OBJECT_TABLE )
181
+ if (alterstmt -> objectType != OBJECT_TABLE || NULL == alterstmt -> relation )
176
182
return ;
177
183
178
184
relid = RangeVarGetRelid (alterstmt -> relation , NoLock , true);
@@ -202,7 +208,7 @@ process_copy(Node *parsetree, const char *query_string, char *completion_tag)
202
208
Cache * hcache ;
203
209
Oid relid ;
204
210
205
- if (!stmt -> is_from )
211
+ if (!stmt -> is_from || NULL == stmt -> relation )
206
212
return false;
207
213
208
214
relid = RangeVarGetRelid (stmt -> relation , NoLock , true);
@@ -326,7 +332,13 @@ process_drop_table(DropStmt *stmt)
326
332
foreach (lc , stmt -> objects )
327
333
{
328
334
List * object = lfirst (lc );
329
- Oid relid = RangeVarGetRelid (makeRangeVarFromNameList (object ), NoLock , true);
335
+ RangeVar * relation = makeRangeVarFromNameList (object );
336
+ Oid relid ;
337
+
338
+ if (NULL == relation )
339
+ continue ;
340
+
341
+ relid = RangeVarGetRelid (relation , NoLock , true);
330
342
331
343
if (OidIsValid (relid ))
332
344
{
@@ -428,8 +440,13 @@ process_drop_index(DropStmt *stmt)
428
440
foreach (lc , stmt -> objects )
429
441
{
430
442
List * object = lfirst (lc );
431
- RangeVar * rv = makeRangeVarFromNameList (object );
432
- Oid idxrelid = RangeVarGetRelid (rv , NoLock , true);
443
+ RangeVar * relation = makeRangeVarFromNameList (object );
444
+ Oid idxrelid ;
445
+
446
+ if (NULL == relation )
447
+ continue ;
448
+
449
+ idxrelid = RangeVarGetRelid (relation , NoLock , true);
433
450
434
451
if (OidIsValid (idxrelid ))
435
452
{
@@ -511,7 +528,16 @@ static bool
511
528
process_reindex (Node * parsetree )
512
529
{
513
530
ReindexStmt * stmt = (ReindexStmt * ) parsetree ;
514
- Oid relid = RangeVarGetRelid (stmt -> relation , NoLock , true);
531
+ Oid relid ;
532
+
533
+ if (NULL == stmt -> relation )
534
+ /* Not a case we are interested in */
535
+ return false;
536
+
537
+ relid = RangeVarGetRelid (stmt -> relation , NoLock , true);
538
+
539
+ if (!OidIsValid (relid ))
540
+ return false;
515
541
516
542
switch (stmt -> kind )
517
543
{
@@ -571,8 +597,13 @@ process_rename_column(Cache *hcache, Oid relid, RenameStmt *stmt)
571
597
static void
572
598
process_rename_index (Cache * hcache , Oid relid , RenameStmt * stmt )
573
599
{
574
- Oid tablerelid = IndexGetRelation (relid , false);
575
- Hypertable * ht = hypertable_cache_get_entry (hcache , tablerelid );
600
+ Oid tablerelid = IndexGetRelation (relid , true);
601
+ Hypertable * ht ;
602
+
603
+ if (!OidIsValid (tablerelid ))
604
+ return ;
605
+
606
+ ht = hypertable_cache_get_entry (hcache , tablerelid );
576
607
577
608
if (NULL != ht )
578
609
chunk_index_rename_parent (ht , relid , stmt -> newname );
@@ -589,14 +620,20 @@ static void
589
620
process_rename (Node * parsetree )
590
621
{
591
622
RenameStmt * stmt = (RenameStmt * ) parsetree ;
592
- Oid relid = RangeVarGetRelid ( stmt -> relation , NoLock , true) ;
623
+ Oid relid ;
593
624
Cache * hcache ;
594
625
595
- /* TODO: forbid all rename op on chunk table */
626
+ if (NULL == stmt -> relation )
627
+ /* Not an object we are interested in */
628
+ return ;
629
+
630
+ relid = RangeVarGetRelid (stmt -> relation , NoLock , true);
596
631
597
632
if (!OidIsValid (relid ))
598
633
return ;
599
634
635
+ /* TODO: forbid all rename op on chunk table */
636
+
600
637
hcache = hypertable_cache_pin ();
601
638
602
639
switch (stmt -> renameType )
0 commit comments