@@ -341,39 +341,64 @@ static PgQueryError *apply_truncations(Summary *summary, Node *tree, TruncationS
341341 stmt -> whereClause = (Node * ) dummy_column ();
342342 }
343343 else if (IsA (node , SelectStmt ) && attr == TRUNCATION_VALUES_LISTS ) {
344+ SelectStmt * stmt = castNode (SelectStmt , node );
345+ stmt -> valuesLists = list_make1 (dummy_column ());
344346 printf ("Select/valuesLists\n" );
345347 }
346348 else if (IsA (node , UpdateStmt ) && attr == TRUNCATION_TARGET_LIST ) {
349+ UpdateStmt * stmt = castNode (UpdateStmt , node );
350+ stmt -> targetList = list_make1 (dummy_target ());
347351 printf ("UpdateStmt/targetList\n" );
348352 }
349353 else if (IsA (node , UpdateStmt ) && attr == TRUNCATION_WHERE_CLAUSE ) {
354+ UpdateStmt * stmt = castNode (UpdateStmt , node );
355+ stmt -> whereClause = (Node * ) dummy_column ();
350356 printf ("UpdateStmt/whereClause\n" );
351357 }
352358 else if (IsA (node , DeleteStmt ) && attr == TRUNCATION_WHERE_CLAUSE ) {
359+ DeleteStmt * stmt = castNode (DeleteStmt , node );
360+ stmt -> whereClause = (Node * ) dummy_column ();
353361 printf ("Delete/whereClause\n" );
354362 }
355363 else if (IsA (node , CopyStmt ) && attr == TRUNCATION_WHERE_CLAUSE ) {
364+ CopyStmt * stmt = castNode (CopyStmt , node );
365+ stmt -> whereClause = (Node * ) dummy_column ();
356366 printf ("Copy/whereClause\n" );
357367 }
358368 else if (IsA (node , InsertStmt ) && attr == TRUNCATION_COLS ) {
369+ InsertStmt * stmt = castNode (InsertStmt , node );
370+ stmt -> cols = list_make1 (dummy_target ());
359371 printf ("Insert/cols\n" );
360372 }
361373 else if (IsA (node , IndexStmt ) && attr == TRUNCATION_WHERE_CLAUSE ) {
374+ IndexStmt * stmt = castNode (IndexStmt , node );
375+ stmt -> whereClause = (Node * ) dummy_column ();
362376 printf ("Index/whereClause\n" );
363377 }
364378 else if (IsA (node , RuleStmt ) && attr == TRUNCATION_WHERE_CLAUSE ) {
379+ RuleStmt * stmt = castNode (RuleStmt , node );
380+ stmt -> whereClause = (Node * ) dummy_column ();
365381 printf ("Rule/whereClause\n" );
366382 }
367383 else if (IsA (node , CommonTableExpr ) && attr == TRUNCATION_CTE_QUERY ) {
384+ CommonTableExpr * stmt = castNode (CommonTableExpr , node );
385+ stmt -> ctequery = dummy_select (NULL , (Node * ) dummy_column (), NULL );
386+ // FIXME: https://github.com/pganalyze/pg_query.rs/blob/66eb7becea1a40e315fee3f90197a35a89d20c25/src/truncate.rs#L230-L237
368387 printf ("CTE/cteQuery\n" );
369388 }
370389 else if (IsA (node , InferClause ) && attr == TRUNCATION_WHERE_CLAUSE ) {
390+ InferClause * stmt = castNode (InferClause , node );
391+ stmt -> whereClause = (Node * ) dummy_column ();
371392 printf ("InferClause/whereClause\n" );
372393 }
373394 else if (IsA (node , OnConflictClause ) && attr == TRUNCATION_TARGET_LIST ) {
395+ OnConflictClause * stmt = castNode (OnConflictClause , node );
396+ stmt -> targetList = list_make1 (dummy_target ());
374397 printf ("OnConflictClause/targetList\n" );
375398 }
376399 else if (IsA (node , OnConflictClause ) && attr == TRUNCATION_WHERE_CLAUSE ) {
400+ OnConflictClause * stmt = castNode (OnConflictClause , node );
401+ stmt -> whereClause = (Node * ) dummy_column ();
377402 printf ("OnConflictClause/whereClause\n" );
378403 }
379404 else
0 commit comments